aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-10-30 11:13:16 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-10-30 11:13:16 +0000
commit62a23835b7c9019ae502915d5990e150349d5114 (patch)
tree9114ec26a352c53503f487d02d2d779529e38487 /tests
parent844178e7b327690068baeb45d413bc84d797db6b (diff)
parentefdb45bfd72745038909dfd1e970a827cb8d5d7e (diff)
Merge remote-tracking branch 'remotes/cleber/tags/python-next-pull-request' into staging
Python (acceptance tests) queue, 2019-10-28 # gpg: Signature made Mon 28 Oct 2019 23:43:11 GMT # gpg: using RSA key 7ABB96EB8B46B94D5E0FE9BB657E8D33A5F209F3 # gpg: Good signature from "Cleber Rosa <crosa@redhat.com>" [marginal] # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 7ABB 96EB 8B46 B94D 5E0F E9BB 657E 8D33 A5F2 09F3 * remotes/cleber/tags/python-next-pull-request: tests/boot_linux_console: Run BusyBox on 5KEc 64-bit cpu tests/boot_linux_console: Add initrd test for the Exynos4210 tests/boot_linux_console: Add a test for the Raspberry Pi 2 tests/boot_linux_console: Use Avocado archive::gzip_uncompress() .travis.yml: Let the avocado job run the 40p tests tests/acceptance: Test OpenBIOS on the PReP/40p tests/acceptance: Add test that runs NetBSD 4.0 installer on PRep/40p .travis.yml: Let the avocado job run the Leon3 test tests/acceptance: Add test that boots the HelenOS microkernel on Leon3 tests/acceptance: Refactor exec_command_and_wait_for_pattern() tests/acceptance: Send <carriage return> on serial lines tests/acceptance: Fix wait_for_console_pattern() hangs Acceptance tests: refactor wait_for_console_pattern Python libs: close console sockets before shutting down the VMs Acceptance tests: work around socket dir MAINTAINERS: update location of Python libraries Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/acceptance/avocado_qemu/__init__.py48
-rw-r--r--tests/acceptance/boot_linux_console.py167
-rw-r--r--tests/acceptance/linux_ssh_mips_malta.py18
-rw-r--r--tests/acceptance/machine_sparc_leon3.py34
-rw-r--r--tests/acceptance/ppc_prep_40p.py82
5 files changed, 297 insertions, 52 deletions
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index bd41e0443c..9a57c020d8 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -8,9 +8,11 @@
# 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
+import tempfile
import avocado
@@ -53,6 +55,50 @@ 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:
+ console.close()
+ fail = 'Failure message found in console: %s' % failure_message
+ 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 = {}
@@ -69,7 +115,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
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index df27813c78..4e9ac0ecc3 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -9,12 +9,14 @@
# later. See the COPYING file in the top-level directory.
import os
-import logging
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
from avocado.utils import process
from avocado.utils import archive
@@ -29,31 +31,9 @@ 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 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)
+ def wait_for_console_pattern(self, success_message):
+ wait_for_console_pattern(self, success_message,
+ failure_message='Kernel panic - not syncing')
def extract_from_deb(self, deb, path):
"""
@@ -166,10 +146,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()
@@ -183,12 +160,53 @@ 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')
+
+ @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)
@@ -316,6 +334,83 @@ 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_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
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)
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é <f4bug@amsat.org>
+#
+# 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 ...')
diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py
new file mode 100644
index 0000000000..6f507fb0a6
--- /dev/null
+++ b/tests/acceptance/ppc_prep_40p.py
@@ -0,0 +1,82 @@
+# Functional test that boots a PReP/40p machine and checks its serial console.
+#
+# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org>
+#
+# 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')
+
+ 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')