aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/avocado/avocado_qemu/__init__.py4
-rw-r--r--tests/avocado/boot_linux.py48
-rw-r--r--tests/avocado/boot_linux_console.py1
-rw-r--r--tests/avocado/machine_aarch64_virt.py63
-rw-r--r--tests/avocado/reverse_debugging.py8
-rw-r--r--tests/avocado/virtiofs_submounts.py217
-rw-r--r--tests/qtest/arm-cpu-features.c22
-rw-r--r--tests/qtest/meson.build4
8 files changed, 95 insertions, 272 deletions
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
index 25a546842f..a313e88c07 100644
--- a/tests/avocado/avocado_qemu/__init__.py
+++ b/tests/avocado/avocado_qemu/__init__.py
@@ -274,6 +274,10 @@ class QemuSystemTest(QemuBaseTest):
super().setUp('qemu-system-')
+ accel_required = self._get_unique_tag_val('accel')
+ if accel_required:
+ self.require_accelerator(accel_required)
+
self.machine = self.params.get('machine',
default=self._get_unique_tag_val('machine'))
diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py
index b3e58fa309..fe0bb180d9 100644
--- a/tests/avocado/boot_linux.py
+++ b/tests/avocado/boot_linux.py
@@ -58,52 +58,16 @@ class BootLinuxX8664(LinuxTest):
self.launch_and_wait(set_up_ssh_connection=False)
-# For Aarch64 we only boot KVM tests in CI as the TCG tests are very
-# heavyweight. There are lighter weight distros which we use in the
-# machine_aarch64_virt.py tests.
+# For Aarch64 we only boot KVM tests in CI as booting the current
+# Fedora OS in TCG tests is very heavyweight. There are lighter weight
+# distros which we use in the machine_aarch64_virt.py tests.
class BootLinuxAarch64(LinuxTest):
"""
:avocado: tags=arch:aarch64
:avocado: tags=machine:virt
- :avocado: tags=machine:gic-version=2
"""
timeout = 720
- def add_common_args(self):
- self.vm.add_args('-bios',
- os.path.join(BUILD_DIR, 'pc-bios',
- 'edk2-aarch64-code.fd'))
- self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
- self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
-
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
- def test_fedora_cloud_tcg_gicv2(self):
- """
- :avocado: tags=accel:tcg
- :avocado: tags=cpu:max
- :avocado: tags=device:gicv2
- """
- self.require_accelerator("tcg")
- self.vm.add_args("-accel", "tcg")
- self.vm.add_args("-cpu", "max,lpa2=off")
- self.vm.add_args("-machine", "virt,gic-version=2")
- self.add_common_args()
- self.launch_and_wait(set_up_ssh_connection=False)
-
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
- def test_fedora_cloud_tcg_gicv3(self):
- """
- :avocado: tags=accel:tcg
- :avocado: tags=cpu:max
- :avocado: tags=device:gicv3
- """
- self.require_accelerator("tcg")
- self.vm.add_args("-accel", "tcg")
- self.vm.add_args("-cpu", "max,lpa2=off")
- self.vm.add_args("-machine", "virt,gic-version=3")
- self.add_common_args()
- self.launch_and_wait(set_up_ssh_connection=False)
-
def test_virt_kvm(self):
"""
:avocado: tags=accel:kvm
@@ -112,7 +76,11 @@ class BootLinuxAarch64(LinuxTest):
self.require_accelerator("kvm")
self.vm.add_args("-accel", "kvm")
self.vm.add_args("-machine", "virt,gic-version=host")
- self.add_common_args()
+ self.vm.add_args('-bios',
+ os.path.join(BUILD_DIR, 'pc-bios',
+ 'edk2-aarch64-code.fd'))
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
+ self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
self.launch_and_wait(set_up_ssh_connection=False)
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
index be60f8cda9..574609bf43 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -997,6 +997,7 @@ class BootLinuxConsole(LinuxKernelTest):
def test_aarch64_raspi3_atf(self):
"""
+ :avocado: tags=accel:tcg
:avocado: tags=arch:aarch64
:avocado: tags=machine:raspi3b
:avocado: tags=cpu:cortex-a53
diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py
index c2b2ba2cf8..25dab8dc00 100644
--- a/tests/avocado/machine_aarch64_virt.py
+++ b/tests/avocado/machine_aarch64_virt.py
@@ -10,11 +10,14 @@
import time
import os
+import logging
from avocado_qemu import QemuSystemTest
from avocado_qemu import wait_for_console_pattern
from avocado_qemu import exec_command
from avocado_qemu import BUILD_DIR
+from avocado.utils import process
+from avocado.utils.path import find_command
class Aarch64VirtMachine(QemuSystemTest):
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
@@ -65,16 +68,15 @@ class Aarch64VirtMachine(QemuSystemTest):
self.wait_for_console_pattern('Welcome to Alpine Linux 3.16')
- def test_aarch64_virt(self):
+ def common_aarch64_virt(self, machine):
"""
- :avocado: tags=arch:aarch64
- :avocado: tags=machine:virt
- :avocado: tags=accel:tcg
- :avocado: tags=cpu:max
+ Common code to launch basic virt machine with kernel+initrd
+ and a scratch disk.
"""
+ logger = logging.getLogger('aarch64_virt')
+
kernel_url = ('https://fileserver.linaro.org/s/'
'z6B2ARM7DQT3HWN/download')
-
kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347'
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
@@ -83,13 +85,62 @@ class Aarch64VirtMachine(QemuSystemTest):
'console=ttyAMA0')
self.require_accelerator("tcg")
self.vm.add_args('-cpu', 'max,pauth-impdef=on',
+ '-machine', machine,
'-accel', 'tcg',
'-kernel', kernel_path,
'-append', kernel_command_line)
+
+ # A RNG offers an easy way to generate a few IRQs
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
+ self.vm.add_args('-object',
+ 'rng-random,id=rng0,filename=/dev/urandom')
+
+ # Also add a scratch block device
+ logger.info('creating scratch qcow2 image')
+ image_path = os.path.join(self.workdir, 'scratch.qcow2')
+ qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
+ if not os.path.exists(qemu_img):
+ qemu_img = find_command('qemu-img', False)
+ if qemu_img is False:
+ self.cancel('Could not find "qemu-img", which is required to '
+ 'create the temporary qcow2 image')
+ cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path)
+ process.run(cmd)
+
+ # Add the device
+ self.vm.add_args('-blockdev',
+ f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch")
+ self.vm.add_args('-device',
+ 'virtio-blk-device,drive=scratch')
+
self.vm.launch()
self.wait_for_console_pattern('Welcome to Buildroot')
time.sleep(0.1)
exec_command(self, 'root')
time.sleep(0.1)
+ exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4')
+ time.sleep(0.1)
+ exec_command(self, 'md5sum /dev/vda')
+ time.sleep(0.1)
+ exec_command(self, 'cat /proc/interrupts')
+ time.sleep(0.1)
exec_command(self, 'cat /proc/self/maps')
time.sleep(0.1)
+
+ def test_aarch64_virt_gicv3(self):
+ """
+ :avocado: tags=arch:aarch64
+ :avocado: tags=machine:virt
+ :avocado: tags=accel:tcg
+ :avocado: tags=cpu:max
+ """
+ self.common_aarch64_virt("virt,gic_version=3")
+
+ def test_aarch64_virt_gicv2(self):
+ """
+ :avocado: tags=arch:aarch64
+ :avocado: tags=machine:virt
+ :avocado: tags=accel:tcg
+ :avocado: tags=cpu:max
+ """
+ self.common_aarch64_virt("virt,gic-version=2")
diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
index d2921e70c3..680c314cfc 100644
--- a/tests/avocado/reverse_debugging.py
+++ b/tests/avocado/reverse_debugging.py
@@ -173,6 +173,10 @@ class ReverseDebugging(LinuxKernelTest):
vm.shutdown()
class ReverseDebugging_X86_64(ReverseDebugging):
+ """
+ :avocado: tags=accel:tcg
+ """
+
REG_PC = 0x10
REG_CS = 0x12
def get_pc(self, g):
@@ -190,6 +194,10 @@ class ReverseDebugging_X86_64(ReverseDebugging):
self.reverse_debugging()
class ReverseDebugging_AArch64(ReverseDebugging):
+ """
+ :avocado: tags=accel:tcg
+ """
+
REG_PC = 32
# unidentified gitlab timeout problem
diff --git a/tests/avocado/virtiofs_submounts.py b/tests/avocado/virtiofs_submounts.py
deleted file mode 100644
index e6dc32ffd4..0000000000
--- a/tests/avocado/virtiofs_submounts.py
+++ /dev/null
@@ -1,217 +0,0 @@
-import logging
-import re
-import os
-import subprocess
-import time
-
-from avocado import skipUnless
-from avocado_qemu import LinuxTest, BUILD_DIR
-from avocado_qemu import has_cmds
-from avocado_qemu import run_cmd
-from avocado_qemu import wait_for_console_pattern
-from avocado.utils import ssh
-
-
-class VirtiofsSubmountsTest(LinuxTest):
- """
- :avocado: tags=arch:x86_64
- :avocado: tags=accel:kvm
- """
-
- def run(self, args, ignore_error=False):
- stdout, stderr, ret = run_cmd(args)
-
- if ret != 0:
- cmdline = ' '.join(args)
- if not ignore_error:
- self.fail(f'{cmdline}: Returned {ret}: {stderr}')
- else:
- self.log.warn(f'{cmdline}: Returned {ret}: {stderr}')
-
- return (stdout, stderr, ret)
-
- def set_up_shared_dir(self):
- self.shared_dir = os.path.join(self.workdir, 'virtiofs-shared')
-
- os.mkdir(self.shared_dir)
-
- self.run(('cp', self.get_data('guest.sh'),
- os.path.join(self.shared_dir, 'check.sh')))
-
- self.run(('cp', self.get_data('guest-cleanup.sh'),
- os.path.join(self.shared_dir, 'cleanup.sh')))
-
- def set_up_virtiofs(self):
- attmp = os.getenv('AVOCADO_TESTS_COMMON_TMPDIR')
- self.vfsdsock = os.path.join(attmp, 'vfsdsock')
-
- self.run(('sudo', '-n', 'rm', '-f', self.vfsdsock), ignore_error=True)
-
- self.virtiofsd = \
- subprocess.Popen(('sudo', '-n',
- 'tools/virtiofsd/virtiofsd',
- f'--socket-path={self.vfsdsock}',
- '-o', f'source={self.shared_dir}',
- '-o', 'cache=always',
- '-o', 'xattr',
- '-o', 'announce_submounts',
- '-f'),
- stdout=subprocess.DEVNULL,
- stderr=subprocess.PIPE,
- universal_newlines=True)
-
- while not os.path.exists(self.vfsdsock):
- if self.virtiofsd.poll() is not None:
- self.fail('virtiofsd exited prematurely: ' +
- self.virtiofsd.communicate()[1])
- time.sleep(0.1)
-
- self.run(('sudo', '-n', 'chmod', 'go+rw', self.vfsdsock))
-
- self.vm.add_args('-chardev',
- f'socket,id=vfsdsock,path={self.vfsdsock}',
- '-device',
- 'vhost-user-fs-pci,queue-size=1024,chardev=vfsdsock' \
- ',tag=host',
- '-object',
- 'memory-backend-file,id=mem,size=1G,' \
- 'mem-path=/dev/shm,share=on',
- '-numa',
- 'node,memdev=mem')
-
- def set_up_nested_mounts(self):
- scratch_dir = os.path.join(self.shared_dir, 'scratch')
- try:
- os.mkdir(scratch_dir)
- except FileExistsError:
- pass
-
- args = ['bash', self.get_data('host.sh'), scratch_dir]
- if self.seed:
- args += [self.seed]
-
- out, _, _ = self.run(args)
- seed = re.search(r'^Seed: \d+', out)
- self.log.info(seed[0])
-
- def mount_in_guest(self):
- self.ssh_command('mkdir -p /mnt/host')
- self.ssh_command('mount -t virtiofs host /mnt/host')
-
- def check_in_guest(self):
- self.ssh_command('bash /mnt/host/check.sh /mnt/host/scratch/share')
-
- def live_cleanup(self):
- self.ssh_command('bash /mnt/host/cleanup.sh /mnt/host/scratch')
-
- # It would be nice if the above was sufficient to make virtiofsd clear
- # all references to the mounted directories (so they can be unmounted
- # on the host), but unfortunately it is not. To do so, we have to
- # resort to a remount.
- self.ssh_command('mount -o remount /mnt/host')
-
- scratch_dir = os.path.join(self.shared_dir, 'scratch')
- self.run(('bash', self.get_data('cleanup.sh'), scratch_dir))
-
- @skipUnless(*has_cmds(('sudo -n', ('sudo', '-n', 'true')),
- 'ssh-keygen', 'bash', 'losetup', 'mkfs.xfs', 'mount'))
- def setUp(self):
- vmlinuz = self.params.get('vmlinuz')
- if vmlinuz is None:
- """
- The Linux kernel supports FUSE auto-submounts only as of 5.10.
- boot_linux.py currently provides Fedora 31, whose kernel is too
- old, so this test cannot pass with the on-image kernel (you are
- welcome to try, hence the option to force such a test with
- -p vmlinuz=''). Therefore, for now the user must provide a
- sufficiently new custom kernel, or effectively explicitly
- request failure with -p vmlinuz=''.
- Once an image with a sufficiently new kernel is available
- (probably Fedora 34), we can make -p vmlinuz='' the default, so
- that this parameter no longer needs to be specified.
- """
- self.cancel('vmlinuz parameter not set; you must point it to a '
- 'Linux kernel binary to test (to run this test with ' \
- 'the on-image kernel, set it to an empty string)')
-
- self.seed = self.params.get('seed')
-
- self.ssh_key = os.path.join(self.workdir, 'id_ed25519')
-
- self.run(('ssh-keygen', '-N', '', '-t', 'ed25519', '-f', self.ssh_key))
-
- pubkey = self.ssh_key + '.pub'
-
- super(VirtiofsSubmountsTest, self).setUp(pubkey)
-
- if vmlinuz:
- self.vm.add_args('-kernel', vmlinuz,
- '-append', 'console=ttyS0 root=/dev/sda1')
-
- self.require_accelerator("kvm")
- self.vm.add_args('-accel', 'kvm')
-
- def tearDown(self):
- try:
- self.vm.shutdown()
- except:
- pass
-
- scratch_dir = os.path.join(self.shared_dir, 'scratch')
- self.run(('bash', self.get_data('cleanup.sh'), scratch_dir),
- ignore_error=True)
-
- def test_pre_virtiofsd_set_up(self):
- self.set_up_shared_dir()
-
- self.set_up_nested_mounts()
-
- self.set_up_virtiofs()
- self.launch_and_wait()
- self.mount_in_guest()
- self.check_in_guest()
-
- def test_pre_launch_set_up(self):
- self.set_up_shared_dir()
- self.set_up_virtiofs()
-
- self.set_up_nested_mounts()
-
- self.launch_and_wait()
- self.mount_in_guest()
- self.check_in_guest()
-
- def test_post_launch_set_up(self):
- self.set_up_shared_dir()
- self.set_up_virtiofs()
- self.launch_and_wait()
-
- self.set_up_nested_mounts()
-
- self.mount_in_guest()
- self.check_in_guest()
-
- def test_post_mount_set_up(self):
- self.set_up_shared_dir()
- self.set_up_virtiofs()
- self.launch_and_wait()
- self.mount_in_guest()
-
- self.set_up_nested_mounts()
-
- self.check_in_guest()
-
- def test_two_runs(self):
- self.set_up_shared_dir()
-
- self.set_up_nested_mounts()
-
- self.set_up_virtiofs()
- self.launch_and_wait()
- self.mount_in_guest()
- self.check_in_guest()
-
- self.live_cleanup()
- self.set_up_nested_mounts()
-
- self.check_in_guest()
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
index 8691802950..1cb08138ad 100644
--- a/tests/qtest/arm-cpu-features.c
+++ b/tests/qtest/arm-cpu-features.c
@@ -21,7 +21,7 @@
#define SVE_MAX_VQ 16
#define MACHINE "-machine virt,gic-version=max -accel tcg "
-#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg "
+#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \
" 'arguments': { 'type': 'full', "
#define QUERY_TAIL "}}"
@@ -607,31 +607,39 @@ int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
- qtest_add_data_func("/arm/query-cpu-model-expansion",
- NULL, test_query_cpu_model_expansion);
+ if (qtest_has_accel("tcg")) {
+ qtest_add_data_func("/arm/query-cpu-model-expansion",
+ NULL, test_query_cpu_model_expansion);
+ }
+
+ if (!g_str_equal(qtest_get_arch(), "aarch64")) {
+ goto out;
+ }
/*
* For now we only run KVM specific tests with AArch64 QEMU in
* order avoid attempting to run an AArch32 QEMU with KVM on
* AArch64 hosts. That won't work and isn't easy to detect.
*/
- if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
+ if (qtest_has_accel("kvm")) {
/*
* This tests target the 'host' CPU type, so register it only if
* KVM is available.
*/
qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
NULL, test_query_cpu_model_expansion_kvm);
+
+ qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
+ NULL, sve_tests_sve_off_kvm);
}
- if (g_str_equal(qtest_get_arch(), "aarch64")) {
+ if (qtest_has_accel("tcg")) {
qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
NULL, sve_tests_sve_max_vq_8);
qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
NULL, sve_tests_sve_off);
- qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
- NULL, sve_tests_sve_off_kvm);
}
+out:
return g_test_run();
}
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 222e1892fb..29a4efb4c2 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -208,8 +208,8 @@ qtests_arm = \
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
qtests_aarch64 = \
(cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
+ (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
+ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
['arm-cpu-features',