8 changes: 0 additions & 8 deletions tests/avocado/linux_ssh_mips_malta.py
Expand Up @@ -101,14 +101,6 @@ def shutdown_via_ssh(self):
self.ssh_disconnect_vm()
wait_for_console_pattern(self, 'Power down', 'Oops')

def ssh_command_output_contains(self, cmd, exp):
stdout, _ = self.ssh_command(cmd)
for line in stdout:
if exp in line:
break
else:
self.fail('"%s" output does not contain "%s"' % (cmd, exp))

def run_common_commands(self, wordsize):
self.ssh_command_output_contains(
'cat /proc/cpuinfo',
Expand Down
158 changes: 158 additions & 0 deletions tests/avocado/machine_aarch64_sbsaref.py
@@ -0,0 +1,158 @@
# Functional test that boots a Linux kernel and checks the console
#
# SPDX-FileCopyrightText: 2023 Linaro Ltd.
# SPDX-FileContributor: Philippe Mathieu-Daudé <philmd@linaro.org>
# SPDX-FileContributor: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later

import os

from avocado import skip
from avocado import skipUnless
from avocado.utils import archive

from avocado_qemu import QemuSystemTest
from avocado_qemu import wait_for_console_pattern
from avocado_qemu import interrupt_interactive_console_until_pattern


class Aarch64SbsarefMachine(QemuSystemTest):
"""
:avocado: tags=arch:aarch64
:avocado: tags=machine:sbsa-ref
"""

timeout = 180

def fetch_firmware(self):
"""
Flash volumes generated using:
- Fedora GNU Toolchain version 12.2.1 20220819 (Red Hat Cross 12.2.1-2)
- Trusted Firmware-A
https://github.com/ARM-software/arm-trusted-firmware/tree/5fdb2e54
- Tianocore EDK II
https://github.com/tianocore/edk2/tree/494127613b
https://github.com/tianocore/edk2-non-osi/tree/41876073
https://github.com/tianocore/edk2-platforms/tree/8efa4f42
"""

# Secure BootRom (TF-A code)
fs0_xz_url = (
"https://fileserver.linaro.org/s/ATnSmq6k8SoXgbH/"
"download/SBSA_FLASH0.fd.xz"
)
fs0_xz_hash = "a210a09692bcbe0a3743ffd0df44e80e0c7ad8ab"
tar_xz_path = self.fetch_asset(fs0_xz_url, asset_hash=fs0_xz_hash)
archive.extract(tar_xz_path, self.workdir)
fs0_path = os.path.join(self.workdir, "SBSA_FLASH0.fd")

# Non-secure rom (UEFI and EFI variables)
fs1_xz_url = (
"https://fileserver.linaro.org/s/t8foNnMPz74DZZy/"
"download/SBSA_FLASH1.fd.xz"
)
fs1_xz_hash = "13a9a262953787c7fc5a9155dfaa26e703631e02"
tar_xz_path = self.fetch_asset(fs1_xz_url, asset_hash=fs1_xz_hash)
archive.extract(tar_xz_path, self.workdir)
fs1_path = os.path.join(self.workdir, "SBSA_FLASH1.fd")

for path in [fs0_path, fs1_path]:
with open(path, "ab+") as fd:
fd.truncate(256 << 20) # Expand volumes to 256MiB

self.vm.set_console()
self.vm.add_args(
"-drive",
f"if=pflash,file={fs0_path},format=raw",
"-drive",
f"if=pflash,file={fs1_path},format=raw",
"-smp",
"1",
"-machine",
"sbsa-ref",
)

def test_sbsaref_edk2_firmware(self):
"""
:avocado: tags=cpu:cortex-a57
"""

self.fetch_firmware()
self.vm.launch()

# TF-A boot sequence:
#
# https://github.com/ARM-software/arm-trusted-firmware/blob/v2.8.0/\
# docs/design/trusted-board-boot.rst#trusted-board-boot-sequence
# https://trustedfirmware-a.readthedocs.io/en/v2.8/\
# design/firmware-design.html#cold-boot

# AP Trusted ROM
wait_for_console_pattern(self, "Booting Trusted Firmware")
wait_for_console_pattern(self, "BL1: v2.8(release):v2.8")
wait_for_console_pattern(self, "BL1: Booting BL2")

# Trusted Boot Firmware
wait_for_console_pattern(self, "BL2: v2.8(release)")
wait_for_console_pattern(self, "Booting BL31")

# EL3 Runtime Software
wait_for_console_pattern(self, "BL31: v2.8(release)")

# Non-trusted Firmware
wait_for_console_pattern(self, "UEFI firmware (version 1.0")
interrupt_interactive_console_until_pattern(self, "QEMU SBSA-REF Machine")

# This tests the whole boot chain from EFI to Userspace
# We only boot a whole OS for the current top level CPU and GIC
# Other test profiles should use more minimal boots
def boot_alpine_linux(self, cpu):
self.fetch_firmware()

iso_url = (
"https://dl-cdn.alpinelinux.org/"
"alpine/v3.17/releases/aarch64/alpine-standard-3.17.2-aarch64.iso"
)

iso_hash = "5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027"
iso_path = self.fetch_asset(iso_url, algorithm="sha256", asset_hash=iso_hash)

self.vm.set_console()
self.vm.add_args(
"-cpu",
cpu,
"-drive",
f"file={iso_path},format=raw",
"-device",
"virtio-rng-pci,rng=rng0",
"-object",
"rng-random,id=rng0,filename=/dev/urandom",
)

self.vm.launch()
wait_for_console_pattern(self, "Welcome to Alpine Linux 3.17")

@skipUnless(os.getenv("AVOCADO_TIMEOUT_EXPECTED"), "Test might timeout")
def test_sbsaref_alpine_linux_cortex_a57(self):
"""
:avocado: tags=cpu:cortex-a57
"""
self.boot_alpine_linux("cortex-a57")

@skipUnless(os.getenv("AVOCADO_TIMEOUT_EXPECTED"), "Test might timeout")
def test_sbsaref_alpine_linux_neoverse_n1(self):
"""
:avocado: tags=cpu:max
"""
self.boot_alpine_linux("neoverse-n1")

@skip("requires TF-A update to handle FEAT_FGT")
def test_sbsaref_alpine_linux_max(self):
"""
:avocado: tags=cpu:max
"""
self.boot_alpine_linux("max,pauth-impdef=on")
30 changes: 17 additions & 13 deletions tests/avocado/machine_aspeed.py
Expand Up @@ -10,6 +10,7 @@
import tempfile
import subprocess

from avocado_qemu import LinuxSSHMixIn
from avocado_qemu import QemuSystemTest
from avocado_qemu import wait_for_console_pattern
from avocado_qemu import exec_command
Expand Down Expand Up @@ -268,7 +269,7 @@ def test_arm_ast2600_evb_buildroot_tpm(self):

self.do_test_arm_aspeed_buildroot_poweroff()

class AST2x00MachineSDK(QemuSystemTest):
class AST2x00MachineSDK(QemuSystemTest, LinuxSSHMixIn):

EXTRA_BOOTARGS = (
'quiet '
Expand All @@ -295,7 +296,7 @@ def do_test_arm_aspeed_sdk_start(self, image):
self.require_netdev('user')
self.vm.set_console()
self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
'-net', 'nic', '-net', 'user')
'-net', 'nic', '-net', 'user,hostfwd=:127.0.0.1:0-:22')
self.vm.launch()

