From patchwork Fri Sep 28 00:30:56 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: 10618793 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 CDDDE14BD for ; Fri, 28 Sep 2018 00:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C318D2AF47 for ; Fri, 28 Sep 2018 00:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B73322B2BE; Fri, 28 Sep 2018 00:33:05 +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 CEEBD2AF47 for ; Fri, 28 Sep 2018 00:33:03 +0000 (UTC) Received: from localhost ([::1]:40444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5giM-0005SI-B0 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 20:33:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5gh2-0003j7-26 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5ggy-0008F6-Aw for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57336) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5ggw-0008Cs-GF for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:35 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D97868830F for ; Fri, 28 Sep 2018 00:31:33 +0000 (UTC) Received: from x1w.redhat.com (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A17F3091375; Fri, 28 Sep 2018 00:31:31 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Fri, 28 Sep 2018 01:30:56 +0100 Message-Id: <20180928003058.12786-2-philmd@redhat.com> In-Reply-To: <20180928003058.12786-1-philmd@redhat.com> References: <20180928003058.12786-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 28 Sep 2018 00:31:33 +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 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 --show=debugcon run tests/acceptance/boot_firmware.py Signed-off-by: Philippe Mathieu-Daudé --- - can we avoid the time.time() 2nd timeout check? - can we avoid tempfile.mkdtemp() + shutil.rmtree() with Python2? (using context manager) --- tests/acceptance/boot_firmware.py | 72 +++++++++++++++++++++++++++++++ 1 file changed, 72 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..a41e04936d --- /dev/null +++ b/tests/acceptance/boot_firmware.py @@ -0,0 +1,72 @@ +# 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 time +import shutil +import logging +import tempfile + +from avocado_qemu import Test + + +class BootFirmwareX86(Test): + """ + Boots a firmware on a default PC machine and checks the debug console is + operational + + :avocado: enable + :avocado: tags=x86_64,quick + """ + + timeout = 15 + + def test_seabios(self): + tmpdirname = tempfile.mkdtemp() + debugcon_path = os.path.join(tmpdirname, '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 + timeout = time.time() + 5 + while True: + msg = console.readline() + if not '\x1b' in msg: # ignore ANSI sequences + serial_logger.debug(msg.strip()) + if 'No bootable device.' in msg: + break + if time.time() > timeout: + 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', + ] + lines = open(debugcon_path).readlines() + for msg in lines: + debugcon_logger.debug(msg.strip()) + for line in expected: + if line + '\n' not in lines: + self.fail('missing: %s' % line) + shutil.rmtree(tmpdirname, ignore_errors=True) From patchwork Fri Sep 28 00:30:57 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: 10618797 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 C578F14BD for ; Fri, 28 Sep 2018 00:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B29952B34E for ; Fri, 28 Sep 2018 00:35:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F81D2B36A; Fri, 28 Sep 2018 00:35:02 +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 2DBBB2B34E for ; Fri, 28 Sep 2018 00:35:02 +0000 (UTC) Received: from localhost ([::1]:40453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5gkH-0006mn-Ew for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 20:35:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5gh2-0003j9-3U for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5gh0-0008H1-6Y for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5ggz-0008FR-5S for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:37 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8356188E51 for ; Fri, 28 Sep 2018 00:31:36 +0000 (UTC) Received: from x1w.redhat.com (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50DC03091375; Fri, 28 Sep 2018 00:31:34 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Fri, 28 Sep 2018 01:30:57 +0100 Message-Id: <20180928003058.12786-3-philmd@redhat.com> In-Reply-To: <20180928003058.12786-1-philmd@redhat.com> References: <20180928003058.12786-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 28 Sep 2018 00:31:36 +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 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. Example: $ avocado --show=QMP,serial run tests/acceptance/boot_firmware.py Signed-off-by: Philippe Mathieu-Daudé --- - how to refactor common code from test_seabios() (previous patch)? --- tests/acceptance/boot_firmware.py | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py index a41e04936d..05f6728212 100644 --- a/tests/acceptance/boot_firmware.py +++ b/tests/acceptance/boot_firmware.py @@ -70,3 +70,55 @@ class BootFirmwareX86(Test): if line + '\n' not in lines: self.fail('missing: %s' % line) shutil.rmtree(tmpdirname, ignore_errors=True) + + def test_ovmf(self): + tmpdirname = tempfile.mkdtemp() + debugcon_path = os.path.join(tmpdirname, '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 + timeout = time.time() + 15 + while True: + msg = console.readline() + if not '\x1b' in msg: # ignore ANSI sequences + serial_logger.debug(msg.strip()) + if 'EDK II' in msg: + break + if time.time() > timeout: + 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', + 'DetectSmbiosVersion: SMBIOS version from QEMU: 0x0208', + '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', + ] + lines = open(debugcon_path).readlines() + for msg in lines: + debugcon_logger.debug(msg.strip()) + for line in expected: + if line + '\r\n' not in lines: + self.fail('missing: %s' % line) + shutil.rmtree(tmpdirname, ignore_errors=True) From patchwork Fri Sep 28 00:30:58 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: 10618795 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 7AE0C16B1 for ; Fri, 28 Sep 2018 00:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E98D2AF47 for ; Fri, 28 Sep 2018 00:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 608F92B2BE; Fri, 28 Sep 2018 00:33:11 +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 023B92AF47 for ; Fri, 28 Sep 2018 00:33:11 +0000 (UTC) Received: from localhost ([::1]:40447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5giU-0005fh-By for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Sep 2018 20:33:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5gh5-0003lC-Vo for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5gh4-0008KY-0I for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5gh2-0008IE-31 for qemu-devel@nongnu.org; Thu, 27 Sep 2018 20:31:40 -0400 Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62BD9308624E; Fri, 28 Sep 2018 00:31:39 +0000 (UTC) Received: from x1w.redhat.com (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F289C3091375; Fri, 28 Sep 2018 00:31:36 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Cleber Rosa , Eduardo Habkost , Caio Carrara Date: Fri, 28 Sep 2018 01:30:58 +0100 Message-Id: <20180928003058.12786-4-philmd@redhat.com> In-Reply-To: <20180928003058.12786-1-philmd@redhat.com> References: <20180928003058.12786-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 28 Sep 2018 00:31:39 +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 3/3] acceptance tests: Add EDK2 AAVMF 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 AAVMF and check the debug console (PL011) reports enough information on the initialized devices. Example: $ avocado --show=console run tests/acceptance/boot_firmware.py --cit-parameter-file aarch64.cit having aarch64.cit: [parameters] qemu_bin: aarch64-softmmu/qemu-system-aarch64 Signed-off-by: Philippe Mathieu-Daudé --- - requires (even for single parameter): $ pip install avocado-framework-plugin-varianter-cit - use gzip kludge (avocado only support tarballs) - can not set $arch param since pick_default_qemu_bin() forces to host os.uname()[4] --- tests/acceptance/boot_firmware.py | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/acceptance/boot_firmware.py b/tests/acceptance/boot_firmware.py index 05f6728212..4f5554c0ad 100644 --- a/tests/acceptance/boot_firmware.py +++ b/tests/acceptance/boot_firmware.py @@ -10,6 +10,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later import os +import gzip import time import shutil import logging @@ -122,3 +123,45 @@ class BootFirmwareX86(Test): if line + '\r\n' not in lines: self.fail('missing: %s' % line) shutil.rmtree(tmpdirname, ignore_errors=True) + + +class BootFirmwareAarch64(Test): + """ + Boots the EDK2 firmware on a default virt machine and checks the console is + operational + + :avocado: enable + :avocado: tags=arch:aarch64 + :avocado: tags=aarch64,quick + """ + + timeout = 15 + + def test_aavmf(self): + tmpdirname = tempfile.mkdtemp() + 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(tmpdirname, 'flash.img') + with gzip.open(image_path_gz) as gz, open(image_path, 'wb') as img: + shutil.copyfileobj(gz, img) + + self.vm.set_machine('virt') + self.vm.set_console() + self.vm.add_args('-nographic', + '-cpu', 'cortex-a57', + '-m', '1G', + '-pflash', image_path) + self.vm.launch() + console = self.vm.console_socket.makefile() + serial_logger = logging.getLogger('serial') + + # serial console checks + while True: + msg = console.readline() + if not '\x1b' in msg: # ignore ANSI sequences + serial_logger.debug(msg.strip()) + if 'Start PXE over IPv4InstallProtocolInterface:' in msg: + break + shutil.rmtree(tmpdirname, ignore_errors=True)