xref: /qemu/tests/functional/test_rx_gdbsim.py (revision 9132fff802431438a2805389e74402321fb9afed)
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
13import os
14
15from qemu_test import QemuSystemTest, Asset
16from qemu_test import exec_command_and_wait_for_pattern
17from qemu_test import wait_for_console_pattern, skipFlakyTest
18from qemu_test.utils import gzip_uncompress
19
20
21class RxGdbSimMachine(QemuSystemTest):
22
23    timeout = 30
24    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
25
26    ASSET_UBOOT = Asset(
27        'https://acc.dl.osdn.jp/users/23/23888/u-boot.bin.gz',
28        '7146567d669e91dbac166384b29aeba1715beb844c8551e904b86831bfd9d046')
29    ASSET_DTB = Asset(
30        'https://acc.dl.osdn.jp/users/23/23887/rx-virt.dtb',
31        'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a')
32    ASSET_KERNEL = Asset(
33        'http://acc.dl.osdn.jp/users/23/23845/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_gz = self.ASSET_UBOOT.fetch()
43        uboot_path = os.path.join(self.workdir, 'u-boot.bin')
44        gzip_uncompress(uboot_path_gz, uboot_path)
45
46        self.vm.set_console()
47        self.vm.add_args('-bios', uboot_path,
48                         '-no-reboot')
49        self.vm.launch()
50        uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty'
51        wait_for_console_pattern(self, uboot_version)
52        gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)'
53        # FIXME limit baudrate on chardev, else we type too fast
54        #  https://gitlab.com/qemu-project/qemu/-/issues/2691
55        #exec_command_and_wait_for_pattern(self, 'version', gcc_version)
56
57    @skipFlakyTest(bug_url="https://gitlab.com/qemu-project/qemu/-/issues/2691")
58    def test_linux_sash(self):
59        """
60        Boots a Linux kernel and checks that the console is operational.
61        """
62        self.set_machine('gdbsim-r5f562n7')
63
64        dtb_path = self.ASSET_DTB.fetch()
65        kernel_path = self.ASSET_KERNEL.fetch()
66
67        self.vm.set_console()
68        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon'
69        self.vm.add_args('-kernel', kernel_path,
70                         '-dtb', dtb_path,
71                         '-no-reboot')
72        self.vm.launch()
73        wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)',
74                                 failure_message='Kernel panic - not syncing')
75        exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux')
76
77if __name__ == '__main__':
78    QemuSystemTest.main()
79