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
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
):
20 Extracts a cpio archive into the test workdir
22 :param cpio_path: path to the cpio archive
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
)
31 @skipUnless(*has_cmd('cpio'))
32 @skipUnless(os
.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code')
35 :avocado: tags=arch:arm
36 :avocado: tags=linux_user
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
)