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 Huthfrom qemu_test import QemuSystemTest, Asset 14d5674412SThomas Huthfrom qemu_test import exec_command_and_wait_for_pattern 153d593860SDaniel P. Berrangéfrom qemu_test import wait_for_console_pattern, skipFlakyTest 16d5674412SThomas Huth 17d5674412SThomas Huth 18d5674412SThomas Huthclass RxGdbSimMachine(QemuSystemTest): 19d5674412SThomas Huth 20d5674412SThomas Huth timeout = 30 21d5674412SThomas Huth KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' 22d5674412SThomas Huth 23d5674412SThomas Huth ASSET_UBOOT = Asset( 24*ec2dfb7cSPhilippe Mathieu-Daudé ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' 25*ec2dfb7cSPhilippe Mathieu-Daudé 'u-boot.bin'), 26*ec2dfb7cSPhilippe Mathieu-Daudé 'dd7dd4220cccf7aeb32227b26233bf39600db05c3f8e26005bcc2bf6c927207d') 27d5674412SThomas Huth ASSET_DTB = Asset( 28*ec2dfb7cSPhilippe Mathieu-Daudé ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' 29*ec2dfb7cSPhilippe Mathieu-Daudé 'rx-gdbsim.dtb'), 30d5674412SThomas Huth 'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a') 31d5674412SThomas Huth ASSET_KERNEL = Asset( 32*ec2dfb7cSPhilippe Mathieu-Daudé ('https://github.com/philmd/qemu-testing-blob/raw/rx-gdbsim/rx/gdbsim/' 33*ec2dfb7cSPhilippe Mathieu-Daudé 'zImage'), 34d5674412SThomas Huth 'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656') 35d5674412SThomas Huth 36d5674412SThomas Huth def test_uboot(self): 37d5674412SThomas Huth """ 38d5674412SThomas Huth U-Boot and checks that the console is operational. 39d5674412SThomas Huth """ 40d5674412SThomas Huth self.set_machine('gdbsim-r5f562n8') 41d5674412SThomas Huth 42*ec2dfb7cSPhilippe Mathieu-Daudé uboot_path = self.ASSET_UBOOT.fetch() 43d5674412SThomas Huth 44d5674412SThomas Huth self.vm.set_console() 45d5674412SThomas Huth self.vm.add_args('-bios', uboot_path, 46d5674412SThomas Huth '-no-reboot') 47d5674412SThomas Huth self.vm.launch() 48d5674412SThomas Huth uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty' 49d5674412SThomas Huth wait_for_console_pattern(self, uboot_version) 50d5674412SThomas Huth gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)' 51d5674412SThomas Huth # FIXME limit baudrate on chardev, else we type too fast 523d593860SDaniel P. Berrangé # https://gitlab.com/qemu-project/qemu/-/issues/2691 53d5674412SThomas Huth #exec_command_and_wait_for_pattern(self, 'version', gcc_version) 54d5674412SThomas Huth 553d593860SDaniel P. Berrangé @skipFlakyTest(bug_url="https://gitlab.com/qemu-project/qemu/-/issues/2691") 56d5674412SThomas Huth def test_linux_sash(self): 57d5674412SThomas Huth """ 58d5674412SThomas Huth Boots a Linux kernel and checks that the console is operational. 59d5674412SThomas Huth """ 60d5674412SThomas Huth self.set_machine('gdbsim-r5f562n7') 61d5674412SThomas Huth 62d5674412SThomas Huth dtb_path = self.ASSET_DTB.fetch() 63d5674412SThomas Huth kernel_path = self.ASSET_KERNEL.fetch() 64d5674412SThomas Huth 65d5674412SThomas Huth self.vm.set_console() 66d5674412SThomas Huth kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon' 67d5674412SThomas Huth self.vm.add_args('-kernel', kernel_path, 68d5674412SThomas Huth '-dtb', dtb_path, 69d5674412SThomas Huth '-no-reboot') 70d5674412SThomas Huth self.vm.launch() 71d5674412SThomas Huth wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)', 72d5674412SThomas Huth failure_message='Kernel panic - not syncing') 73d5674412SThomas Huth exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux') 74d5674412SThomas Huth 75d5674412SThomas Huthif __name__ == '__main__': 76d5674412SThomas Huth QemuSystemTest.main() 77