1*16a9b550SThomas Huth#!/usr/bin/env python3 2*16a9b550SThomas Huth# 3*16a9b550SThomas Huth# Functional test that boots a Linux kernel on a realview arm machine 4*16a9b550SThomas Huth# and checks the console 5*16a9b550SThomas Huth# 6*16a9b550SThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later 7*16a9b550SThomas Huth 8*16a9b550SThomas Huthfrom qemu_test import LinuxKernelTest, exec_command_and_wait_for_pattern 9*16a9b550SThomas Huthfrom qemu_test import Asset 10*16a9b550SThomas Huth 11*16a9b550SThomas Huth 12*16a9b550SThomas Huthclass RealviewMachine(LinuxKernelTest): 13*16a9b550SThomas Huth 14*16a9b550SThomas Huth ASSET_REALVIEW_MPCORE = Asset( 15*16a9b550SThomas Huth ('https://archive.openwrt.org/chaos_calmer/15.05.1/realview/generic/' 16*16a9b550SThomas Huth 'openwrt-15.05.1-realview-vmlinux-initramfs.elf'), 17*16a9b550SThomas Huth 'd3a01037f33e7512d46d50975588d5c3a0e0cbf25f37afab44775c2a2be523e6') 18*16a9b550SThomas Huth 19*16a9b550SThomas Huth def test_realview_ep_mpcore(self): 20*16a9b550SThomas Huth self.require_netdev('user') 21*16a9b550SThomas Huth self.set_machine('realview-eb-mpcore') 22*16a9b550SThomas Huth kernel_path = self.ASSET_REALVIEW_MPCORE.fetch() 23*16a9b550SThomas Huth self.vm.set_console() 24*16a9b550SThomas Huth kernel_param = 'console=ttyAMA0 mem=128M quiet' 25*16a9b550SThomas Huth self.vm.add_args('-kernel', kernel_path, 26*16a9b550SThomas Huth '-append', kernel_param) 27*16a9b550SThomas Huth self.vm.launch() 28*16a9b550SThomas Huth self.wait_for_console_pattern('Please press Enter to activate') 29*16a9b550SThomas Huth prompt = ':/#' 30*16a9b550SThomas Huth exec_command_and_wait_for_pattern(self, '', prompt) 31*16a9b550SThomas Huth exec_command_and_wait_for_pattern(self, 'dmesg', kernel_param) 32*16a9b550SThomas Huth self.wait_for_console_pattern(prompt) 33*16a9b550SThomas Huth exec_command_and_wait_for_pattern(self, 34*16a9b550SThomas Huth ('while ! dmesg | grep "br-lan: port 1(eth0) entered" ;' 35*16a9b550SThomas Huth ' do sleep 1 ; done'), 36*16a9b550SThomas Huth 'entered forwarding state') 37*16a9b550SThomas Huth self.wait_for_console_pattern(prompt) 38*16a9b550SThomas Huth exec_command_and_wait_for_pattern(self, 39*16a9b550SThomas Huth 'while ! ifconfig | grep "10.0.2.15" ; do sleep 1 ; done', 40*16a9b550SThomas Huth 'addr:10.0.2.15') 41*16a9b550SThomas Huth self.wait_for_console_pattern(prompt) 42*16a9b550SThomas Huth exec_command_and_wait_for_pattern(self, 'ping -c 1 10.0.2.2', 43*16a9b550SThomas Huth '1 packets received, 0% packet loss') 44*16a9b550SThomas Huth 45*16a9b550SThomas Huth 46*16a9b550SThomas Huthif __name__ == '__main__': 47*16a9b550SThomas Huth LinuxKernelTest.main() 48