self.wait_for_console_pattern('U-Boot 2019.04')
Expand Down Expand Up @@ -323,7 +324,7 @@ def test_arm_ast2500_evb_sdk(self):

self.do_test_arm_aspeed_sdk_start(
self.workdir + '/ast2500-default/image-bmc')
self.wait_for_console_pattern('ast2500-default login:')
self.wait_for_console_pattern('nodistro.0 ast2500-default ttyS4')

@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
def test_arm_ast2600_evb_sdk(self):
Expand All @@ -345,22 +346,25 @@ def test_arm_ast2600_evb_sdk(self):
'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
self.do_test_arm_aspeed_sdk_start(
self.workdir + '/ast2600-default/image-bmc')
self.wait_for_console_pattern('ast2600-default login:')
exec_command_and_wait_for_pattern(self, 'root', 'Password:')
exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
self.wait_for_console_pattern('nodistro.0 ast2600-default ttyS4')

exec_command_and_wait_for_pattern(self,
'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
self.ssh_connect('root', '0penBmc', False)
self.ssh_command('dmesg -c > /dev/null')

self.ssh_command_output_contains(
'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device ; '
'dmesg -c',
'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
exec_command_and_wait_for_pattern(self,
self.ssh_command_output_contains(
'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
property='temperature', value=18000);
exec_command_and_wait_for_pattern(self,
self.ssh_command_output_contains(
'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')

exec_command_and_wait_for_pattern(self,
'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
self.ssh_command_output_contains(
'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device ; '
'dmesg -c',
'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
year = time.strftime("%Y")
exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
self.ssh_command_output_contains('/sbin/hwclock -f /dev/rtc1', year);
232 changes: 204 additions & 28 deletions tests/avocado/tuxrun_baselines.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/lcitool/refresh
Expand Up @@ -182,7 +182,6 @@ try:
#
# Cirrus packages lists for GitLab
#
generate_cirrus("freebsd-12")
generate_cirrus("freebsd-13")
generate_cirrus("macos-12")

Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Expand Up @@ -2,5 +2,5 @@
# in the tests/venv Python virtual environment. For more info,
# refer to: https://pip.pypa.io/en/stable/user_guide/#id1
# Note that qemu.git/python/ is always implicitly installed.
avocado-framework==88.1
avocado-framework==101.0
pycdlib==1.11.0
10 changes: 7 additions & 3 deletions tests/tcg/Makefile.target
Expand Up @@ -152,13 +152,17 @@ PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))

# We need to ensure expand the run-plugin-TEST-with-PLUGIN
# pre-requistes manually here as we can't use stems to handle it. We
# also add some special helpers the run-plugin- rules can use bellow.
# only expand MULTIARCH_TESTS which are common on most of our targets
# to avoid an exponential explosion as new tests are added. We also
# add some special helpers the run-plugin- rules can use bellow.

ifneq ($(MULTIARCH_TESTS),)
$(foreach p,$(PLUGINS), \
$(foreach t,$(TESTS),\
$(foreach t,$(MULTIARCH_TESTS),\
$(eval run-plugin-$(t)-with-$(p): $t $p) \
$(eval RUN_TESTS+=run-plugin-$(t)-with-$(p))))
endif
endif # MULTIARCH_TESTS
endif # CONFIG_PLUGIN

strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1))
extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1))
Expand Down
2 changes: 0 additions & 2 deletions tests/tcg/aarch64/Makefile.softmmu-target
Expand Up @@ -81,6 +81,4 @@ pauth-3:
$(call skip-test, "BUILD of $@", "missing compiler support")
run-pauth-3:
$(call skip-test, "RUN of pauth-3", "not built")
run-plugin-pauth-3-with-%:
$(call skip-test, "RUN of pauth-3 ($*)", "not built")
endif
1 change: 0 additions & 1 deletion tests/tcg/aarch64/Makefile.target
Expand Up @@ -32,7 +32,6 @@ ifneq ($(CROSS_CC_HAS_ARMV8_3),)
AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
pauth-%: CFLAGS += -march=armv8.3-a
run-pauth-%: QEMU_OPTS += -cpu max
run-plugin-pauth-%: QEMU_OPTS += -cpu max
endif

# BTI Tests
Expand Down
4 changes: 3 additions & 1 deletion tests/tcg/arm/Makefile.softmmu-target
Expand Up @@ -23,4 +23,6 @@ LDFLAGS+=-nostdlib -N -static
test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 -mfloat-abi=soft

run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
run-plugin-test-armv6m-undef-%: QEMU_OPTS+=-semihosting -M microbit -kernel

# We don't currently support the multiarch system tests
undefine MULTIARCH_TESTS
8 changes: 0 additions & 8 deletions tests/tcg/arm/Makefile.target
Expand Up @@ -46,11 +46,6 @@ semihosting-arm: semihosting.c
run-semihosting-arm: semihosting-arm
$(call run-test,$<,$(QEMU) $< 2> $<.err)

run-plugin-semihosting-arm-with-%:
$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
$(call strip-plugin,$<) 2> $<.err)

