Lines Matching +full:self +full:- +full:working
23 # pylint: disable=invalid-name
24 # pylint: disable=consider-using-f-string
31 https://gitlab.com/qemu-project/biosbits-bits .
85 class QEMUBitsMachine(QEMUMachine): # pylint: disable=too-few-public-methods
87 A QEMU VM, with isa-debugcon enabled and bits iso passed
88 using -cdrom to QEMU commandline.
91 def __init__(self, argument
97 debugcon_log: str = "debugcon-log.txt",
100 # pylint: disable=too-many-arguments
103 name = "qemu-bits-%d" % os.getpid()
107 self.debugcon_log = debugcon_log
108 self.debugcon_addr = debugcon_addr
109 self.base_temp_dir = base_temp_dir
112 def _base_args(self) -> List[str]: argument
115 '-chardev',
116 'file,path=%s,id=debugcon' %os.path.join(self.base_temp_dir,
117 self.debugcon_log),
118 '-device',
119 'isa-debugcon,iobase=%s,chardev=debugcon' %self.debugcon_addr,
123 def base_args(self): argument
125 return self._base_args
130 class AcpiBitsTest(QemuSystemTest): #pylint: disable=too-many-instance-attributes
143 BITS_TAG = "qemu-bits-10262023"
145 ASSET_BITS = Asset(("https://gitlab.com/qemu-project/"
146 "biosbits-bits/-/jobs/artifacts/%s/"
147 "download?job=qemu-bits-build" % BITS_TAG),
150 def __init__(self, *args, **kwargs): argument
152 self._vm = None
153 self._baseDir = None
155 self._debugcon_addr = '0x403'
156 self._debugcon_log = 'debugcon-log.txt'
157 self.logger = self.log
159 def _print_log(self, log): argument
160 self.logger.info('\nlogs from biosbits follows:')
161 self.logger.info('==========================================\n')
162 self.logger.info(log)
163 self.logger.info('==========================================\n')
165 def copy_bits_config(self): argument
168 config_file = 'bits-cfg.txt'
169 bits_config_dir = os.path.join(self._baseDir, 'acpi-bits',
170 'bits-config')
171 target_config_dir = os.path.join(self.workdir,
172 'bits-%d' %self.BITS_INTERNAL_VER,
174 self.assertTrue(os.path.exists(bits_config_dir))
175 self.assertTrue(os.path.exists(target_config_dir))
176 self.assertTrue(os.access(os.path.join(bits_config_dir,
180 self.logger.info('copied config file %s to %s',
183 def copy_test_scripts(self): argument
186 bits_test_dir = os.path.join(self._baseDir, 'acpi-bits',
187 'bits-tests')
188 target_test_dir = os.path.join(self.workdir,
189 'bits-%d' %self.BITS_INTERNAL_VER,
192 self.assertTrue(os.path.exists(bits_test_dir))
193 self.assertTrue(os.path.exists(target_test_dir))
207 self.logger.info('copied test file %s to %s',
216 self.logger.info('removed compiled file %s',
220 def fix_mkrescue(self, mkrescue): argument
221 """ grub-mkrescue is a bash script with two variables, 'prefix' and
224 the directory where we have extracted our pre-built bits grub
227 grub_x86_64_mods = os.path.join(self.workdir, 'grub-inst-x86_64-efi')
228 grub_i386_mods = os.path.join(self.workdir, 'grub-inst')
230 self.assertTrue(os.path.exists(grub_x86_64_mods))
231 self.assertTrue(os.path.exists(grub_i386_mods))
234 with open(mkrescue, 'r', encoding='utf-8') as filehandle:
242 with open(mkrescue, 'w', encoding='utf-8') as filehandle:
245 def generate_bits_iso(self): argument
246 """ Uses grub-mkrescue to generate a fresh bits iso with the python
249 bits_dir = os.path.join(self.workdir,
250 'bits-%d' %self.BITS_INTERNAL_VER)
251 iso_file = os.path.join(self.workdir,
252 'bits-%d.iso' %self.BITS_INTERNAL_VER)
253 mkrescue_script = os.path.join(self.workdir,
254 'grub-inst-x86_64-efi', 'bin',
255 'grub-mkrescue')
257 self.assertTrue(os.access(mkrescue_script,
260 self.fix_mkrescue(mkrescue_script)
262 self.logger.info('using grub-mkrescue for generating biosbits iso ...')
266 proc = subprocess.run([mkrescue_script, '-o', iso_file,
271 self.logger.info("grub-mkrescue output %s" % proc.stdout)
273 subprocess.check_call([mkrescue_script, '-o',
277 except Exception as e: # pylint: disable=broad-except
278 self.skipTest("Error while generating the bits iso. "
282 self.assertTrue(os.access(iso_file, os.R_OK))
284 self.logger.info('iso file %s successfully generated.', iso_file)
286 def setUp(self): # pylint: disable=arguments-differ argument
288 self.logger = self.log
290 self._baseDir = Path(__file__).parent
292 prebuiltDir = os.path.join(self.workdir, 'prebuilt')
296 bits_zip_file = os.path.join(prebuiltDir, 'bits-%d-%s.zip'
297 %(self.BITS_INTERNAL_VER,
298 self.BITS_COMMIT_HASH))
300 'bits-%d-%s-grub.tar.gz'
301 %(self.BITS_INTERNAL_VER,
302 self.BITS_COMMIT_HASH))
304 bitsLocalArtLoc = self.ASSET_BITS.fetch()
305 self.logger.info("downloaded bits artifacts to %s", bitsLocalArtLoc)
307 # extract the bits artifact in the temp working directory
311 # extract the bits software in the temp working directory
313 zref.extractall(self.workdir)
315 with tarfile.open(grub_tar_file, 'r', encoding='utf-8') as tarball:
316 tarball.extractall(self.workdir)
318 self.copy_test_scripts()
319 self.copy_bits_config()
320 self.generate_bits_iso()
322 def parse_log(self): argument
326 debugconf = os.path.join(self.workdir, self._debugcon_log)
328 with open(debugconf, 'r', encoding='utf-8') as filehandle:
336 self.assertEqual(match.group(3).split()[0], '0',
340 self._print_log(log)
344 self._print_log(log)
346 def tearDown(self): argument
350 if self._vm:
351 self.assertFalse(not self._vm.is_running)
354 def test_acpi_smbios_bits(self): argument
357 self.set_machine('pc')
358 iso_file = os.path.join(self.workdir,
359 'bits-%d.iso' %self.BITS_INTERNAL_VER)
361 self.assertTrue(os.access(iso_file, os.R_OK))
363 self._vm = QEMUBitsMachine(binary=self.qemu_bin,
364 base_temp_dir=self.workdir,
365 debugcon_log=self._debugcon_log,
366 debugcon_addr=self._debugcon_addr)
368 self._vm.add_args('-cdrom', '%s' %iso_file)
372 self._vm.add_args('-icount', 'auto')
373 # currently there is no support in bits for recognizing 64-bit SMBIOS
374 # entry points. QEMU defaults to 64-bit entry points since the
376 # for newer machine models"). Therefore, enforce 32-bit entry point.
377 self._vm.add_args('-machine', 'smbios-entry-point-type=32')
380 self._vm.set_console()
381 self._vm.launch()
386 self._vm.event_wait('SHUTDOWN', timeout=BITS_TIMEOUT)
387 self._vm.wait(timeout=None)
388 self.logger.debug("Checking console output ...")
389 self.parse_log()