xref: /qemu/tests/functional/test_rx_gdbsim.py (revision 1ada452efc7d8f8bf42cd5e8a2af1b4ac9167a1f)
1#!/usr/bin/env python3
2#
3# Functional test that boots a Linux kernel and checks the console
4#
5# Copyright (c) 2018 Red Hat, Inc.
6#
7# Author:
8#  Cleber Rosa <crosa@redhat.com>
9#
10# This work is licensed under the terms of the GNU GPL, version 2 or
11# later.  See the COPYING file in the top-level directory.
12
13from qemu_test import QemuSystemTest, Asset
14from qemu_test import exec_command_and_wait_for_pattern
15from qemu_test import wait_for_console_pattern, skipFlakyTest
16
17
18class RxGdbSimMachine(QemuSystemTest):
19
20    timeout = 30
21    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
22
23    ASSET_UBOOT = Asset(
24        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
25         'u-boot.bin'),
26        'dd7dd4220cccf7aeb32227b26233bf39600db05c3f8e26005bcc2bf6c927207d')
27    ASSET_DTB = Asset(
28        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
29         'rx-gdbsim.dtb'),
30        'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a')
31    ASSET_KERNEL = Asset(
32        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
33         'zImage'),
34        'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656')
35
36    def test_uboot(self):
37        """
38        U-Boot and checks that the console is operational.
39        """
40        self.set_machine('gdbsim-r5f562n8')
41
42        uboot_path = self.ASSET_UBOOT.fetch()
43
44        self.vm.set_console()
45        self.vm.add_args('-bios', uboot_path,
46                         '-no-reboot')
47        self.vm.launch()
48        uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty'
49        wait_for_console_pattern(self, uboot_version)
50        gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)'
51        # FIXME limit baudrate on chardev, else we type too fast
52        #  https://gitlab.com/qemu-project/qemu/-/issues/2691
53        #exec_command_and_wait_for_pattern(self, 'version', gcc_version)
54
55    @skipFlakyTest(bug_url="https://gitlab.com/qemu-project/qemu/-/issues/2691")
56    def test_linux_sash(self):
57        """
58        Boots a Linux kernel and checks that the console is operational.
59        """
60        self.set_machine('gdbsim-r5f562n7')
61
62        dtb_path = self.ASSET_DTB.fetch()
63        kernel_path = self.ASSET_KERNEL.fetch()
64
65        self.vm.set_console()
66        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon'
67        self.vm.add_args('-kernel', kernel_path,
68                         '-dtb', dtb_path,
69                         '-no-reboot')
70        self.vm.launch()
71        wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)',
72                                 failure_message='Kernel panic - not syncing')
73        exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux')
74
75if __name__ == '__main__':
76    QemuSystemTest.main()
77