xref: /openbmc/qemu/tests/functional/test_rx_gdbsim.py (revision bb6940dbad20a90515fd53f901b370251e7a25df)
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 unittest import skipUnless
16from qemu_test import QemuSystemTest, Asset
17from qemu_test import exec_command_and_wait_for_pattern
18from qemu_test import wait_for_console_pattern
19from qemu_test.utils import gzip_uncompress
20
21
22class RxGdbSimMachine(QemuSystemTest):
23
24    timeout = 30
25    KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
26
27    ASSET_UBOOT = Asset(
28        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
29         'u-boot.bin'),
30        'dd7dd4220cccf7aeb32227b26233bf39600db05c3f8e26005bcc2bf6c927207d')
31    ASSET_DTB = Asset(
32        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
33         'rx-gdbsim.dtb'),
34        'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a')
35    ASSET_KERNEL = Asset(
36        ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/'
37         'zImage'),
38        'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656')
39
40    def test_uboot(self):
41        """
42        U-Boot and checks that the console is operational.
43        """
44        self.set_machine('gdbsim-r5f562n8')
45
46        uboot_path = self.ASSET_UBOOT.fetch()
47
48        self.vm.set_console()
49        self.vm.add_args('-bios', uboot_path,
50                         '-no-reboot')
51        self.vm.launch()
52        uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty'
53        wait_for_console_pattern(self, uboot_version)
54        gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)'
55        # FIXME limit baudrate on chardev, else we type too fast
56        #exec_command_and_wait_for_pattern(self, 'version', gcc_version)
57
58    @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab')
59    def test_linux_sash(self):
60        """
61        Boots a Linux kernel and checks that the console is operational.
62        """
63        self.set_machine('gdbsim-r5f562n7')
64
65        dtb_path = self.ASSET_DTB.fetch()
66        kernel_path = self.ASSET_KERNEL.fetch()
67
68        self.vm.set_console()
69        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon'
70        self.vm.add_args('-kernel', kernel_path,
71                         '-dtb', dtb_path,
72                         '-no-reboot')
73        self.vm.launch()
74        wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)',
75                                 failure_message='Kernel panic - not syncing')
76        exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux')
77
78if __name__ == '__main__':
79    QemuSystemTest.main()
80