xref: /qemu/tests/functional/test_arm_bflt.py (revision ba182a693fe15a4f6f2a04e8ecb865c2630e5a16)
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 bz2
1034917eadSPhilippe Mathieu-Daudé
1134917eadSPhilippe Mathieu-Daudéfrom qemu_test import QemuUserTest, Asset
123d593860SDaniel P. Berrangéfrom qemu_test import skipIfMissingCommands, skipUntrustedTest
1334917eadSPhilippe Mathieu-Daudé
1434917eadSPhilippe Mathieu-Daudé
1534917eadSPhilippe Mathieu-Daudéclass LoadBFLT(QemuUserTest):
1634917eadSPhilippe Mathieu-Daudé
1734917eadSPhilippe Mathieu-Daudé    ASSET_ROOTFS = Asset(
1834917eadSPhilippe Mathieu-Daudé        ('https://elinux.org/images/5/51/Stm32_mini_rootfs.cpio.bz2'),
1934917eadSPhilippe Mathieu-Daudé         'eefb788e4980c9e8d6c9d60ce7d15d4da6bf4fbc6a80f487673824600d5ba9cc')
2034917eadSPhilippe Mathieu-Daudé
213d593860SDaniel P. Berrangé    @skipIfMissingCommands('cpio')
223d593860SDaniel P. Berrangé    @skipUntrustedTest()
2334917eadSPhilippe Mathieu-Daudé    def test_stm32(self):
2434917eadSPhilippe Mathieu-Daudé        # See https://elinux.org/STM32#User_Space
2534917eadSPhilippe Mathieu-Daudé        rootfs_path_bz2 = self.ASSET_ROOTFS.fetch()
26beaf88c8SDaniel P. Berrangé        busybox_path = self.scratch_file("bin", "busybox")
2734917eadSPhilippe Mathieu-Daudé
2834917eadSPhilippe Mathieu-Daudé        with bz2.open(rootfs_path_bz2, 'rb') as cpio_handle:
29*5831ed84SDaniel P. Berrangé            self.archive_extract(cpio_handle, format="cpio")
3034917eadSPhilippe Mathieu-Daudé
3134917eadSPhilippe Mathieu-Daudé        res = self.run_cmd(busybox_path)
3234917eadSPhilippe Mathieu-Daudé        ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.'
3334917eadSPhilippe Mathieu-Daudé        self.assertIn(ver, res.stdout)
3434917eadSPhilippe Mathieu-Daudé
3534917eadSPhilippe Mathieu-Daudé        res = self.run_cmd(busybox_path, ['uname', '-a'])
3634917eadSPhilippe Mathieu-Daudé        unm = 'armv7l GNU/Linux'
3734917eadSPhilippe Mathieu-Daudé        self.assertIn(unm, res.stdout)
3834917eadSPhilippe Mathieu-Daudé
3934917eadSPhilippe Mathieu-Daudé
4034917eadSPhilippe Mathieu-Daudéif __name__ == '__main__':
4134917eadSPhilippe Mathieu-Daudé    QemuUserTest.main()
42