All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Cleber Rosa <crosa@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Caio Carrara <ccarrara@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Laszlo Ersek" <lersek@redhat.com>
Subject: [Qemu-devel] [RFC PATCH v2 1/3] acceptance tests: Add SeaBIOS boot and debug console checking test
Date: Wed,  3 Oct 2018 20:30:34 +0200	[thread overview]
Message-ID: <20181003183036.6716-2-philmd@redhat.com> (raw)
In-Reply-To: <20181003183036.6716-1-philmd@redhat.com>

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é <philmd@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é <philmd@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

  reply	other threads:[~2018-10-03 18:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 18:30 [Qemu-devel] [RFC PATCH v2 0/3] acceptance tests: Test firmware checking debug console output Philippe Mathieu-Daudé
2018-10-03 18:30 ` Philippe Mathieu-Daudé [this message]
2018-10-03 18:30 ` [Qemu-devel] [RFC PATCH v2 2/3] acceptance tests: Add EDK2 OVMF boot and debug console checking test Philippe Mathieu-Daudé
2018-10-03 18:30 ` [Qemu-devel] [RFC PATCH v2 3/3] acceptance tests: Add EDK2 ArmVirtQemu boot and " Philippe Mathieu-Daudé
2018-10-04 15:07   ` Laszlo Ersek
2018-10-04 15:15     ` Philippe Mathieu-Daudé
2018-10-04 16:19       ` Laszlo Ersek
2018-10-04 12:58 ` [Qemu-devel] [RFC PATCH v2 0/3] acceptance tests: Test firmware checking debug console output Alex Bennée
2018-10-04 13:04   ` Alex Bennée
2018-10-04 13:09     ` Peter Maydell
2018-10-04 14:42       ` Cleber Rosa
2018-10-04 14:44     ` Philippe Mathieu-Daudé
2018-10-04 14:40   ` Cleber Rosa
2018-10-04 15:29     ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181003183036.6716-2-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=ccarrara@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.