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