diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2019-06-21 15:26:38 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@redhat.com> | 2021-11-08 17:00:22 +0100 |
commit | 8011837a019182c61bad0d8f3a603d26dd4b6710 (patch) | |
tree | 2b3e457a5e89000fc2d874d1beef05c98ff77e57 /tests/avocado/load_bflt.py | |
parent | 0e4b1c9435528c30718a2722d09ff35beaa300ee (diff) | |
download | qemu-8011837a019182c61bad0d8f3a603d26dd4b6710.zip qemu-8011837a019182c61bad0d8f3a603d26dd4b6710.tar.gz qemu-8011837a019182c61bad0d8f3a603d26dd4b6710.tar.bz2 |
tests/avocado: Add bFLT loader linux-user test
Add a very quick test that runs a busybox binary in bFLT format:
$ AVOCADO_ALLOW_UNTRUSTED_CODE=1 \
avocado --show=app run -t linux_user tests/avocado/load_bflt.py
JOB ID : db94d5960ce564c50904d666a7e259148c27e88f
JOB LOG : ~/avocado/job-results/job-2019-06-25T10.52-db94d59/job.log
(1/1) tests/avocado/load_bflt.py:LoadBFLT.test_stm32: PASS (0.15 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 0.54 s
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20211105143416.148332-6-f4bug@amsat.org>
Diffstat (limited to 'tests/avocado/load_bflt.py')
-rw-r--r-- | tests/avocado/load_bflt.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/avocado/load_bflt.py b/tests/avocado/load_bflt.py new file mode 100644 index 0000000..bb50cec --- /dev/null +++ b/tests/avocado/load_bflt.py @@ -0,0 +1,54 @@ +# Test the bFLT loader format +# +# Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import bz2 +import subprocess + +from avocado import skipUnless +from avocado_qemu import QemuUserTest +from avocado_qemu import has_cmd + + +class LoadBFLT(QemuUserTest): + + def extract_cpio(self, cpio_path): + """ + Extracts a cpio archive into the test workdir + + :param cpio_path: path to the cpio archive + """ + cwd = os.getcwd() + os.chdir(self.workdir) + with bz2.open(cpio_path, 'rb') as archive_cpio: + subprocess.run(['cpio', '-i'], input=archive_cpio.read(), + stderr=subprocess.DEVNULL) + os.chdir(cwd) + + @skipUnless(*has_cmd('cpio')) + @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') + def test_stm32(self): + """ + :avocado: tags=arch:arm + :avocado: tags=linux_user + :avocado: tags=quick + """ + # See https://elinux.org/STM32#User_Space + rootfs_url = ('https://elinux.org/images/5/51/' + 'Stm32_mini_rootfs.cpio.bz2') + rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6' + rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) + busybox_path = os.path.join(self.workdir, "/bin/busybox") + + self.extract_cpio(rootfs_path_bz2) + + res = self.run(busybox_path) + ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.' + self.assertIn(ver, res.stdout_text) + + res = self.run(busybox_path, ['uname', '-a']) + unm = 'armv7l GNU/Linux' + self.assertIn(unm, res.stdout_text) |