179cb4a14SPhilippe Mathieu-Daudé#!/usr/bin/env python3 279cb4a14SPhilippe Mathieu-Daudé# 3c8b2deb9SThomas Huth# Functional tests for the big-endian 32-bit MIPS Malta board 479cb4a14SPhilippe Mathieu-Daudé# 579cb4a14SPhilippe Mathieu-Daudé# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org> 679cb4a14SPhilippe Mathieu-Daudé# 779cb4a14SPhilippe Mathieu-Daudé# SPDX-License-Identifier: GPL-2.0-or-later 879cb4a14SPhilippe Mathieu-Daudé 979cb4a14SPhilippe Mathieu-Daudéfrom qemu_test import LinuxKernelTest, Asset 1079cb4a14SPhilippe Mathieu-Daudéfrom qemu_test import exec_command_and_wait_for_pattern 1179cb4a14SPhilippe Mathieu-Daudé 1279cb4a14SPhilippe Mathieu-Daudé 1379cb4a14SPhilippe Mathieu-Daudéclass MaltaMachineConsole(LinuxKernelTest): 1479cb4a14SPhilippe Mathieu-Daudé 1579cb4a14SPhilippe Mathieu-Daudé ASSET_KERNEL_2_63_2 = Asset( 1679cb4a14SPhilippe Mathieu-Daudé ('http://snapshot.debian.org/archive/debian/' 1779cb4a14SPhilippe Mathieu-Daudé '20130217T032700Z/pool/main/l/linux-2.6/' 1879cb4a14SPhilippe Mathieu-Daudé 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb'), 1979cb4a14SPhilippe Mathieu-Daudé '16ca524148afb0626f483163e5edf352bc1ab0e4fc7b9f9d473252762f2c7a43') 2079cb4a14SPhilippe Mathieu-Daudé 2179cb4a14SPhilippe Mathieu-Daudé def test_mips_malta(self): 225831ed84SDaniel P. Berrangé kernel_path = self.archive_extract( 235831ed84SDaniel P. Berrangé self.ASSET_KERNEL_2_63_2, 245831ed84SDaniel P. Berrangé member='boot/vmlinux-2.6.32-5-4kc-malta') 2579cb4a14SPhilippe Mathieu-Daudé 2679cb4a14SPhilippe Mathieu-Daudé self.set_machine('malta') 2779cb4a14SPhilippe Mathieu-Daudé self.vm.set_console() 2879cb4a14SPhilippe Mathieu-Daudé kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 2979cb4a14SPhilippe Mathieu-Daudé self.vm.add_args('-kernel', kernel_path, 3079cb4a14SPhilippe Mathieu-Daudé '-append', kernel_command_line) 3179cb4a14SPhilippe Mathieu-Daudé self.vm.launch() 3279cb4a14SPhilippe Mathieu-Daudé console_pattern = 'Kernel command line: %s' % kernel_command_line 3379cb4a14SPhilippe Mathieu-Daudé self.wait_for_console_pattern(console_pattern) 3479cb4a14SPhilippe Mathieu-Daudé 3579cb4a14SPhilippe Mathieu-Daudé ASSET_KERNEL_4_5_0 = Asset( 3679cb4a14SPhilippe Mathieu-Daudé ('http://snapshot.debian.org/archive/debian/' 3779cb4a14SPhilippe Mathieu-Daudé '20160601T041800Z/pool/main/l/linux/' 3879cb4a14SPhilippe Mathieu-Daudé 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb'), 3979cb4a14SPhilippe Mathieu-Daudé '526b17d5889840888b76fc2c36a0ebde182c9b1410a3a1e68203c3b160eb2027') 4079cb4a14SPhilippe Mathieu-Daudé 4179cb4a14SPhilippe Mathieu-Daudé ASSET_INITRD = Asset( 4279cb4a14SPhilippe Mathieu-Daudé ('https://github.com/groeck/linux-build-test/raw/' 4379cb4a14SPhilippe Mathieu-Daudé '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' 4479cb4a14SPhilippe Mathieu-Daudé 'mips/rootfs.cpio.gz'), 4579cb4a14SPhilippe Mathieu-Daudé 'dcfe3a7fe3200da3a00d176b95caaa086495eb158f2bff64afc67d7e1eb2cddc') 4679cb4a14SPhilippe Mathieu-Daudé 4779cb4a14SPhilippe Mathieu-Daudé def test_mips_malta_cpio(self): 48*7b7f98efSThomas Huth self.require_netdev('user') 49*7b7f98efSThomas Huth self.set_machine('malta') 50*7b7f98efSThomas Huth self.require_device('pcnet') 51*7b7f98efSThomas Huth 525831ed84SDaniel P. Berrangé kernel_path = self.archive_extract( 535831ed84SDaniel P. Berrangé self.ASSET_KERNEL_4_5_0, 545831ed84SDaniel P. Berrangé member='boot/vmlinux-4.5.0-2-4kc-malta') 5565d35a4eSDaniel P. Berrangé initrd_path = self.uncompress(self.ASSET_INITRD) 5679cb4a14SPhilippe Mathieu-Daudé 5779cb4a14SPhilippe Mathieu-Daudé self.vm.set_console() 5879cb4a14SPhilippe Mathieu-Daudé kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE 5979cb4a14SPhilippe Mathieu-Daudé + 'console=ttyS0 console=tty ' 6079cb4a14SPhilippe Mathieu-Daudé + 'rdinit=/sbin/init noreboot') 6179cb4a14SPhilippe Mathieu-Daudé self.vm.add_args('-kernel', kernel_path, 6279cb4a14SPhilippe Mathieu-Daudé '-initrd', initrd_path, 6379cb4a14SPhilippe Mathieu-Daudé '-append', kernel_command_line, 64*7b7f98efSThomas Huth '-netdev', 'user,id=n1,tftp=' + self.scratch_file('boot'), 65*7b7f98efSThomas Huth '-device', 'pcnet,netdev=n1', 6679cb4a14SPhilippe Mathieu-Daudé '-no-reboot') 6779cb4a14SPhilippe Mathieu-Daudé self.vm.launch() 6879cb4a14SPhilippe Mathieu-Daudé self.wait_for_console_pattern('Boot successful.') 6979cb4a14SPhilippe Mathieu-Daudé 7079cb4a14SPhilippe Mathieu-Daudé exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 7179cb4a14SPhilippe Mathieu-Daudé 'BogoMIPS') 7279cb4a14SPhilippe Mathieu-Daudé exec_command_and_wait_for_pattern(self, 'uname -a', 7379cb4a14SPhilippe Mathieu-Daudé 'Debian') 74*7b7f98efSThomas Huth 75*7b7f98efSThomas Huth exec_command_and_wait_for_pattern(self, 'ip link set eth0 up', 76*7b7f98efSThomas Huth 'eth0: link up') 77*7b7f98efSThomas Huth exec_command_and_wait_for_pattern(self, 78*7b7f98efSThomas Huth 'ip addr add 10.0.2.15 dev eth0', 79*7b7f98efSThomas Huth '#') 80*7b7f98efSThomas Huth exec_command_and_wait_for_pattern(self, 'route add default eth0', '#') 81*7b7f98efSThomas Huth exec_command_and_wait_for_pattern(self, 82*7b7f98efSThomas Huth 'tftp -g -r vmlinux-4.5.0-2-4kc-malta 10.0.2.2', '#') 83*7b7f98efSThomas Huth exec_command_and_wait_for_pattern(self, 84*7b7f98efSThomas Huth 'md5sum vmlinux-4.5.0-2-4kc-malta', 85*7b7f98efSThomas Huth 'a98218a7efbdefb2dfdf9ecd08c98318') 86*7b7f98efSThomas Huth 8779cb4a14SPhilippe Mathieu-Daudé exec_command_and_wait_for_pattern(self, 'reboot', 8879cb4a14SPhilippe Mathieu-Daudé 'reboot: Restarting system') 8979cb4a14SPhilippe Mathieu-Daudé # Wait for VM to shut down gracefully 9079cb4a14SPhilippe Mathieu-Daudé self.vm.wait() 9179cb4a14SPhilippe Mathieu-Daudé 9279cb4a14SPhilippe Mathieu-Daudé 9379cb4a14SPhilippe Mathieu-Daudéif __name__ == '__main__': 9479cb4a14SPhilippe Mathieu-Daudé LinuxKernelTest.main() 95