testing/next: gdb-multiarch, check-tcg, vbsa tests
v2 cover testing/next: gdb-multiarch, check-tcg, vbsa tests
This is the current status of my testing tree. The gdb-multiarch and filtering changes should be pretty uncontroversial. Due to the enhancements I needed to make to get the vbsa linux tests running they may want to cook a bit longer and wait until the 11.0 release is out of the way.
v2
- mostly tweaks to the vbsa test (see inline comments on commit)
- dropped the zip and send_key patches
All patches now reviewed (although worth giving the vbsa test the once over).
Alex.
Alex Bennée (4):
tests/docker: add gdb-multiarch to all-test-cross tests/tcg: allow filtering of TCG tests tests/functional: allow tests to define decompression target tests/functional: add VBSA linux tests
Matheus Tavares Bernardino (1):
tests/tcg/multiarch/linux-test: use portable alternative for dirent64
tests/tcg/multiarch/linux/linux-test.c | 5 +- tests/Makefile.include | 8 +- .../dockerfiles/debian-all-test-cross.docker | 1 + tests/functional/aarch64/test_virt_vbsa.py | 122 ++++++++++++++++-- tests/functional/qemu_test/testcase.py | 9 +- tests/lcitool/refresh | 1 + tests/tcg/Makefile.target | 12 +- 7 files changed, 138 insertions(+), 20 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/5 tests/docker: add gdb-multiarch to all-test-cross
This allows the gdb integration tests to be run as well.
--- tests/docker/dockerfiles/debian-all-test-cross.docker | 1 + tests/lcitool/refresh | 1 + 2 files changed, 2 insertions(+)
tests/docker/dockerfiles/debian-all-test-cross.docker +1 -0
@@ -59,6 +59,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ apt install -y --no-install-recommends \ clang\ dpkg-dev\ + gdb-multiarch\ libclang-rt-dev ENV AVAILABLE_COMPILERS gcc-aarch64-linux-gnu \ libc6-dev-arm64-cross \
tests/lcitool/refresh +1 -0
@@ -167,6 +167,7 @@ debian_all_test_cross_compilers = [ " apt install -y --no-install-recommends \\\n", " clang\\\n", " dpkg-dev\\\n", + " gdb-multiarch\\\n", " libclang-rt-dev\n", "ENV AVAILABLE_COMPILERS gcc-aarch64-linux-gnu \\\n", " libc6-dev-arm64-cross \\\n",
Signature · 1 line
2.47.3
PATCH v2 2/5 tests/tcg: allow filtering of TCG tests
In reply to Alex BennéeWe have a lot of TCG tests now which can be fiddly if we just want to check one particular test type across the targets. Introduce TCG_TEST_FILTER to allow this:
make check-tcg TCG_TEST_FILTER=gdb
to run all the gdb tests across the suites.
--- tests/Makefile.include | 8 +++++--- tests/tcg/Makefile.target | 12 +++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-)
tests/Makefile.include +5 -3
@@ -16,9 +16,11 @@ check-help: @echo " $(MAKE) check-tracetool Run tracetool generator tests" @echo " $(MAKE) check-block Run block tests" ifneq ($(filter $(all-check-targets), check-softfloat),) - @echo " $(MAKE) check-tcg Run TCG tests" @echo " $(MAKE) check-softfloat Run FPU emulation tests" - @echo " $(MAKE) run-tcg-tests-TARGET-softmmu Run TCG tests for a given target" + @echo " $(MAKE) check-tcg Run TCG tests" + @echo " $(MAKE) run-tcg-tests-TARGET Run TCG tests for a given target" + @echo + @echo "The variable TCG_TEST_FILTER will select the subset of matching tests." endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report"
@@ -64,7 +66,7 @@ $(TCG_TESTS_TARGETS:%=build-tcg-tests-%): build-tcg-tests-%: $(BUILD_DIR)/tests/ .PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%) $(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-% $(call quiet-command, \ - $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) SPEED=$(SPEED) run, \ + $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) SPEED=$(SPEED) TCG_TEST_FILTER=$(TCG_TEST_FILTER) run, \ "RUN", "$* guest-tests") .PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%)
tests/tcg/Makefile.target +11 -1
@@ -254,8 +254,15 @@ endif gdb-%: % gdb --args $(QEMU) $(QEMU_OPTS) $< +# Filter tests based on TCG_TEST_FILTER if set +ifdef TCG_TEST_FILTER +FILTERED_RUN_TESTS=$(foreach test,$(RUN_TESTS),$(if $(findstring $(TCG_TEST_FILTER),$(test)),$(test))) +else +FILTERED_RUN_TESTS=$(RUN_TESTS) +endif + .PHONY: run -run: $(RUN_TESTS) +run: $(FILTERED_RUN_TESTS) clean: rm -f $(TESTS) *.o $(CLEANFILES)
@@ -269,3 +276,6 @@ help: @echo "Built with $(CC)" @echo "Available tests:" @$(foreach t,$(RUN_TESTS),echo " $t";) + @echo "" + @echo "Environment variables:" + @echo " TCG_TEST_FILTER=<pattern> Filter tests matching pattern"
Signature · 1 line
2.47.3
PATCH v2 3/5 tests/tcg/multiarch/linux-test: use portable alternative for dirent64
In reply to Alex BennéeFrom: Matheus Tavares Bernardino <[email protected]>
dirent64 and readdir64 are glibc-specific and not portable to other C libraries such as musl. Define _FILE_OFFSET_BITS=64 instead, which portably instructs all libc implementations to use 64-bit file offsets, making readdir() and struct dirent equivalent to their 64-bit variants.
Message-ID: <af31d21c4d668cfb940ba4159f584fa6454c3d82.1772107448.git.matheus.bernardino@oss.qualcomm.com>
--- tests/tcg/multiarch/linux/linux-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tests/tcg/multiarch/linux/linux-test.c +3 -2
@@ -16,6 +16,7 @@* You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#define _FILE_OFFSET_BITS 64#define _GNU_SOURCE#include <stdarg.h> #include <stdlib.h>
@@ -83,7 +84,7 @@ static void test_file(void)struct utimbuf tbuf;struct iovec vecs[2 ];DIR *dir; -struct dirent64 *de; +struct dirent *de;/* TODO: make common tempdir creation for tcg tests */ char template[] ="/tmp/linux-test-XXXXXX" ;char *tmpdir =mkdtemp (template);
@@ -191,7 +192,7 @@ static void test_file(void)error ("opendir" ); len =0 ;for (;;) { - de =readdir64 (dir); + de =readdir (dir);if (!de)break ; if (strcmp(de->d_name, ".") != 0 &&
Signature · 1 line
2.47.3
PATCH v2 4/5 tests/functional: allow tests to define decompression target
In reply to Alex BennéeWhen dealing with multi-stage decompression we want to specify the target file name lest we just overload the cache name. It also allows for something is little more friendly than the cache hash.
--- tests/functional/qemu_test/testcase.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tests/functional/qemu_test/testcase.py +6 -3
@@ -35,7 +35,7 @@ class QemuBaseTest(unittest.TestCase): - def uncompress(self, compressed, format=None): + def uncompress(self, compressed, target=None, format=None): ''' @params compressed: filename, Asset, or file-like object to uncompress @params format: optional compression format (gzip, lzma)
@@ -52,8 +52,11 @@ def uncompress(self, compressed, format=None): if isinstance(compressed, Asset): compressed.fetch() - (name, _ext) = os.path.splitext(str(compressed)) - uncompressed = self.scratch_file(os.path.basename(name)) + if target is not None: + uncompressed = self.scratch_file(target) + else: + (name, _ext) = os.path.splitext(str(compressed)) + uncompressed = self.scratch_file(os.path.basename(name)) uncompress(compressed, uncompressed, format)
Signature · 1 line
2.47.3
PATCH v2 5/5 tests/functional: add VBSA linux tests
In reply to Alex BennéeThis extends the VBSA test to run the linux tests. The sysarch-acs test suite does provide some pre-built images which is good because the tests require a patched kernel. However due to the structure of the image we need to jump one or two hoops to get something useful:
- download and double decompress (zip then xz) the image
- navigate grub to launch the Linux Execution Environment
- shutdown the system once tests are done
- extract the logs from the MSDOS file system and parse them
It does make the code a bit ugly but it works for me at least. So far the subset of tests run is limited but that might be solved by adding some more devices to the PCIe bus to exercise the SMMU behaviour.
---
v2
- dropped unused imports
- use archive_extract for the zip step
- drop virtuilization=on and smmu=max lines from config
- use utf8 encodings for file access
- don't use f"" strings when not needed
- hack grub.cfg rather than using key presses
--- tests/functional/aarch64/test_virt_vbsa.py | 122 +++++++++++++++++++-- 1 file changed, 111 insertions(+), 11 deletions(-)
tests/functional/aarch64/test_virt_vbsa.py +111 -11
@@ -10,7 +10,8 @@ # SPDX-License-Identifier: GPL-2.0-or-later import shutil -from subprocess import check_call, DEVNULL +import re +from subprocess import check_call, check_output, DEVNULL from qemu_test import QemuSystemTest, Asset from qemu_test import get_qemu_img, skipIfMissingCommands
@@ -28,6 +29,20 @@ def wait_for_console_pattern(self, success_message, vm=None): failure_message='FAILED', vm=vm) + def append_firmware_blobs(self): + """ + Setup QEMU firmware blobs for boot. + """ + code_path = self.build_file('pc-bios', 'edk2-aarch64-code.fd') + vars_source = self.build_file('pc-bios', 'edk2-arm-vars.fd') + vars_path = self.scratch_file('vars.fd') + shutil.copy(vars_source, vars_path) + + self.vm.add_args('-drive', + f'if=pflash,format=raw,readonly=on,file={code_path}') + self.vm.add_args('-drive', f'if=pflash,format=raw,file={vars_path}') + + ASSET_VBSA_EFI = Asset( 'https://github.com/ARM-software/sysarch-acs/raw/refs/heads/main' '/prebuilt_images/VBSA/v25.12_VBSA_0.7.0/Vbsa.efi',
@@ -45,20 +60,12 @@ def test_aarch64_vbsa_uefi_tests(self): self.vm.set_console() - # virt machine wi + # virt machine self.set_machine('virt') self.vm.add_args('-M', 'virt,gic-version=max,virtualization=on') self.vm.add_args('-cpu', 'max', '-m', '1024') - # We will use the QEMU firmware blobs to boot - code_path = self.build_file('pc-bios', 'edk2-aarch64-code.fd') - vars_source = self.build_file('pc-bios', 'edk2-arm-vars.fd') - vars_path = self.scratch_file('vars.fd') - shutil.copy(vars_source, vars_path) - - self.vm.add_args('-drive', - f'if=pflash,format=raw,readonly=on,file={code_path}') - self.vm.add_args('-drive', f'if=pflash,format=raw,file={vars_path}') + self.append_firmware_blobs() # Build an EFI FAT32 file-system for the UEFI tests vbsa_efi = self.ASSET_VBSA_EFI.fetch()
@@ -102,5 +109,98 @@ def test_aarch64_vbsa_uefi_tests(self): self.wait_for_console_pattern('VBSA tests complete. Reset the system.') + ASSET_SYSREADY_IMAGE = Asset( + 'https://github.com/ARM-software/arm-systemready/' + 'releases/download/v25.10_SR_3.1.0/systemready_acs_live_image.img.xz.zip', + 'df2c359de15784b1da6a8e6f3c98a053ee38ac0b3f241ccea62e17db092eb03a') + + ROOT_PROMPT = '/ # ' + + @skipIfMissingCommands("sfdisk", "jq", "sed") + def test_aarch64_vbsa_linux_tests(self): + """ + Launch the Linux based VBSA test from the ACS prebuilt images. + + We can use the pre-built images and then trigger the Linux + build and run the tests. We then need to slurp the results + from the partition. + """ + + self.vm.set_console() + + # Plain virt machine + self.set_machine('virt') + self.vm.add_args('-M', 'virt,gic-version=max') + self.vm.add_args('-cpu', 'max', '-m', '1024', '-smp', '4') + + self.append_firmware_blobs() + + # First fetch, decompress (twice) and prepare the disk image + # on an NVME device (the kernel only has drivers for that). + self.archive_extract(self.ASSET_SYSREADY_IMAGE, format="zip") + disk_image_xz = self.scratch_file("systemready_acs_live_image.img.xz") + disk_image = self.uncompress(disk_image_xz) + + self.vm.add_args('-device', + 'nvme,drive=hd,serial=QEMU_ROOT_SSD') + self.vm.add_args('-blockdev', + f'driver=raw,node-name=hd,file.driver=file,file.filename={disk_image}') + + # Tweak grub.cfg default to avoid manually navigating grub + grub_cfg = self.scratch_file("grub.cfg") + offset = int(check_output(f"sfdisk --json {disk_image} |" + "jq '.partitiontable.partitions[0].start * 512'", + shell=True)) + check_call(["mcopy", "-i", f"{disk_image}@@{offset}", + "::/EFI/BOOT/grub.cfg", grub_cfg]) + + with open(grub_cfg, 'a', encoding="utf8") as f: + f.write("set default='Linux Execution Enviroment'") + + check_call(["mcopy", "-D", "o", "-i", f"{disk_image}@@{offset}", + grub_cfg, "::/EFI/BOOT/grub.cfg"]) + + # Launch QEMU and wait for grub and select the "Linux + # Execution Environment" so we can launch the test. + + self.vm.launch() + self.wait_for_console_pattern(self.ROOT_PROMPT) + ec_and_wait(self, "/usr/bin/bsa.sh --skip " + "B_REP_1,B_IEP_1,B_PCIe_11,B_MEM_06", + self.ROOT_PROMPT) + + # Now we can shutdown + ec_and_wait(self, "halt -f", "reboot: System halted") + self.vm.shutdown() + + # and extract the test logs + bsa_app_res = self.scratch_file("BsaResultsApp.log") + bsa_kern_res = self.scratch_file("BsaResultsKernel.log") + + check_call(["mcopy", "-i", f"{disk_image}@@{offset}", + "::acs_results/Linux/BsaResultsApp.log", bsa_app_res]) + check_call(["mcopy", "-i", f"{disk_image}@@{offset}", + "::acs_results/Linux/BsaResultsKernel.log", bsa_kern_res]) + + # for now just check the kernel log for the result summary + test_result_re = re.compile(r"\[.*\]\s+(.+): Result:\s+(\w+)") + summary_re = re.compile(r"Total Tests Run =\s*(\d+), Tests Passed =\s*(\d+), Tests Failed =\s*(\d+)") + + with open(bsa_kern_res, 'r', encoding="utf8") as f: + for line in f: + test_match = test_result_re.search(line) + if test_match: + desc = test_match.group(1) + status = test_match.group(2) + self.log.info(f"Test: {desc} status: {status}") + + match = summary_re.search(line) + if match: + total, passed, failed = match.groups() + + if int(failed) > 0: + self.fail(f"{failed} tests failed ({total})") + + if __name__ == '__main__': QemuSystemTest.main()
Signature · 1 line
2.47.3
Re: [PATCH v2 5/5] tests/functional: add VBSA linux tests
Quoted 5 lines · Alex Bennée
This extends the VBSA test to run the linux tests. The sysarch-acs test suite does provide some pre-built images which is good because the tests require a patched kernel. However due to the structure of the image we need to jump one or two hoops to get something useful:
Quoted 9 lines
- download and double decompress (zip then xz) the image
- navigate grub to launch the Linux Execution Environment
- shutdown the system once tests are done
- extract the logs from the MSDOS file system and parse themIt does make the code a bit ugly but it works for me at least. So far the subset of tests run is limited but that might be solved by adding some more devices to the PCIe bus to exercise the SMMU behaviour.
If I recall correctly, all TF-A tests concerning SMMU are based on SMMUv3TestEngine device, which unfortunately has a proprietary interface. We would greatly benefit from all this is Arm published that as a specification, and this would remove all the needs for ad hoc SMMU testing. Or we could reverse engineer the interface from how tests exercise it and implement something similar in QEMU to run original Arm tests.
Regards,
Pierrick