Lines Matching +full:self +full:- +full:working +full:- +full:mode
23 # pylint: disable=invalid-name
24 # pylint: disable=consider-using-f-string
31 https://gitlab.com/qemu-project/biosbits-bits .
52 class QEMUBitsMachine(QEMUMachine): # pylint: disable=too-few-public-methods
54 A QEMU VM, with isa-debugcon enabled and bits iso passed
55 using -cdrom to QEMU commandline.
58 def __init__(self, argument
64 debugcon_log: str = "debugcon-log.txt",
67 # pylint: disable=too-many-arguments
70 name = "qemu-bits-%d" % os.getpid()
74 self.debugcon_log = debugcon_log
75 self.debugcon_addr = debugcon_addr
76 self.base_temp_dir = base_temp_dir
79 def _base_args(self) -> List[str]: argument
82 '-chardev',
83 'file,path=%s,id=debugcon' %os.path.join(self.base_temp_dir,
84 self.debugcon_log),
85 '-device',
86 'isa-debugcon,iobase=%s,chardev=debugcon' %self.debugcon_addr,
90 def base_args(self): argument
92 return self._base_args
96 class AcpiBitsTest(QemuSystemTest): #pylint: disable=too-many-instance-attributes
109 BITS_TAG = "qemu-bits-10262023"
111 ASSET_BITS = Asset(("https://gitlab.com/qemu-project/"
112 "biosbits-bits/-/jobs/artifacts/%s/"
113 "download?job=qemu-bits-build" % BITS_TAG),
116 def __init__(self, *args, **kwargs): argument
118 self._vm = None
120 self._debugcon_addr = '0x403'
121 self._debugcon_log = 'debugcon-log.txt'
123 def _print_log(self, log): argument
124 self.logger.info('\nlogs from biosbits follows:')
125 self.logger.info('==========================================\n')
126 self.logger.info(log)
127 self.logger.info('==========================================\n')
129 def copy_bits_config(self): argument
132 bits_config_file = self.data_file('acpi-bits',
133 'bits-config',
134 'bits-cfg.txt')
135 target_config_dir = self.scratch_file('bits-%d' %
136 self.BITS_INTERNAL_VER,
138 self.assertTrue(os.path.exists(bits_config_file))
139 self.assertTrue(os.path.exists(target_config_dir))
141 self.logger.info('copied config file %s to %s',
144 def copy_test_scripts(self): argument
147 bits_test_dir = self.data_file('acpi-bits', 'bits-tests')
148 target_test_dir = self.scratch_file('bits-%d' % self.BITS_INTERNAL_VER,
151 self.assertTrue(os.path.exists(bits_test_dir))
152 self.assertTrue(os.path.exists(target_test_dir))
166 self.logger.info('copied test file %s to %s',
175 self.logger.info('removed compiled file %s',
179 def fix_mkrescue(self, mkrescue): argument
180 """ grub-mkrescue is a bash script with two variables, 'prefix' and
183 the directory where we have extracted our pre-built bits grub
186 grub_x86_64_mods = self.scratch_file('grub-inst-x86_64-efi')
187 grub_i386_mods = self.scratch_file('grub-inst')
189 self.assertTrue(os.path.exists(grub_x86_64_mods))
190 self.assertTrue(os.path.exists(grub_i386_mods))
193 with open(mkrescue, 'r', encoding='utf-8') as filehandle:
201 with open(mkrescue, 'w', encoding='utf-8') as filehandle:
204 def generate_bits_iso(self): argument
205 """ Uses grub-mkrescue to generate a fresh bits iso with the python
208 bits_dir = self.scratch_file('bits-%d' % self.BITS_INTERNAL_VER)
209 iso_file = self.scratch_file('bits-%d.iso' % self.BITS_INTERNAL_VER)
210 mkrescue_script = self.scratch_file('grub-inst-x86_64-efi',
212 'grub-mkrescue')
214 self.assertTrue(os.access(mkrescue_script,
217 self.fix_mkrescue(mkrescue_script)
219 self.logger.info('using grub-mkrescue for generating biosbits iso ...')
223 proc = subprocess.run([mkrescue_script, '-o', iso_file,
228 self.logger.info("grub-mkrescue output %s" % proc.stdout)
230 subprocess.check_call([mkrescue_script, '-o',
234 except Exception as e: # pylint: disable=broad-except
235 self.skipTest("Error while generating the bits iso. "
239 self.assertTrue(os.access(iso_file, os.R_OK))
241 self.logger.info('iso file %s successfully generated.', iso_file)
243 def setUp(self): # pylint: disable=arguments-differ argument
245 self.logger = self.log
247 prebuiltDir = self.scratch_file('prebuilt')
249 os.mkdir(prebuiltDir, mode=0o775)
251 bits_zip_file = self.scratch_file('prebuilt',
252 'bits-%d-%s.zip'
253 %(self.BITS_INTERNAL_VER,
254 self.BITS_COMMIT_HASH))
255 grub_tar_file = self.scratch_file('prebuilt',
256 'bits-%d-%s-grub.tar.gz'
257 %(self.BITS_INTERNAL_VER,
258 self.BITS_COMMIT_HASH))
260 # extract the bits artifact in the temp working directory
261 self.archive_extract(self.ASSET_BITS, sub_dir='prebuilt', format='zip')
263 # extract the bits software in the temp working directory
264 self.archive_extract(bits_zip_file)
265 self.archive_extract(grub_tar_file)
267 self.copy_test_scripts()
268 self.copy_bits_config()
269 self.generate_bits_iso()
271 def parse_log(self): argument
275 debugconf = self.scratch_file(self._debugcon_log)
277 with open(debugconf, 'r', encoding='utf-8') as filehandle:
285 self.assertEqual(match.group(3).split()[0], '0',
289 self._print_log(log)
293 self._print_log(log)
295 def tearDown(self): argument
299 if self._vm:
300 self.assertFalse(not self._vm.is_running)
303 def test_acpi_smbios_bits(self): argument
306 self.set_machine('pc')
307 iso_file = self.scratch_file('bits-%d.iso' % self.BITS_INTERNAL_VER)
309 self.assertTrue(os.access(iso_file, os.R_OK))
311 self._vm = QEMUBitsMachine(binary=self.qemu_bin,
312 base_temp_dir=self.workdir,
313 debugcon_log=self._debugcon_log,
314 debugcon_addr=self._debugcon_addr)
316 self._vm.add_args('-cdrom', '%s' %iso_file)
320 self._vm.add_args('-icount', 'auto')
321 # currently there is no support in bits for recognizing 64-bit SMBIOS
322 # entry points. QEMU defaults to 64-bit entry points since the
324 # for newer machine models"). Therefore, enforce 32-bit entry point.
325 self._vm.add_args('-machine', 'smbios-entry-point-type=32')
328 self._vm.set_console()
329 self._vm.launch()
333 # in batch mode and then automatically initiate a vm shutdown.
334 self._vm.event_wait('SHUTDOWN', timeout=BITS_TIMEOUT)
335 self._vm.wait(timeout=None)
336 self.logger.debug("Checking console output ...")
337 self.parse_log()