Skip to content

Commit f66f848

Browse files
committed
actually fix tests (maybe)
Signed-off-by: Zen <[email protected]>
1 parent 0c5cf41 commit f66f848

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

src/ugrd/base/test.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,30 @@ def init_test_vars(self):
2626
self['test_flag'] = uuid4()
2727

2828

29+
def _get_qemu_cmd_args(self, test_image):
30+
""" Gets the qemu command from the configuration """
31+
test_initrd = self._archive_out_path
32+
test_rootfs = test_image['_archive_out_path']
33+
qemu_args = {'-m': self['test_memory'],
34+
'-cpu': self['test_cpu'],
35+
'-kernel': self['test_kernel'],
36+
'-initrd': test_initrd,
37+
'-serial': 'mon:stdio',
38+
'-append': self['test_cmdline'],
39+
'-drive': 'file=%s,format=raw' % test_rootfs}
40+
41+
qemu_bools = [f'-{item}' for item in self['qemu_bool_args']]
42+
43+
arglist = [f"qemu-system-{self['test_arch']}"] + qemu_bools
44+
for key, value in qemu_args.items():
45+
arglist.append(key)
46+
arglist.append(value)
47+
48+
return arglist
49+
50+
2951
def make_test_image(self):
30-
""" Creates a new initramfs generator to creaate the test image """
52+
""" Creates a new initramfs generator to create the test image """
3153
from ugrd.initramfs_generator import InitramfsGenerator
3254

3355
kwargs = {'logger': self.logger,
@@ -46,37 +68,17 @@ def make_test_image(self):
4668
self.logger.error("Test image configuration:\n%s", target_fs)
4769
raise RuntimeError("Failed to build test rootfs: %s" % e)
4870

49-
self['_test_rootfs'] = target_fs
50-
51-
52-
def _get_qemu_cmd_args(self):
53-
""" Gets the qemu command from the configuration """
54-
test_initrd = self._archive_out_path
55-
test_rootfs = self['_test_rootfs']['_archive_out_path']
56-
qemu_args = {'-m': self['test_memory'],
57-
'-cpu': self['test_cpu'],
58-
'-kernel': self['test_kernel'],
59-
'-initrd': test_initrd,
60-
'-serial': 'mon:stdio',
61-
'-append': self['test_cmdline'],
62-
'-drive': 'file=%s,format=raw' % test_rootfs}
63-
64-
qemu_bools = [f'-{item}' for item in self['qemu_bool_args']]
65-
66-
arglist = [f"qemu-system-{self['test_arch']}"] + qemu_bools
67-
for key, value in qemu_args.items():
68-
arglist.append(key)
69-
arglist.append(value)
70-
71-
return arglist
71+
return target_fs
7272

7373

7474
def test_image(self):
75-
qemu_cmd = _get_qemu_cmd_args(self)
75+
image = make_test_image(self)
76+
qemu_cmd = _get_qemu_cmd_args(self, image)
77+
7678
self.logger.info("Testing initramfs image: %s", self['_archive_out_path'])
77-
self.logger.debug("Test config:\n%s", self._test_rootfs)
79+
self.logger.debug("Test config:\n%s", image)
7880
self.logger.info("Test kernel: %s", self['test_kernel'])
79-
self.logger.info("Test rootfs: %s", self['_test_rootfs']['_archive_out_path'])
81+
self.logger.info("Test rootfs: %s", image['_archive_out_path'])
8082
self.logger.info("Test flag: %s", self['test_flag'])
8183
self.logger.info("QEMU command: %s", ' '.join([str(arg) for arg in qemu_cmd]))
8284

src/ugrd/base/test.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ qemu_bool_args = ['nographic', 'no-reboot', 'enable-kvm']
1212
[imports.build_pre]
1313
"ugrd.base.test" = [ "init_test_vars" ]
1414

15-
[imports.build_tasks]
16-
"ugrd.base.test" = [ "make_test_image" ]
17-
1815
[imports.tests]
1916
"ugrd.base.test" = [ "test_image" ]
2017

@@ -30,5 +27,4 @@ test_flag = "str" # Define the success flag for the test
3027
test_rootfs_name = "str" # Define the name of the rootfs image
3128
test_rootfs_build_dir = "Path" # Define the build directory for the rootfs image
3229
qemu_bool_args = "NoDupFlatList" # Define the qemu boolean arguments
33-
_test_rootfs = "InitramfsGenerator" # Define the target rootfs generator
3430
_qemu_cmd = "str" # Define the qemu command to use for the test

0 commit comments

Comments
 (0)