This test boots SeaBIOS and check the debug console (I/O port on the ISA bus) reports enough information on the initialized devices.
Example: $ avocado run tests/acceptance/boot_firmware.py JOB ID : 3dac2e738c941747ec01f043092b882a8370a92f JOB LOG : /home/phil/avocado/job-results/job-2018-10-03T19.42-3dac2e7/job.log (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_seabios: PASS (0.27 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 0.56 s Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> --- tests/acceptance/boot_firmware.py | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/acceptance/boot_firmware.py diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py new file mode 100644 index 0000000000..669e4849f6 --- /dev/null +++ b/tests/acceptance/boot_firmware.py @@ -0,0 +1,74 @@ +# coding=utf-8 +# +# Functional test that boots SeaBIOS and checks the console +# +# Copyright (c) 2018 Red Hat, Inc. +# +# Author: +# Philippe Mathieu-Daudé <phi...@redhat.com> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import logging + +from avocado_qemu import Test +from avocado.utils.wait import wait_for + + +def read_console_for_string(console, expected_string, logger, ignore_ansi=True): + msg = console.readline() + if len(msg) == 0: + return False + if logger: + logger.debug(msg.strip() if ignore_ansi and not '\x1b' in msg else msg) + return expected_string in msg + + +class BootFirmware(Test): + """ + Boots a firmware and checks via a console it is operational + + :avocado: enable + """ + + def test_seabios(self): + """ + Boots SeaBIOS on a default PC machine, checks the debug console + + :avocado: tags=arch:x86_64 + :avocado: tags=maxtime:5s + :avocado: tags=quick + """ + debugcon_path = os.path.join(self.workdir, 'debugconsole.log') + serial_logger = logging.getLogger('serial') + debugcon_logger = logging.getLogger('debugcon') + + self.vm.set_machine('pc') + self.vm.set_console() + self.vm.add_args('-nographic', + '-net', 'none', + '-global', 'isa-debugcon.iobase=0x402', + '-debugcon', 'file:%s' % debugcon_path) + self.vm.launch() + console = self.vm.console_socket.makefile() + + # serial console checks + if not wait_for(read_console_for_string, timeout=5, step=0, + args=(console, 'No bootable device.', serial_logger)): + self.fail("SeaBIOS failed to boot") + + # debug console checks + expected = [ + 'Running on QEMU (i440fx)', + 'Turning on vga text mode console', + 'Found 1 lpt ports', + 'Found 1 serial ports', + 'PS2 keyboard initialized', + ] + with open(debugcon_path) as debugcon: + content = debugcon.readlines() + for line in content: # TODO use FDDrainer + debugcon_logger.debug(line.strip()) + for exp in expected: + self.assertIn(exp + '\n', content) -- 2.17.1