xref: /qemu/tests/functional/test_arm_bflt.py (revision 3d5938607e05c4f8ac6df046a92fad19b681c23b)
134917eadSPhilippe Mathieu-Daudé#!/usr/bin/env python3
234917eadSPhilippe Mathieu-Daudé#
334917eadSPhilippe Mathieu-Daudé# Test the bFLT loader format
434917eadSPhilippe Mathieu-Daudé#
534917eadSPhilippe Mathieu-Daudé# Copyright (C) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org>
634917eadSPhilippe Mathieu-Daudé#
734917eadSPhilippe Mathieu-Daudé# SPDX-License-Identifier: GPL-2.0-or-later
834917eadSPhilippe Mathieu-Daudé
934917eadSPhilippe Mathieu-Daudéimport os
1034917eadSPhilippe Mathieu-Daudéimport bz2
1134917eadSPhilippe Mathieu-Daudé
1234917eadSPhilippe Mathieu-Daudéfrom qemu_test import QemuUserTest, Asset
13*3d593860SDaniel P. Berrangéfrom qemu_test import skipIfMissingCommands, skipUntrustedTest
1434917eadSPhilippe Mathieu-Daudéfrom qemu_test.utils import cpio_extract
1534917eadSPhilippe Mathieu-Daudé
1634917eadSPhilippe Mathieu-Daudé
1734917eadSPhilippe Mathieu-Daudéclass LoadBFLT(QemuUserTest):
1834917eadSPhilippe Mathieu-Daudé
1934917eadSPhilippe Mathieu-Daudé    ASSET_ROOTFS = Asset(
2034917eadSPhilippe Mathieu-Daudé        ('https://elinux.org/images/5/51/Stm32_mini_rootfs.cpio.bz2'),
2134917eadSPhilippe Mathieu-Daudé         'eefb788e4980c9e8d6c9d60ce7d15d4da6bf4fbc6a80f487673824600d5ba9cc')
2234917eadSPhilippe Mathieu-Daudé
23*3d593860SDaniel P. Berrangé    @skipIfMissingCommands('cpio')
24*3d593860SDaniel P. Berrangé    @skipUntrustedTest()
2534917eadSPhilippe Mathieu-Daudé    def test_stm32(self):
2634917eadSPhilippe Mathieu-Daudé        # See https://elinux.org/STM32#User_Space
2734917eadSPhilippe Mathieu-Daudé        rootfs_path_bz2 = self.ASSET_ROOTFS.fetch()
2834917eadSPhilippe Mathieu-Daudé        busybox_path = os.path.join(self.workdir, "bin/busybox")
2934917eadSPhilippe Mathieu-Daudé
3034917eadSPhilippe Mathieu-Daudé        with bz2.open(rootfs_path_bz2, 'rb') as cpio_handle:
3134917eadSPhilippe Mathieu-Daudé            cpio_extract(cpio_handle, self.workdir)
3234917eadSPhilippe Mathieu-Daudé
3334917eadSPhilippe Mathieu-Daudé        res = self.run_cmd(busybox_path)
3434917eadSPhilippe Mathieu-Daudé        ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
3534917eadSPhilippe Mathieu-Daudé        self.assertIn(ver, res.stdout)
3634917eadSPhilippe Mathieu-Daudé
3734917eadSPhilippe Mathieu-Daudé        res = self.run_cmd(busybox_path, ['uname', '-a'])
3834917eadSPhilippe Mathieu-Daudé        unm = 'armv7l GNU/Linux'
3934917eadSPhilippe Mathieu-Daudé        self.assertIn(unm, res.stdout)
4034917eadSPhilippe Mathieu-Daudé
4134917eadSPhilippe Mathieu-Daudé
4234917eadSPhilippe Mathieu-Daudéif __name__ == '__main__':
4334917eadSPhilippe Mathieu-Daudé    QemuUserTest.main()
44