ARM_TESTS += semiconsole-arm

semiconsole: CFLAGS += -mthumb
Expand All @@ -62,9 +57,6 @@ semiconsole-arm: semihosting.c
run-semiconsole-arm: semiconsole-arm
$(call skip-test, $<, "MANUAL ONLY")

run-plugin-semiconsole-arm-with-%:
$(call skip-test, $<, "MANUAL ONLY")

endif

ARM_TESTS += commpage
Expand Down
3 changes: 3 additions & 0 deletions tests/tcg/cris/Makefile.target
Expand Up @@ -57,3 +57,6 @@ SIMG:=cris-axis-linux-gnu-run
# e.g.: make -f ../../tests/tcg/Makefile run-check_orm-on-sim
run-%-on-sim:
$(call run-test, $<, $(SIMG) $<)

# We don't currently support the multiarch tests
undefine MULTIARCH_TESTS
2 changes: 0 additions & 2 deletions tests/tcg/hppa/Makefile.target
Expand Up @@ -10,8 +10,6 @@ EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536
# it requires the full vdso with dwarf2 unwind info.
run-signals: signals
$(call skip-test, $<, "BROKEN awaiting vdso support")
run-plugin-signals-with-%:
$(call skip-test, $<, "BROKEN awaiting vdso support")

