1#!/usr/bin/env python3 2# 3# Test the bFLT loader format 4# 5# Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> 6# 7# SPDX-License-Identifier: GPL-2.0-or-later 8 9import os 10import bz2 11 12from qemu_test import QemuUserTest, Asset 13from qemu_test import skipIfMissingCommands, skipUntrustedTest 14from qemu_test.utils import cpio_extract 15 16 17class LoadBFLT(QemuUserTest): 18 19 ASSET_ROOTFS = Asset( 20 ('https://elinux.org/images/5/51/Stm32_mini_rootfs.cpio.bz2'), 21 'eefb788e4980c9e8d6c9d60ce7d15d4da6bf4fbc6a80f487673824600d5ba9cc') 22 23 @skipIfMissingCommands('cpio') 24 @skipUntrustedTest() 25 def test_stm32(self): 26 # See https://elinux.org/STM32#User_Space 27 rootfs_path_bz2 = self.ASSET_ROOTFS.fetch() 28 busybox_path = os.path.join(self.workdir, "bin/busybox") 29 30 with bz2.open(rootfs_path_bz2, 'rb') as cpio_handle: 31 cpio_extract(cpio_handle, self.workdir) 32 33 res = self.run_cmd(busybox_path) 34 ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.' 35 self.assertIn(ver, res.stdout) 36 37 res = self.run_cmd(busybox_path, ['uname', '-a']) 38 unm = 'armv7l GNU/Linux' 39 self.assertIn(unm, res.stdout) 40 41 42if __name__ == '__main__': 43 QemuUserTest.main() 44