From patchwork Wed Oct 3 18:30:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10625181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D20C5112B for ; Wed, 3 Oct 2018 18:43:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C287628E9F for ; Wed, 3 Oct 2018 18:43:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B724D28FC1; Wed, 3 Oct 2018 18:43:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54E4128E9F for ; Wed, 3 Oct 2018 18:43:47 +0000 (UTC) Received: from localhost ([::1]:52022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m7e-0003s7-13 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Oct 2018 14:43:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m15-0006Zm-UU for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:37:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lvU-0000q7-2B for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7lvM-0000lp-LU for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B171583F3D for ; Wed, 3 Oct 2018 18:31:01 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-135.brq.redhat.com [10.40.204.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 581C667158; Wed, 3 Oct 2018 18:30:57 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Wed, 3 Oct 2018 20:30:34 +0200 Message-Id: <20181003183036.6716-2-philmd@redhat.com> In-Reply-To: <20181003183036.6716-1-philmd@redhat.com> References: <20181003183036.6716-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 03 Oct 2018 18:31:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH v2 1/3] acceptance tests: Add SeaBIOS boot and debug console checking test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Laszlo Ersek , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- 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é +# +# 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) From patchwork Wed Oct 3 18:30:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10625175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C40BA112B for ; Wed, 3 Oct 2018 18:38:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56CF28FDC for ; Wed, 3 Oct 2018 18:38:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A945F28FE9; Wed, 3 Oct 2018 18:38:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3ED5028FDC for ; Wed, 3 Oct 2018 18:38:51 +0000 (UTC) Received: from localhost ([::1]:51861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m2s-0008TU-Ga for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Oct 2018 14:38:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m12-0006eL-7q for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:36:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lvg-0000tx-4b for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48902) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7lve-0000mU-7K for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B53E85550 for ; Wed, 3 Oct 2018 18:31:04 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-135.brq.redhat.com [10.40.204.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2FA4667163; Wed, 3 Oct 2018 18:31:01 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Wed, 3 Oct 2018 20:30:35 +0200 Message-Id: <20181003183036.6716-3-philmd@redhat.com> In-Reply-To: <20181003183036.6716-1-philmd@redhat.com> References: <20181003183036.6716-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 03 Oct 2018 18:31:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH v2 2/3] acceptance tests: Add EDK2 OVMF boot and debug console checking test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Laszlo Ersek Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This test boots OVMF and check the debug console (I/O port on the ISA bus) report enough information on the initialized devices. $ avocado --show=app,debugcon run tests/acceptance/boot_firmware.py (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_pc: debugcon: SecCoreStartupWithStack(0xFFFCC000, 0x820000) debugcon: SEC: Normal boot ... debugcon: [Bds]Booting EFI Internal Shell PASS (5.27 s) JOB TIME : 5.60 s Signed-off-by: Philippe Mathieu-Daudé --- tests/acceptance/boot_firmware.py | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py index 669e4849f6..2053b1a4b6 100644 --- a/tests/acceptance/boot_firmware.py +++ b/tests/acceptance/boot_firmware.py @@ -72,3 +72,52 @@ class BootFirmware(Test): debugcon_logger.debug(line.strip()) for exp in expected: self.assertIn(exp + '\n', content) + + def test_ovmf_pc(self): + """ + Boots OVMF on the default PC machine, checks the debug console + + :avocado: tags=arch:x86_64 + :avocado: tags=maxtime:10s + """ + 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, + '--bios', '/usr/share/OVMF/OVMF_CODE.fd') + self.vm.launch() + console = self.vm.console_socket.makefile() + + # serial console checks + if not wait_for(read_console_for_string, timeout=10, step=0, + args=(console, 'EDK II', serial_logger)): + self.fail("OVMF failed to boot") + + # debug console checks + expected = [ + 'SEC: Normal boot', + 'S3 support was detected on QEMU', + 'Platform PEI Firmware Volume Initialization', + 'DXE IPL Entry', + 'Installing FVB for EMU Variable support', + 'SmbiosCreateTable: Initialize 32-bit entry point structure', + 'PlatformBootManagerBeforeConsole', + 'OnRootBridgesConnected: root bridges have been connected, ' + 'installing ACPI tables', + 'Found LPC Bridge device', + 'PlatformBootManagerAfterConsole', + 'EfiBootManagerConnectAll', + '[Bds]Booting EFI Internal Shell', + ] + 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 + '\r\n', content) From patchwork Wed Oct 3 18:30:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10625177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D92A13BB for ; Wed, 3 Oct 2018 18:41:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E1DB28FDC for ; Wed, 3 Oct 2018 18:41:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30BA228FE9; Wed, 3 Oct 2018 18:41:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C80B728FDC for ; Wed, 3 Oct 2018 18:41:40 +0000 (UTC) Received: from localhost ([::1]:51951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m5c-0002Ao-6h for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Oct 2018 14:41:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7m12-0006nB-Qm for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:36:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7lve-0000tE-63 for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59112) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g7lvc-0000rH-7L for qemu-devel@nongnu.org; Wed, 03 Oct 2018 14:31:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C579308FBA4; Wed, 3 Oct 2018 18:31:15 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-135.brq.redhat.com [10.40.204.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C4DF67158; Wed, 3 Oct 2018 18:31:04 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Wed, 3 Oct 2018 20:30:36 +0200 Message-Id: <20181003183036.6716-4-philmd@redhat.com> In-Reply-To: <20181003183036.6716-1-philmd@redhat.com> References: <20181003183036.6716-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 03 Oct 2018 18:31:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH v2 3/3] acceptance tests: Add EDK2 ArmVirtQemu boot and console checking test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , qemu-devel@nongnu.org, Laszlo Ersek , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This test boots EDK2 ArmVirtQemu and check the debug console (PL011) reports enough information on the initialized devices. $ avocado run -p qemu_bin=aarch64-softmmu/qemu-system-aarch64 tests/acceptance/boot_firmware.py JOB ID : cb1c5bd9e0312483eabeffbb37885a5273ef23bf JOB LOG : /home/phil/avocado/job-results/job-2018-10-03T19.39-cb1c5bd/job.log (1/1) tests/acceptance/boot_firmware.py:BootFirmware.test_ovmf_virt: PASS (5.02 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 5.30 s Signed-off-by: Philippe Mathieu-Daudé --- The '-p' option requires Avocado >= 65.0 --- tests/acceptance/boot_firmware.py | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py index 2053b1a4b6..42f0672963 100644 --- a/tests/acceptance/boot_firmware.py +++ b/tests/acceptance/boot_firmware.py @@ -121,3 +121,39 @@ class BootFirmware(Test): debugcon_logger.debug(line.strip()) for exp in expected: self.assertIn(exp + '\r\n', content) + + def test_ovmf_virt(self): + """ + Boots OVMF on the default virt machine, checks the debug console + + :avocado: tags=arch:aarch64 + :avocado: tags=maxtime:20s + """ + image_url = ('http://snapshots.linaro.org/components/kernel/' + 'leg-virt-tianocore-edk2-upstream/latest/' + 'QEMU-AARCH64/DEBUG_GCC5/QEMU_EFI.img.gz') + image_path_gz = self.fetch_asset(image_url) + image_path = os.path.join(self.workdir, 'flash.img') + + # kludge until Avocado support gzip files + import gzip, shutil + with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img: + shutil.copyfileobj(gz, img) + + serial_path = os.path.join(self.workdir, 'serial.log') + self.vm.set_machine('virt') + self.vm.add_args('-nographic', + '-cpu', 'cortex-a57', + '-m', '1G', # 1GB min to boot fw? + '-drive', 'file=%s,format=raw,if=pflash' % image_path, + '-chardev', 'file,path=%s,id=console' % serial_path, + '-serial', 'chardev:console') + self.vm.launch() + serial_logger = logging.getLogger('serial') + + # serial console checks + if not wait_for(read_console_for_string, timeout=15, step=0, + args=(open(serial_path), + 'Start PXE over IPv4', + serial_logger)): + self.fail("OVMF failed to boot")