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