1#!/usr/bin/env python3 2# 3# Functional test that boots known good tuxboot images the same way 4# that tuxrun (www.tuxrun.org) does. This tool is used by things like 5# the LKFT project to run regression tests on kernels. 6# 7# Copyright (c) 2023 Linaro Ltd. 8# 9# Author: 10# Alex Bennée <alex.bennee@linaro.org> 11# 12# SPDX-License-Identifier: GPL-2.0-or-later 13 14import os 15import time 16 17from unittest import skipUnless 18from qemu_test import Asset, exec_command_and_wait_for_pattern, exec_command 19from qemu_test.tuxruntest import TuxRunBaselineTest 20 21class TuxRunSh4Test(TuxRunBaselineTest): 22 23 ASSET_SH4_KERNEL = Asset( 24 'https://storage.tuxboot.com/20230331/sh4/zImage', 25 '29d9b2aba604a0f53a5dc3b5d0f2b8e35d497de1129f8ee5139eb6fdf0db692f') 26 ASSET_SH4_ROOTFS = Asset( 27 'https://storage.tuxboot.com/20230331/sh4/rootfs.ext4.zst', 28 '3592a7a3d5a641e8b9821449e77bc43c9904a56c30d45da0694349cfd86743fd') 29 30 # Note: some segfaults caused by unaligned userspace access 31 @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable') 32 def test_sh4(self): 33 self.set_machine('r2d') 34 self.cpu='sh7785' 35 self.root='sda' 36 self.console='ttySC1' 37 38 # The test is currently too unstable to do much in userspace 39 # so we skip common_tuxrun and do a minimal boot and shutdown. 40 (kernel, disk, dtb) = self.fetch_tuxrun_assets(self.ASSET_SH4_KERNEL, 41 self.ASSET_SH4_ROOTFS) 42 43 # the console comes on the second serial port 44 self.prepare_run(kernel, disk, 45 "driver=ide-hd,bus=ide.0,unit=0", 46 console_index=1) 47 self.vm.launch() 48 49 self.wait_for_console_pattern("Welcome to TuxTest") 50 time.sleep(0.1) 51 exec_command(self, 'root') 52 time.sleep(0.1) 53 exec_command_and_wait_for_pattern(self, 'halt', 54 "reboot: System halted") 55 56if __name__ == '__main__': 57 TuxRunBaselineTest.main() 58