VPATH += $(SRC_PATH)/tests/tcg/hppa
TESTS += stby
Expand Down
10 changes: 0 additions & 10 deletions tests/tcg/i386/Makefile.target
Expand Up @@ -18,19 +18,15 @@ X86_64_TESTS:=$(filter test-i386-adcox test-i386-bmi2 $(SKIP_I386_TESTS), $(ALL_

test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse
run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max
run-plugin-test-i386-sse-exceptions-%: QEMU_OPTS += -cpu max

test-i386-pcmpistri: CFLAGS += -msse4.2
run-test-i386-pcmpistri: QEMU_OPTS += -cpu max
run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max

test-i386-bmi2: CFLAGS=-O2
run-test-i386-bmi2: QEMU_OPTS += -cpu max
run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max

test-i386-adcox: CFLAGS=-O2
run-test-i386-adcox: QEMU_OPTS += -cpu max
run-plugin-test-i386-adcox-%: QEMU_OPTS += -cpu max

#
# hello-i386 is a barebones app
Expand All @@ -52,8 +48,6 @@ test-i386:
$(call skip-test, "BUILD of $@", "missing -no-pie compiler support")
run-test-i386:
$(call skip-test, "RUN of test-i386", "not built")
run-plugin-test-i386-with-%:
$(call skip-test, "RUN of test-i386 ($*)", "not built")
endif

ifeq ($(SPEED), slow)
Expand Down Expand Up @@ -87,7 +81,6 @@ sha512-sse: sha512.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)

run-sha512-sse: QEMU_OPTS+=-cpu max
run-plugin-sha512-sse-with-%: QEMU_OPTS+=-cpu max

TESTS+=sha512-sse

Expand All @@ -103,15 +96,12 @@ test-avx.h: test-avx.py x86.csv

test-3dnow: CFLAGS += -masm=intel -O -I.
run-test-3dnow: QEMU_OPTS += -cpu max
run-plugin-test-3dnow: QEMU_OPTS += -cpu max
test-3dnow: test-3dnow.h

test-mmx: CFLAGS += -masm=intel -O -I.
run-test-mmx: QEMU_OPTS += -cpu max
run-plugin-test-mmx: QEMU_OPTS += -cpu max
test-mmx: test-mmx.h

test-avx: CFLAGS += -mavx -masm=intel -O -I.
run-test-avx: QEMU_OPTS += -cpu max
run-plugin-test-avx: QEMU_OPTS += -cpu max
test-avx: test-avx.h
2 changes: 0 additions & 2 deletions tests/tcg/ppc64/Makefile.target
Expand Up @@ -24,14 +24,12 @@ PPC64_TESTS += byte_reverse sha512-vector
endif
byte_reverse: CFLAGS += -mcpu=power10
run-byte_reverse: QEMU_OPTS+=-cpu POWER10
run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10

sha512-vector: CFLAGS +=-mcpu=power10 -O3
sha512-vector: sha512.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)

run-sha512-vector: QEMU_OPTS+=-cpu POWER10
run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10

PPC64_TESTS += signal_save_restore_xer
PPC64_TESTS += xxspltw
Expand Down
3 changes: 3 additions & 0 deletions tests/tcg/riscv64/Makefile.softmmu-target
Expand Up @@ -19,3 +19,6 @@ QEMU_OPTS += -M virt -display none -semihosting -device loader,file=
EXTRA_RUNS += run-issue1060
run-issue1060: issue1060
$(call run-test, $<, $(QEMU) $(QEMU_OPTS)$<)

# We don't currently support the multiarch system tests
undefine MULTIARCH_TESTS
1 change: 0 additions & 1 deletion tests/tcg/riscv64/Makefile.target
Expand Up @@ -9,4 +9,3 @@ TESTS += noexec
TESTS += test-noc
test-noc: LDFLAGS = -nostdlib -static
run-test-noc: QEMU_OPTS += -cpu rv64,c=false
run-plugin-test-noc-%: QEMU_OPTS += -cpu rv64,c=false
3 changes: 3 additions & 0 deletions tests/tcg/s390x/Makefile.softmmu-target
Expand Up @@ -23,3 +23,6 @@ include $(S390X_SRC)/pgm-specification.mak
$(PGM_SPECIFICATION_TESTS): pgm-specification-softmmu.o
$(PGM_SPECIFICATION_TESTS): LDFLAGS+=pgm-specification-softmmu.o
TESTS += $(PGM_SPECIFICATION_TESTS)

# We don't currently support the multiarch system tests
undefine MULTIARCH_TESTS
3 changes: 3 additions & 0 deletions tests/tcg/tricore/Makefile.softmmu-target
Expand Up @@ -29,3 +29,6 @@ QEMU_OPTS += -M tricore_testboard -cpu tc27x -nographic -kernel

%.tst: %.o
$(LD) $(LDFLAGS) $< -o $@

# We don't currently support the multiarch system tests
undefine MULTIARCH_TESTS
3 changes: 3 additions & 0 deletions tests/tcg/xtensa/Makefile.softmmu-target
Expand Up @@ -41,3 +41,6 @@ $(XTENSA_USABLE_TESTS): linker.ld macros.inc $(CRT) Makefile.softmmu-target
$(CC) $(XTENSA_INC) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)

endif

# We don't currently support the multiarch system tests
undefine MULTIARCH_TESTS