Skip to content

Commit a5caae1

Browse files
committed
mock /sys/hypervisor
inorder to be able to run on a host without xen Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent f13d563 commit a5caae1

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xen-3.0-x86_64 hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64

mockrun-installer

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,24 @@ def mock_os_path_exists(path):
500500

501501
os.path.exists = mock_os_path_exists
502502

503+
#
504+
505+
def mocked_hardware_open(fname, mode='r', *args, **kwargs):
506+
logger.debug("open({!r}, mode={!r})".format(fname, mode))
507+
508+
realfname = fname # default
509+
510+
if fname.startswith('/sys/hypervisor/'):
511+
realfname = MOCKDATA + fname
512+
513+
if realfname != fname:
514+
logger.debug("redirecting open() to %r" % (realfname,))
515+
516+
return open(realfname, mode, *args, **kwargs)
517+
518+
import hardware
519+
hardware.open = mocked_hardware_open
520+
503521
####
504522

505523
from xcp import logger

0 commit comments

Comments
 (0)