Skip to content

Commit 0c5cf41

Browse files
committed
fix tests to work with dict validation
Signed-off-by: Zen <[email protected]>
1 parent 4c57769 commit 0c5cf41

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

src/ugrd/base/test.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.5.4"
1+
__version__ = "0.6.0"
22

33
from zenlib.util import unset
44

@@ -26,30 +26,6 @@ def init_test_vars(self):
2626
self['test_flag'] = uuid4()
2727

2828

29-
def get_qemu_cmd_args(self):
30-
""" Gets the qemu command from the configuration """
31-
test_initrd = self._archive_out_path
32-
test_rootfs = self['_test_rootfs']['_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-
self['_qemu_cmd'] = ' '.join(str(arg) for arg in arglist)
49-
50-
return arglist
51-
52-
5329
def make_test_image(self):
5430
""" Creates a new initramfs generator to creaate the test image """
5531
from ugrd.initramfs_generator import InitramfsGenerator
@@ -73,14 +49,36 @@ def make_test_image(self):
7349
self['_test_rootfs'] = target_fs
7450

7551

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
72+
73+
7674
def test_image(self):
77-
qemu_cmd = get_qemu_cmd_args(self)
75+
qemu_cmd = _get_qemu_cmd_args(self)
7876
self.logger.info("Testing initramfs image: %s", self['_archive_out_path'])
7977
self.logger.debug("Test config:\n%s", self._test_rootfs)
8078
self.logger.info("Test kernel: %s", self['test_kernel'])
8179
self.logger.info("Test rootfs: %s", self['_test_rootfs']['_archive_out_path'])
8280
self.logger.info("Test flag: %s", self['test_flag'])
83-
self.logger.info("QEMU command: %s", self['_qemu_cmd'])
81+
self.logger.info("QEMU command: %s", ' '.join([str(arg) for arg in qemu_cmd]))
8482

8583
try:
8684
results = self._run(qemu_cmd, timeout=self['test_timeout'])

src/ugrd/base/test.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ 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+
1518
[imports.tests]
16-
"ugrd.base.test" = [ "make_test_image", "test_image" ]
19+
"ugrd.base.test" = [ "test_image" ]
1720

1821
[custom_parameters]
1922
test_kernel = "Path" # Define the kernel to use for the test

0 commit comments

Comments
 (0)