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