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://acc.dl.osdn.jp/users/23/23888/u-boot.bin.gz', 29 '7146567d669e91dbac166384b29aeba1715beb844c8551e904b86831bfd9d046') 30 ASSET_DTB = Asset( 31 'https://acc.dl.osdn.jp/users/23/23887/rx-virt.dtb', 32 'aa278d9c1907a4501741d7ee57e7f65c02dd1b3e0323b33c6d4247f1b32cf29a') 33 ASSET_KERNEL = Asset( 34 'http://acc.dl.osdn.jp/users/23/23845/zImage', 35 'baa43205e74a7220ed8482188c5e9ce497226712abb7f4e7e4f825ce19ff9656') 36 37 def test_uboot(self): 38 """ 39 U-Boot and checks that the console is operational. 40 """ 41 self.set_machine('gdbsim-r5f562n8') 42 43 uboot_path_gz = self.ASSET_UBOOT.fetch() 44 uboot_path = os.path.join(self.workdir, 'u-boot.bin') 45 gzip_uncompress(uboot_path_gz, uboot_path) 46 47 self.vm.set_console() 48 self.vm.add_args('-bios', uboot_path, 49 '-no-reboot') 50 self.vm.launch() 51 uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty' 52 wait_for_console_pattern(self, uboot_version) 53 gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)' 54 # FIXME limit baudrate on chardev, else we type too fast 55 #exec_command_and_wait_for_pattern(self, 'version', gcc_version) 56 57 @skipUnless(os.getenv('QEMU_TEST_FLAKY_TESTS'), 'Test is unstable on GitLab') 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