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 16from qemu_test.utils import gzip_uncompress 17 18 19class RxGdbSimMachine(QemuSystemTest): 20 21 timeout = 30 22 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' 23 24 ASSET_UBOOT = Asset( 25 'https://acc.dl.osdn.jp/users/23/23888/u-boot.bin.gz', 26 '7146567d669e91dbac166384b29aeba1715beb844c8551e904b86831bfd9d046') 27 ASSET_DTB = Asset( 28 'https://acc.dl.osdn.jp/users/23/23887/rx-virt.dtb', 29 'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a') 30 ASSET_KERNEL = Asset( 31 'http://acc.dl.osdn.jp/users/23/23845/zImage', 32 'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656') 33 34 def test_uboot(self): 35 """ 36 U-Boot and checks that the console is operational. 37 """ 38 self.set_machine('gdbsim-r5f562n8') 39 40 uboot_path_gz = self.ASSET_UBOOT.fetch() 41 uboot_path = self.scratch_file('u-boot.bin') 42 gzip_uncompress(uboot_path_gz, uboot_path) 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