1#!/usr/bin/env python3
2#
3# Boot a Linux kernel on a r2d sh4eb machine and check the console
4#
5# SPDX-License-Identifier: GPL-2.0-or-later
6
7import os
8import shutil
9
10from qemu_test import LinuxKernelTest, Asset
11from qemu_test import exec_command_and_wait_for_pattern
12from qemu_test.utils import archive_extract
13from unittest import skipUnless
14
15class R2dEBTest(LinuxKernelTest):
16
17    ASSET_TGZ = Asset(
18        'https://landley.net/bin/mkroot/0.8.11/sh4eb.tgz',
19        'be8c6cb5aef8406899dc5aa5e22b6aa45840eb886cdd3ced51555c10577ada2c')
20
21    def test_sh4eb_r2d(self):
22        self.set_machine('r2d')
23        file_path = self.ASSET_TGZ.fetch()
24        archive_extract(file_path, self.workdir)
25        self.vm.add_args('-append', 'console=ttySC1 noiotrap')
26        self.launch_kernel(os.path.join(self.workdir, 'sh4eb/linux-kernel'),
27                           initrd=os.path.join(self.workdir, 'sh4eb/initramfs.cpio.gz'),
28                           console_index=1, wait_for='Type exit when done')
29        exec_command_and_wait_for_pattern(self, 'exit', 'Restarting system')
30        shutil.rmtree(os.path.join(self.workdir, 'sh4eb'))
31
32if __name__ == '__main__':
33    LinuxKernelTest.main()
34