Merge tag 'migration-20240311-pull-request' of https://gitlab.com/peterx/qemu into...
[qemu/armbru.git] / tests / avocado / load_bflt.py
blobbb50cec1ee8415a2998edb35798520c54252049a
1 # Test the bFLT loader format
3 # Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
5 # SPDX-License-Identifier: GPL-2.0-or-later
7 import os
8 import bz2
9 import subprocess
11 from avocado import skipUnless
12 from avocado_qemu import QemuUserTest
13 from avocado_qemu import has_cmd
16 class LoadBFLT(QemuUserTest):
18 def extract_cpio(self, cpio_path):
19 """
20 Extracts a cpio archive into the test workdir
22 :param cpio_path: path to the cpio archive
23 """
24 cwd = os.getcwd()
25 os.chdir(self.workdir)
26 with bz2.open(cpio_path, 'rb') as archive_cpio:
27 subprocess.run(['cpio', '-i'], input=archive_cpio.read(),
28 stderr=subprocess.DEVNULL)
29 os.chdir(cwd)
31 @skipUnless(*has_cmd('cpio'))
32 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
33 def test_stm32(self):
34 """
35 :avocado: tags=arch:arm
36 :avocado: tags=linux_user
37 :avocado: tags=quick
38 """
39 # See https://elinux.org/STM32#User_Space
40 rootfs_url = ('https://elinux.org/images/5/51/'
41 'Stm32_mini_rootfs.cpio.bz2')
42 rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6'
43 rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash)
44 busybox_path = os.path.join(self.workdir, "/bin/busybox")
46 self.extract_cpio(rootfs_path_bz2)
48 res = self.run(busybox_path)
49 ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
50 self.assertIn(ver, res.stdout_text)
52 res = self.run(busybox_path, ['uname', '-a'])
53 unm = 'armv7l GNU/Linux'
54 self.assertIn(unm, res.stdout_text)