xref: /openbmc/qemu/tests/functional/test_arm_bflt.py (revision beaf88c895a5eda649777757c80ab4171de777ff)
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 bz2
10
11from qemu_test import QemuUserTest, Asset
12from qemu_test import skipIfMissingCommands, skipUntrustedTest
13from qemu_test.utils import cpio_extract
14
15
16class LoadBFLT(QemuUserTest):
17
18    ASSET_ROOTFS = Asset(
19        ('https://elinux.org/images/5/51/Stm32_mini_rootfs.cpio.bz2'),
20         'eefb788e4980c9e8d6c9d60ce7d15d4da6bf4fbc6a80f487673824600d5ba9cc')
21
22    @skipIfMissingCommands('cpio')
23    @skipUntrustedTest()
24    def test_stm32(self):
25        # See https://elinux.org/STM32#User_Space
26        rootfs_path_bz2 = self.ASSET_ROOTFS.fetch()
27        busybox_path = self.scratch_file("bin", "busybox")
28
29        with bz2.open(rootfs_path_bz2, 'rb') as cpio_handle:
30            cpio_extract(cpio_handle, self.workdir)
31
32        res = self.run_cmd(busybox_path)
33        ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
34        self.assertIn(ver, res.stdout)
35
36        res = self.run_cmd(busybox_path, ['uname', '-a'])
37        unm = 'armv7l GNU/Linux'
38        self.assertIn(unm, res.stdout)
39
40
41if __name__ == '__main__':
42    QemuUserTest.main()
43