From 1b6ee29f48994ad16bed7fcd80f56da688e0bc3a Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 01/16] MAINTAINERS: update location of Python libraries Commit 8f8fd9ed introduced the python directory structure, but forgot to update the path pattern on the MAINTAINERS file. Signed-off-by: Cleber Rosa --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 42e702f346..a0dd1041b2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2001,7 +2001,7 @@ Python scripts M: Eduardo Habkost M: Cleber Rosa S: Odd fixes -F: scripts/qmp/* +F: python/qemu/*py F: scripts/*.py F: tests/*.py From 5449d937cddf78a3c592e58228fd1c248edd0dad Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 02/16] Acceptance tests: work around socket dir Change 32558ce7a4 introduced specific directories for the socket dir when using python/qemu/machine.py:QEMUMachine. iotests probably didn't catch the condition that two simultaneous QEMUMachine instances, without manually set temporary or socket dirs would clash. Having two QEMUMachine instances is a condition expected for many acceptance tests, and it's already used by the migration tests. Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index bd41e0443c..711c29609a 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -11,6 +11,7 @@ import os import sys import uuid +import tempfile import avocado @@ -69,7 +70,7 @@ class Test(avocado.Test): self.cancel("No QEMU binary defined or found in the source tree") def _new_vm(self, *args): - vm = QEMUMachine(self.qemu_bin) + vm = QEMUMachine(self.qemu_bin, sock_dir=tempfile.mkdtemp()) if args: vm.add_args(*args) return vm From 085809670201c6d3a33e37dc753a23115ba8ceb3 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 03/16] Python libs: close console sockets before shutting down the VMs Currently, the console socket on QEMUMachine is closed after the QMP command to gracefully exit QEMU is executed. Because of a possible deadlock (QEMU waiting for the socket to become writable) let's close the console socket earlier. Reference: <20190607034214.GB22416@habkost.net> Reference: https://bugs.launchpad.net/qemu/+bug/1829779 From: Eduardo Habkost Signed-off-by: Cleber Rosa Message-Id: <20190911023558.4880-2-crosa@redhat.com> --- python/qemu/machine.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/qemu/machine.py b/python/qemu/machine.py index 2024e8b1b1..a4631d6934 100644 --- a/python/qemu/machine.py +++ b/python/qemu/machine.py @@ -277,10 +277,6 @@ class QEMUMachine(object): self._qemu_log_path = None - if self._console_socket is not None: - self._console_socket.close() - self._console_socket = None - if self._temp_dir is not None: shutil.rmtree(self._temp_dir) self._temp_dir = None @@ -342,6 +338,13 @@ class QEMUMachine(object): """ Terminate the VM and clean up """ + # If we keep the console socket open, we may deadlock waiting + # for QEMU to exit, while QEMU is waiting for the socket to + # become writeable. + if self._console_socket is not None: + self._console_socket.close() + self._console_socket = None + if self.is_running(): try: if not has_quit: From 77bcd2487e527334a65ca5f263ccfe62f57a7bd5 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 04/16] Acceptance tests: refactor wait_for_console_pattern MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The same utility method is already present in two different test files, so let's consolidate it into a single utility function. Signed-off-by: Cleber Rosa Message-Id: <20190916164011.7653-1-crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé [PMD: failure_message is optional] Reviewed-by: David Gibson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Aleksandar Markovic Message-Id: <20191028073441.6448-3-philmd@redhat.com> Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 25 +++++++++++++++++++++ tests/acceptance/boot_linux_console.py | 27 +++++------------------ tests/acceptance/linux_ssh_mips_malta.py | 18 +++------------ 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 711c29609a..772771e205 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -8,6 +8,7 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. +import logging import os import sys import uuid @@ -54,6 +55,30 @@ def pick_default_qemu_bin(arch=None): return qemu_bin_from_src_dir_path +def wait_for_console_pattern(test, success_message, failure_message=None): + """ + Waits for messages to appear on the console, while logging the content + + :param test: an Avocado test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`avocado_qemu.Test` + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + console = test.vm.console_socket.makefile() + console_logger = logging.getLogger('console') + while True: + msg = console.readline().strip() + if not msg: + continue + console_logger.debug(msg) + if success_message in msg: + break + if failure_message and failure_message in msg: + fail = 'Failure message found in console: %s' % failure_message + test.fail(fail) + + class Test(avocado.Test): def setUp(self): self._vms = {} diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 8a9a314ab4..8897e0c253 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -9,12 +9,12 @@ # later. See the COPYING file in the top-level directory. import os -import logging import lzma import gzip import shutil from avocado_qemu import Test +from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive @@ -29,31 +29,14 @@ class BootLinuxConsole(Test): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' - def wait_for_console_pattern(self, success_message, - failure_message='Kernel panic - not syncing'): - """ - Waits for messages to appear on the console, while logging the content - - :param success_message: if this message appears, test succeeds - :param failure_message: if this message appears, test fails - """ - console = self.vm.console_socket.makefile() - console_logger = logging.getLogger('console') - while True: - msg = console.readline().strip() - if not msg: - continue - console_logger.debug(msg) - if success_message in msg: - break - if failure_message in msg: - fail = 'Failure message found in console: %s' % failure_message - self.fail(fail) + def wait_for_console_pattern(self, success_message): + wait_for_console_pattern(self, success_message, + failure_message='Kernel panic - not syncing') def exec_command_and_wait_for_pattern(self, command, success_message): command += '\n' self.vm.console_socket.sendall(command.encode()) - self.wait_for_console_pattern(success_message) + wait_for_console_pattern(self, success_message) def extract_from_deb(self, deb, path): """ diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py index aa12001942..fc13f9e4d4 100644 --- a/tests/acceptance/linux_ssh_mips_malta.py +++ b/tests/acceptance/linux_ssh_mips_malta.py @@ -13,6 +13,7 @@ import time from avocado import skipUnless from avocado_qemu import Test +from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive from avocado.utils import ssh @@ -69,19 +70,6 @@ class LinuxSSH(Test): def setUp(self): super(LinuxSSH, self).setUp() - def wait_for_console_pattern(self, success_message, - failure_message='Oops'): - console = self.vm.console_socket.makefile() - console_logger = logging.getLogger('console') - while True: - msg = console.readline() - console_logger.debug(msg.strip()) - if success_message in msg: - break - if failure_message in msg: - fail = 'Failure message found in console: %s' % failure_message - self.fail(fail) - def get_portfwd(self): res = self.vm.command('human-monitor-command', command_line='info usernet') @@ -137,7 +125,7 @@ class LinuxSSH(Test): self.log.info('VM launched, waiting for sshd') console_pattern = 'Starting OpenBSD Secure Shell server: sshd' - self.wait_for_console_pattern(console_pattern) + wait_for_console_pattern(self, console_pattern, 'Oops') self.log.info('sshd ready') self.ssh_connect('root', 'root') @@ -145,7 +133,7 @@ class LinuxSSH(Test): def shutdown_via_ssh(self): self.ssh_command('poweroff') self.ssh_disconnect_vm() - self.wait_for_console_pattern('Power down') + wait_for_console_pattern(self, 'Power down', 'Oops') def ssh_command_output_contains(self, cmd, exp): stdout, _ = self.ssh_command(cmd) From ffc1fe7894f7704ed6af0746715099b098a61463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 05/16] tests/acceptance: Fix wait_for_console_pattern() hangs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because of a possible deadlock (QEMU waiting for the socket to become writable) let's close the console socket as soon as we stop to use it. Suggested-by: Cleber Rosa Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-4-philmd@redhat.com> Reviewed-by: Cleber Rosa Reviewed-by: Aleksandar Markovic [Cleber: corrected small typo in commit message] Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 772771e205..393fc33f35 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -75,6 +75,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None): if success_message in msg: break if failure_message and failure_message in msg: + console.close() fail = 'Failure message found in console: %s' % failure_message test.fail(fail) From 6b5720d5b7609d4c0feb8edd930242bb9968c13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 06/16] tests/acceptance: Send on serial lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some firmwares don't parse the control character and expect a . Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-5-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 8897e0c253..f9b77af359 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -34,7 +34,7 @@ class BootLinuxConsole(Test): failure_message='Kernel panic - not syncing') def exec_command_and_wait_for_pattern(self, command, success_message): - command += '\n' + command += '\r' self.vm.console_socket.sendall(command.encode()) wait_for_console_pattern(self, success_message) From 2b17d81ffb6d4dd00fa75b78280171eb5b73aa22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 07/16] tests/acceptance: Refactor exec_command_and_wait_for_pattern() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor the exec_command_and_wait_for_pattern() utility method so we can reuse it in other files. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-6-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 18 +++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 393fc33f35..9a57c020d8 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -80,6 +80,25 @@ def wait_for_console_pattern(test, success_message, failure_message=None): test.fail(fail) +def exec_command_and_wait_for_pattern(test, command, + success_message, failure_message=None): + """ + Send a command to a console (appending CRLF characters), then wait + for success_message to appear on the console, while logging the. + content. Mark the test as failed if failure_message is found instead. + + :param test: an Avocado test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`avocado_qemu.Test` + :param command: the command to send + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + command += '\r' + test.vm.console_socket.sendall(command.encode()) + wait_for_console_pattern(test, success_message, failure_message) + + class Test(avocado.Test): def setUp(self): self._vms = {} diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index f9b77af359..4b419b0559 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -14,6 +14,7 @@ import gzip import shutil from avocado_qemu import Test +from avocado_qemu import exec_command_and_wait_for_pattern from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive @@ -33,11 +34,6 @@ class BootLinuxConsole(Test): wait_for_console_pattern(self, success_message, failure_message='Kernel panic - not syncing') - def exec_command_and_wait_for_pattern(self, command, success_message): - command += '\r' - self.vm.console_socket.sendall(command.encode()) - wait_for_console_pattern(self, success_message) - def extract_from_deb(self, deb, path): """ Extracts a file from a deb package into the test workdir @@ -166,12 +162,12 @@ class BootLinuxConsole(Test): self.vm.launch() self.wait_for_console_pattern('Boot successful.') - self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', - 'BogoMIPS') - self.exec_command_and_wait_for_pattern('uname -a', - 'Debian') - self.exec_command_and_wait_for_pattern('reboot', - 'reboot: Restarting system') + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'BogoMIPS') + exec_command_and_wait_for_pattern(self, 'uname -a', + 'Debian') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash) From b11785ca23e7585ec8a80be422dc7c370ba26dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 08/16] tests/acceptance: Add test that boots the HelenOS microkernel on Leon3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Release notes: http://www.helenos.org/wiki/Download#HelenOS0.6.0 Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-11-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa [Cleber: added/removed needed/unneeded imports] Signed-off-by: Cleber Rosa --- MAINTAINERS | 1 + tests/acceptance/machine_sparc_leon3.py | 34 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/acceptance/machine_sparc_leon3.py diff --git a/MAINTAINERS b/MAINTAINERS index a0dd1041b2..afcd365550 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1173,6 +1173,7 @@ S: Maintained F: hw/sparc/leon3.c F: hw/*/grlib* F: include/hw/*/grlib* +F: tests/acceptance/machine_sparc_leon3.py S390 Machines ------------- diff --git a/tests/acceptance/machine_sparc_leon3.py b/tests/acceptance/machine_sparc_leon3.py new file mode 100644 index 0000000000..298f1e25e6 --- /dev/null +++ b/tests/acceptance/machine_sparc_leon3.py @@ -0,0 +1,34 @@ +# Functional test that boots a Leon3 machine and checks its serial console. +# +# Copyright (c) Philippe Mathieu-Daudé +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +from avocado_qemu import Test +from avocado_qemu import wait_for_console_pattern + + +class Leon3Machine(Test): + + timeout = 60 + + def test_leon3_helenos_uimage(self): + """ + :avocado: tags=arch:sparc + :avocado: tags=machine:leon3 + :avocado: tags=binfmt:uimage + """ + kernel_url = ('http://www.helenos.org/releases/' + 'HelenOS-0.6.0-sparc32-leon3.bin') + kernel_hash = 'a88c9cfdb8430c66650e5290a08765f9bf049a30' + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) + + self.vm.set_machine('leon3_generic') + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path) + + self.vm.launch() + + wait_for_console_pattern(self, 'Copyright (c) 2001-2014 HelenOS project') + wait_for_console_pattern(self, 'Booting the kernel ...') From 4dca8b74c022badc2c3d6f1f33a5a5bc39bb0589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 09/16] .travis.yml: Let the avocado job run the Leon3 test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-13-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ba3a8d4cfc..6ebd1af0d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -271,7 +271,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc64-softmmu,m68k-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log From 71b290e7012354b1d7609860e6433f127f2b8619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 10/16] tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of this commit, NetBSD 4.0 is very old. However it is enough to test the PRep/40p machine. User case from: http://mail-index.netbsd.org/port-prep/2017/04/11/msg000112.html Reviewed-by: Hervé Poussineau Acked-by: David Gibson Acked-by: Artyom Tarasenko Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-14-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa [Cleber: fixed file name and imports] Signed-off-by: Cleber Rosa --- MAINTAINERS | 1 + tests/acceptance/ppc_prep_40p.py | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/acceptance/ppc_prep_40p.py diff --git a/MAINTAINERS b/MAINTAINERS index afcd365550..eafc48ff9a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1068,6 +1068,7 @@ F: hw/rtc/m48t59-isa.c F: include/hw/isa/pc87312.h F: include/hw/rtc/m48t59.h F: pc-bios/ppc_rom.bin +F: tests/acceptance/ppc_prep_40p.py sPAPR M: David Gibson diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py new file mode 100644 index 0000000000..9d95e18fcb --- /dev/null +++ b/tests/acceptance/ppc_prep_40p.py @@ -0,0 +1,49 @@ +# Functional test that boots a PReP/40p machine and checks its serial console. +# +# Copyright (c) Philippe Mathieu-Daudé +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import os + +from avocado import skipIf +from avocado import skipUnless +from avocado_qemu import Test +from avocado_qemu import wait_for_console_pattern + + +class IbmPrep40pMachine(Test): + + timeout = 60 + + # 12H0455 PPS Firmware Licensed Materials + # Property of IBM (C) Copyright IBM Corp. 1994. + # All rights reserved. + # U.S. Government Users Restricted Rights - Use, duplication or disclosure + # restricted by GSA ADP Schedule Contract with IBM Corp. + @skipIf(os.getenv('CONTINUOUS_INTEGRATION'), 'Running on Travis-CI') + @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') + def test_factory_firmware_and_netbsd(self): + """ + :avocado: tags=arch:ppc + :avocado: tags=machine:40p + :avocado: tags=slowness:high + """ + bios_url = ('ftp://ftp.boulder.ibm.com/rs6000/firmware/' + '7020-40p/P12H0456.IMG') + bios_hash = '1775face4e6dc27f3a6ed955ef6eb331bf817f03' + bios_path = self.fetch_asset(bios_url, asset_hash=bios_hash) + drive_url = ('https://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/' + 'NetBSD-4.0/prep/installation/floppy/generic_com0.fs') + drive_hash = 'dbcfc09912e71bd5f0d82c7c1ee43082fb596ceb' + drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash) + + self.vm.set_machine('40p') + self.vm.set_console() + self.vm.add_args('-bios', bios_path, + '-fda', drive_path) + self.vm.launch() + os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007' + wait_for_console_pattern(self, os_banner) + wait_for_console_pattern(self, 'Model: IBM PPS Model 6015') From 1a9559e8f81ab3bb153b051e916eb495fe4a034a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 11/16] tests/acceptance: Test OpenBIOS on the PReP/40p MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User case from: https://mail.coreboot.org/pipermail/openbios/2018-May/010360.html Acked-by: David Gibson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-16-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa [Cleber: added skip conditional for Travis] Signed-off-by: Cleber Rosa --- tests/acceptance/ppc_prep_40p.py | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py index 9d95e18fcb..6f507fb0a6 100644 --- a/tests/acceptance/ppc_prep_40p.py +++ b/tests/acceptance/ppc_prep_40p.py @@ -47,3 +47,36 @@ class IbmPrep40pMachine(Test): os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007' wait_for_console_pattern(self, os_banner) wait_for_console_pattern(self, 'Model: IBM PPS Model 6015') + + def test_openbios_192m(self): + """ + :avocado: tags=arch:ppc + :avocado: tags=machine:40p + """ + self.vm.set_machine('40p') + self.vm.set_console() + self.vm.add_args('-m', '192') # test fw_cfg + + self.vm.launch() + wait_for_console_pattern(self, '>> OpenBIOS') + wait_for_console_pattern(self, '>> Memory: 192M') + wait_for_console_pattern(self, '>> CPU type PowerPC,604') + + @skipIf(os.getenv('CONTINUOUS_INTEGRATION'), 'Running on Travis-CI') + def test_openbios_and_netbsd(self): + """ + :avocado: tags=arch:ppc + :avocado: tags=machine:40p + """ + drive_url = ('https://ftp.netbsd.org/pub/NetBSD/iso/7.1.2/' + 'NetBSD-7.1.2-prep.iso') + drive_hash = 'ac6fa2707d888b36d6fa64de6e7fe48e' + drive_path = self.fetch_asset(drive_url, asset_hash=drive_hash, + algorithm='md5') + self.vm.set_machine('40p') + self.vm.set_console() + self.vm.add_args('-cdrom', drive_path, + '-boot', 'd') + + self.vm.launch() + wait_for_console_pattern(self, 'NetBSD/prep BOOT, Revision 1.9') From 83703220f5ddca303a4bc104aa505ca1773bf7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 12/16] .travis.yml: Let the avocado job run the 40p tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Alex Bennée Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-18-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ebd1af0d9..ef63fc16b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -271,7 +271,7 @@ matrix: # Acceptance (Functional) tests - env: - - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu" + - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu" - TEST_CMD="make check-acceptance" after_failure: - cat tests/results/latest/job.log From f2cd6cf64911bc367713d8c539a53354e6e3eee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 13/16] tests/boot_linux_console: Use Avocado archive::gzip_uncompress() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avocado 67.0 [*] introduced the avocado.utils.archive module which provides handling of gzip files. Use the gzip_uncompress() method. [*] https://avocado-framework.readthedocs.io/en/67.0/api/utils/avocado.utils.html#avocado.utils.archive.gzip_uncompress Suggested-by: Cleber Rosa Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-20-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 4b419b0559..67d7e96d98 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -145,10 +145,7 @@ class BootLinuxConsole(Test): initrd_hash = 'bf806e17009360a866bf537f6de66590de349a99' initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) initrd_path = self.workdir + "rootfs.cpio" - - with gzip.open(initrd_path_gz, 'rb') as f_in: - with open(initrd_path, 'wb') as f_out: - shutil.copyfileobj(f_in, f_out) + archive.gzip_uncompress(initrd_path_gz, initrd_path) self.vm.set_machine('malta') self.vm.set_console() From 92d9361255a0862379866f156686180902bb63d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 14/16] tests/boot_linux_console: Add a test for the Raspberry Pi 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to the x86_64/pc test, it boots a Linux kernel on a raspi2 board and verify the serial is working. The kernel image and DeviceTree blob are built by the Raspbian project (based on Debian): https://www.raspbian.org/RaspbianImages as recommended by the Raspberry Pi project: https://www.raspberrypi.org/downloads/raspbian/ If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags. Alternatively, this test can be run using: $ avocado run -t arch:arm tests/acceptance $ avocado run -t machine:raspi2 tests/acceptance Reviewed-by: Alex Bennée Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-21-philmd@redhat.com> Signed-off-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 67d7e96d98..a4fa31b411 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -292,6 +292,42 @@ class BootLinuxConsole(Test): self.vm.launch() self.wait_for_console_pattern('init started: BusyBox') + def do_test_arm_raspi2(self, uart_id): + """ + The kernel can be rebuilt using the kernel source referenced + and following the instructions on the on: + https://www.raspberrypi.org/documentation/linux/kernel/building.md + """ + serial_kernel_cmdline = { + 0: 'earlycon=pl011,0x3f201000 console=ttyAMA0', + } + deb_url = ('http://archive.raspberrypi.org/debian/' + 'pool/main/r/raspberrypi-firmware/' + 'raspberrypi-kernel_1.20190215-1_armhf.deb') + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') + + self.vm.set_machine('raspi2') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + serial_kernel_cmdline[uart_id]) + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-append', kernel_command_line) + self.vm.launch() + console_pattern = 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern) + + def test_arm_raspi2_uart0(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:raspi2 + :avocado: tags=device:pl011 + """ + self.do_test_arm_raspi2(0) + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x From 017aa60b253bcd0a5dd7e4e0b0c3d5c3c67154cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 15/16] tests/boot_linux_console: Add initrd test for the Exynos4210 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test boots a Linux kernel on a smdkc210 board and verify the serial output is working. The cpio image used comes from the linux-build-test project: https://github.com/groeck/linux-build-test If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags. This test can be run using: $ IGNORE_AVOCADO_CONSOLE_BUG=yes \ avocado --show=app,console run -t machine:smdkc210 \ tests/acceptance/boot_linux_console.py console: Booting Linux on physical CPU 0x900 console: Linux version 4.19.0-6-armmp (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) console: CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache console: OF: fdt: Machine model: Samsung smdkv310 evaluation board based on Exynos4210 [...] console: Samsung CPU ID: 0x43210211 console: random: get_random_bytes called from start_kernel+0xa0/0x504 with crng_init=0 console: percpu: Embedded 17 pages/cpu s39756 r8192 d21684 u69632 console: Built 1 zonelists, mobility grouping on. Total pages: 249152 console: Kernel command line: printk.time=0 console=ttySAC0,115200n8 earlyprintk random.trust_cpu=off cryptomgr.notests cpuidle.off=1 panic=-1 noreboot [...] console: L2C: platform modifies aux control register: 0x02020000 -> 0x3e420001 console: L2C: platform provided aux values permit register corruption. console: L2C: DT/platform modifies aux control register: 0x02020000 -> 0x3e420001 console: L2C-310 erratum 769419 enabled console: L2C-310 enabling early BRESP for Cortex-A9 console: L2C-310: enabling full line of zeros but not enabled in Cortex-A9 console: L2C-310 ID prefetch enabled, offset 1 lines console: L2C-310 dynamic clock gating disabled, standby mode disabled console: L2C-310 cache controller enabled, 8 ways, 128 kB console: L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x7e420001 console: Exynos4210 clocks: sclk_apll = 12000000, sclk_mpll = 12000000 console: sclk_epll = 12000000, sclk_vpll = 12000000, arm_clk = 12000000 [...] console: s3c-i2c 13860000.i2c: slave address 0x00 console: s3c-i2c 13860000.i2c: bus frequency set to 93 KHz console: s3c-i2c 13860000.i2c: i2c-0: S3C I2C adapter [...] console: dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-241330 console: dma-pl330 12680000.pdma: DBUFF-256x8bytes Num_Chans-8 Num_Peri-32 Num_Events-16 console: dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-241330 console: dma-pl330 12690000.pdma: DBUFF-256x8bytes Num_Chans-8 Num_Peri-32 Num_Events-16 console: dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-241330 console: dma-pl330 12850000.mdma: DBUFF-256x8bytes Num_Chans-8 Num_Peri-1 Num_Events-16 console: dma-pl330 12850000.mdma: PM domain LCD0 will not be powered off console: Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled console: Serial: AMBA driver console: 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 40, base_baud = 0) is a S3C6400/10 console: console [ttySAC0] enabled console: 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 41, base_baud = 0) is a S3C6400/10 console: 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 42, base_baud = 0) is a S3C6400/10 console: 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 43, base_baud = 0) is a S3C6400/10 [...] console: Freeing unused kernel memory: 2048K console: Run /init as init process console: mount: mounting devtmpfs on /dev failed: Device or resource busy console: Starting logging: OK console: Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read) console: done. console: Starting network: OK console: Found console ttySAC0 console: Linux version 4.19.0-6-armmp (debian-kernel@lists.debian.org) (gcc version 8.3.0 (Debian 8.3.0-6)) #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) console: Boot successful. PASS (37.98 s) Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-25-philmd@redhat.com> Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa [Cleber: removed conditional to skip test] Signed-off-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index a4fa31b411..dab21b37c4 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -328,6 +328,47 @@ class BootLinuxConsole(Test): """ self.do_test_arm_raspi2(0) + def test_arm_exynos4210_initrd(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:smdkc210 + """ + deb_url = ('https://snapshot.debian.org/archive/debian/' + '20190928T224601Z/pool/main/l/linux/' + 'linux-image-4.19.0-6-armmp_4.19.67-2+deb10u1_armhf.deb') + deb_hash = 'fa9df4a0d38936cb50084838f2cb933f570d7d82' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-4.19.0-6-armmp') + dtb_path = '/usr/lib/linux-image-4.19.0-6-armmp/exynos4210-smdkv310.dtb' + dtb_path = self.extract_from_deb(deb_path, dtb_path) + + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' + 'arm/rootfs-armv5.cpio.gz') + initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') + archive.gzip_uncompress(initrd_path_gz, initrd_path) + + self.vm.set_machine('smdkc210') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'earlycon=exynos4210,0x13800000 earlyprintk ' + + 'console=ttySAC0,115200n8 ' + + 'random.trust_cpu=off cryptomgr.notests ' + + 'cpuidle.off=1 panic=-1 noreboot') + + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + + self.wait_for_console_pattern('Boot successful.') + # TODO user command, for now the uart is stuck + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x From efdb45bfd72745038909dfd1e970a827cb8d5d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Mon, 28 Oct 2019 19:04:04 -0400 Subject: [PATCH 16/16] tests/boot_linux_console: Run BusyBox on 5KEc 64-bit cpu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This tests boots a Linux kernel on a Malta machine up to a busybox shell on the serial console. Few commands are executed before halting the machine (via reboot). We use the Fedora 24 kernel extracted from the image at: https://fedoraproject.org/wiki/Architectures/MIPS and the initrd cpio image from the kerneltests project: https://kerneltests.org/ If MIPS is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:mips" tags. Alternatively, this test can be run using: $ AVOCADO_ALLOW_UNTRUSTED_CODE=yes \ avocado --show=console run -t arch:mips64el \ tests/acceptance/boot_linux_console.py console: [ 0.000000] Linux version 3.19.3.mtoman.20150408 (mtoman@debian-co3-1) (gcc version 5.0.0 20150316 (Red Hat 5.0.0-0.20) (GCC) ) #3 Wed Apr 8 14:32:50 UTC 2015 console: [ 0.000000] Early serial console at I/O port 0x3f8 (options '38400n8') console: [ 0.000000] bootconsole [uart0] enabled console: [ 0.000000] CPU0 revision is: 00018900 (MIPS 5KE) console: [ 0.000000] Checking for the multiply/shift bug... no. console: [ 0.000000] Checking for the daddiu bug... no. [...] console: Boot successful. console: cat /proc/cpuinfo console: / # cat /proc/cpuinfo console: system type : MIPS Malta console: machine : Unknown console: processor : 0 console: cpu model : MIPS 5KE V0.0 console: : 1616.89 console: wait instruction : nouname -a console: microsecond timers : yes console: tlb_entries : 32 console: extra interrupt vector : yes console: hardware watchpoint : yes, count: 1, address/irw mask: [0x0ff8] console: isa : mips1 mips2 mips3 mips4 mips5 mips32r1 mips32r2 mips64r1 mips64r2 console: ASEs implemented : console: shadow register sets : 1 console: kscratch registers : 0 console: package : 0 console: core : 0 console: VCED exceptions : not available console: VCEI exceptions : not available console: / # console: / # uname -a console: Linux buildroot 3.19.3.mtoman.20150408 #3 Wed Apr 8 14:32:50 UTC 2015 mips64 GNU/Linux console: reboot console: / # console: / # reboot console: / # console: / # reboot: Restarting system PASS (7.04 s) JOB TIME : 7.20 s Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20191028073441.6448-27-philmd@redhat.com> Reviewed-by: Aleksandar Markovic Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Signed-off-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index dab21b37c4..9fd65e1ccf 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -13,6 +13,7 @@ import lzma import gzip import shutil +from avocado import skipUnless from avocado_qemu import Test from avocado_qemu import exec_command_and_wait_for_pattern from avocado_qemu import wait_for_console_pattern @@ -166,6 +167,47 @@ class BootLinuxConsole(Test): exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') + @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') + def test_mips64el_malta_5KEc_cpio(self): + """ + :avocado: tags=arch:mips64el + :avocado: tags=machine:malta + :avocado: tags=endian:little + """ + kernel_url = ('https://github.com/philmd/qemu-testing-blob/' + 'raw/9ad2df38/mips/malta/mips64el/' + 'vmlinux-3.19.3.mtoman.20150408') + kernel_hash = '00d1d268fb9f7d8beda1de6bebcc46e884d71754' + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) + initrd_url = ('https://github.com/groeck/linux-build-test/' + 'raw/8584a59e/rootfs/' + 'mipsel64/rootfs.mipsel64r1.cpio.gz') + initrd_hash = '1dbb8a396e916847325284dbe2151167' + initrd_path_gz = self.fetch_asset(initrd_url, algorithm='md5', + asset_hash=initrd_hash) + initrd_path = self.workdir + "rootfs.cpio" + archive.gzip_uncompress(initrd_path_gz, initrd_path) + + self.vm.set_machine('malta') + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0 console=tty ' + + 'rdinit=/sbin/init noreboot') + self.vm.add_args('-cpu', '5KEc', + '-kernel', kernel_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + wait_for_console_pattern(self, 'Boot successful.') + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'MIPS 5KE') + exec_command_and_wait_for_pattern(self, 'uname -a', + '3.19.3.mtoman.20150408') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') + def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): kernel_path_xz = self.fetch_asset(kernel_url, asset_hash=kernel_hash) kernel_path = self.workdir + "kernel"