1#!/usr/bin/env python3
2#
3# Boot a Linux kernel on a r2d sh4 machine and check the console
4#
5# SPDX-License-Identifier: GPL-2.0-or-later
6
7import os
8
9from qemu_test import LinuxKernelTest, Asset
10from qemu_test.utils import archive_extract
11from unittest import skipUnless
12
13class R2dTest(LinuxKernelTest):
14
15    ASSET_DAY09 = Asset(
16        'https://www.qemu-advent-calendar.org/2018/download/day09.tar.xz',
17        'a61b44d2630a739d1380cc4ff4b80981d47ccfd5992f1484ccf48322c35f09ac')
18
19    # This test has a 6-10% failure rate on various hosts that look
20    # like issues with a buggy kernel.
21    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable')
22    def test_r2d(self):
23        self.set_machine('r2d')
24        file_path = self.ASSET_DAY09.fetch()
25        archive_extract(file_path, self.workdir)
26        self.vm.add_args('-append', 'console=ttySC1')
27        self.launch_kernel(self.workdir + '/day09/zImage', console_index=1,
28                           wait_for='QEMU advent calendar')
29
30if __name__ == '__main__':
31    LinuxKernelTest.main()
32