aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-05-03 15:26:09 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-05-03 15:26:09 +0100
commita6ae23831b05a11880b40f7d58e332c45a6b04f7 (patch)
tree0a0d5fcfce8f01f9891b700d70cf239b7aabc04c /tests
parent5b396a8c36f490cbc93fa1aa91cea4a03b94de54 (diff)
parentfaf441429adfe5767be52c5dcdb8bc03161d064f (diff)
Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' into staging
Python queue, 2019-05-02 * configure: automatically pick python3 is available (Daniel P. Berrangé) * tests/acceptance (Cleber Rosa, Philippe Mathieu-Daudé): * Multi-architecture test support * Multiple arch-specific boot_linux_console test cases * Increase verbosity of avocado by default * docstring improvements # gpg: Signature made Fri 03 May 2019 01:40:06 BST # gpg: using RSA key 2807936F984DC5A6 # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/python-next-pull-request: configure: automatically pick python3 is available tests/boot_linux_console: add a test for alpha + clipper tests/boot_linux_console: add a test for s390x + s390-ccw-virtio tests/boot_linux_console: add a test for arm + virt tests/boot_linux_console: add a test for aarch64 + virt tests/boot_linux_console: add a test for mips64el + malta tests/boot_linux_console: add a test for mips + malta scripts/qemu.py: support adding a console with the default serial device tests/boot_linux_console: refactor the console watcher into utility method tests/boot_linux_console: increase timeout tests/boot_linux_console: add common kernel command line options tests/boot_linux_console: update the x86_64 kernel tests/boot_linux_console: rename the x86_64 after the arch and machine tests/acceptance: look for target architecture in test tags first tests/acceptance: use "arch:" tag to filter target specific tests tests/acceptance: introduce arch parameter and attribute tests/acceptance: fix doc reference to avocado_qemu directory tests/acceptance: improve docstring on pick_default_qemu_bin() tests/acceptance: show avocado test execution by default Signed-off-by: Peter Maydell <peter.maydell@linaro.org> # Conflicts: # configure
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include5
-rw-r--r--tests/acceptance/avocado_qemu/__init__.py23
-rw-r--r--tests/acceptance/boot_linux_console.py211
-rw-r--r--tests/acceptance/linux_initrd.py2
-rw-r--r--tests/acceptance/virtio_version.py2
5 files changed, 218 insertions, 25 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index e2432d5e77..7c8b9c84b2 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -1133,7 +1133,8 @@ TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
# Controls the output generated by Avocado when running tests.
# Any number of command separated loggers are accepted. For more
# information please refer to "avocado --help".
-AVOCADO_SHOW=none
+AVOCADO_SHOW=app
+AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGET_DIRS)))
ifneq ($(findstring v2,"v$(PYTHON_VERSION)"),v2)
$(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
@@ -1159,6 +1160,8 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR)
$(call quiet-command, \
$(TESTS_VENV_DIR)/bin/python -m avocado \
--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
+ --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
+ $(AVOCADO_TAGS) \
--failfast=on $(SRC_PATH)/tests/acceptance, \
"AVOCADO", "tests/acceptance")
diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py
index a66ec72daa..2b236a1cf0 100644
--- a/tests/acceptance/avocado_qemu/__init__.py
+++ b/tests/acceptance/avocado_qemu/__init__.py
@@ -23,12 +23,22 @@ def is_readable_executable_file(path):
return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK)
-def pick_default_qemu_bin():
+def pick_default_qemu_bin(arch=None):
"""
Picks the path of a QEMU binary, starting either in the current working
directory or in the source tree root directory.
+
+ :param arch: the arch to use when looking for a QEMU binary (the target
+ will match the arch given). If None (the default), arch
+ will be the current host system arch (as given by
+ :func:`os.uname`).
+ :type arch: str
+ :returns: the path to the default QEMU binary or None if one could not
+ be found
+ :rtype: str or None
"""
- arch = os.uname()[4]
+ if arch is None:
+ arch = os.uname()[4]
qemu_bin_relative_path = os.path.join("%s-softmmu" % arch,
"qemu-system-%s" % arch)
if is_readable_executable_file(qemu_bin_relative_path):
@@ -43,8 +53,15 @@ def pick_default_qemu_bin():
class Test(avocado.Test):
def setUp(self):
self._vms = {}
+ arches = self.tags.get('arch', [])
+ if len(arches) == 1:
+ arch = arches.pop()
+ else:
+ arch = None
+ self.arch = self.params.get('arch', default=arch)
+ default_qemu_bin = pick_default_qemu_bin(arch=self.arch)
self.qemu_bin = self.params.get('qemu_bin',
- default=pick_default_qemu_bin())
+ default=default_qemu_bin)
if self.qemu_bin is None:
self.cancel("No QEMU binary defined or found in the source tree")
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index beeb1e59e8..d5c500ea30 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -8,39 +8,212 @@
# 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
import logging
from avocado_qemu import Test
+from avocado.utils import process
+from avocado.utils import archive
class BootLinuxConsole(Test):
"""
- Boots a x86_64 Linux kernel and checks that the console is operational
- and the kernel command line is properly passed from QEMU to the kernel
-
- :avocado: tags=x86_64
+ Boots a Linux kernel and checks that the console is operational and the
+ kernel command line is properly passed from QEMU to the kernel
"""
- timeout = 60
+ timeout = 90
- def test(self):
- kernel_url = ('https://mirrors.kernel.org/fedora/releases/28/'
- 'Everything/x86_64/os/images/pxeboot/vmlinuz')
- kernel_hash = '238e083e114c48200f80d889f7e32eeb2793e02a'
- kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+ KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
- self.vm.set_machine('pc')
- self.vm.set_console()
- kernel_command_line = 'console=ttyS0'
- self.vm.add_args('-kernel', kernel_path,
- '-append', kernel_command_line)
- self.vm.launch()
+ 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()
console_logger.debug(msg.strip())
- if 'Kernel command line: %s' % kernel_command_line in msg:
+ if success_message in msg:
break
- if 'Kernel panic - not syncing' in msg:
- self.fail("Kernel panic reached")
+ if failure_message in msg:
+ fail = 'Failure message found in console: %s' % failure_message
+ self.fail(fail)
+
+ def extract_from_deb(self, deb, path):
+ """
+ Extracts a file from a deb package into the test workdir
+
+ :param deb: path to the deb archive
+ :param file: path within the deb archive of the file to be extracted
+ :returns: path of the extracted file
+ """
+ cwd = os.getcwd()
+ os.chdir(self.workdir)
+ process.run("ar x %s data.tar.gz" % deb)
+ archive.extract("data.tar.gz", self.workdir)
+ os.chdir(cwd)
+ return self.workdir + path
+
+ def test_x86_64_pc(self):
+ """
+ :avocado: tags=arch:x86_64
+ :avocado: tags=machine:pc
+ """
+ kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'
+ 'releases/29/Everything/x86_64/os/images/pxeboot/vmlinuz')
+ kernel_hash = '23bebd2680757891cf7adedb033532163a792495'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+ self.vm.set_machine('pc')
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
+ self.vm.add_args('-kernel', kernel_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_mips_malta(self):
+ """
+ :avocado: tags=arch:mips
+ :avocado: tags=machine:malta
+ :avocado: tags=endian:big
+ """
+ deb_url = ('http://snapshot.debian.org/archive/debian/'
+ '20130217T032700Z/pool/main/l/linux-2.6/'
+ 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb')
+ deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04'
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+ kernel_path = self.extract_from_deb(deb_path,
+ '/boot/vmlinux-2.6.32-5-4kc-malta')
+
+ self.vm.set_machine('malta')
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
+ self.vm.add_args('-kernel', kernel_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_mips64el_malta(self):
+ """
+ This test requires the ar tool to extract "data.tar.gz" from
+ the Debian package.
+
+ The kernel can be rebuilt using this Debian kernel source [1] and
+ following the instructions on [2].
+
+ [1] http://snapshot.debian.org/package/linux-2.6/2.6.32-48/
+ #linux-source-2.6.32_2.6.32-48
+ [2] https://kernel-team.pages.debian.net/kernel-handbook/
+ ch-common-tasks.html#s-common-official
+
+ :avocado: tags=arch:mips64el
+ :avocado: tags=machine:malta
+ """
+ deb_url = ('http://snapshot.debian.org/archive/debian/'
+ '20130217T032700Z/pool/main/l/linux-2.6/'
+ 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb')
+ deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5'
+ deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
+ kernel_path = self.extract_from_deb(deb_path,
+ '/boot/vmlinux-2.6.32-5-5kc-malta')
+
+ self.vm.set_machine('malta')
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
+ self.vm.add_args('-kernel', kernel_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_aarch64_virt(self):
+ """
+ :avocado: tags=arch:aarch64
+ :avocado: tags=machine:virt
+ """
+ kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'
+ 'releases/29/Everything/aarch64/os/images/pxeboot/vmlinuz')
+ kernel_hash = '8c73e469fc6ea06a58dc83a628fc695b693b8493'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+ self.vm.set_machine('virt')
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ 'console=ttyAMA0')
+ self.vm.add_args('-cpu', 'cortex-a53',
+ '-kernel', kernel_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_virt(self):
+ """
+ :avocado: tags=arch:arm
+ :avocado: tags=machine:virt
+ """
+ kernel_url = ('https://download.fedoraproject.org/pub/fedora/linux/'
+ 'releases/29/Everything/armhfp/os/images/pxeboot/vmlinuz')
+ kernel_hash = 'e9826d741b4fb04cadba8d4824d1ed3b7fb8b4d4'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+ self.vm.set_machine('virt')
+ self.vm.set_console()
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
+ 'console=ttyAMA0')
+ self.vm.add_args('-kernel', kernel_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_s390x_s390_ccw_virtio(self):
+ """
+ :avocado: tags=arch:s390x
+ :avocado: tags=machine:s390_ccw_virtio
+ """
+ kernel_url = ('https://download.fedoraproject.org/pub/fedora-secondary/'
+ 'releases/29/Everything/s390x/os/images/kernel.img')
+ kernel_hash = 'e8e8439103ef8053418ef062644ffd46a7919313'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+ self.vm.set_machine('s390-ccw-virtio')
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=sclp0'
+ self.vm.add_args('-nodefaults',
+ '-kernel', kernel_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_alpha_clipper(self):
+ """
+ :avocado: tags=arch:alpha
+ :avocado: tags=machine:clipper
+ """
+ kernel_url = ('http://archive.debian.org/debian/dists/lenny/main/'
+ 'installer-alpha/current/images/cdrom/vmlinuz')
+ kernel_hash = '3a943149335529e2ed3e74d0d787b85fb5671ba3'
+ kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+ uncompressed_kernel = archive.uncompress(kernel_path, self.workdir)
+
+ self.vm.set_machine('clipper')
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
+ self.vm.add_args('-vga', 'std',
+ '-kernel', uncompressed_kernel,
+ '-append', kernel_command_line)
+ self.vm.launch()
+ console_pattern = 'Kernel command line: %s' % kernel_command_line
+ self.wait_for_console_pattern(console_pattern)
diff --git a/tests/acceptance/linux_initrd.py b/tests/acceptance/linux_initrd.py
index fbdb48e43f..23be5a63aa 100644
--- a/tests/acceptance/linux_initrd.py
+++ b/tests/acceptance/linux_initrd.py
@@ -19,7 +19,7 @@ class LinuxInitrd(Test):
"""
Checks QEMU evaluates correctly the initrd file passed as -initrd option.
- :avocado: tags=x86_64
+ :avocado: tags=arch:x86_64
"""
timeout = 300
diff --git a/tests/acceptance/virtio_version.py b/tests/acceptance/virtio_version.py
index 37fc01ea18..8b97453ff8 100644
--- a/tests/acceptance/virtio_version.py
+++ b/tests/acceptance/virtio_version.py
@@ -61,7 +61,7 @@ class VirtioVersionCheck(Test):
same device tree created by `disable-modern` and
`disable-legacy`.
- :avocado: tags=x86_64
+ :avocado: tags=arch:x86_64
"""
# just in case there are failures, show larger diff: