@@ -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+
2951def 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
7474def 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
0 commit comments