1#!/usr/bin/env python3 2# 3# Functional tests for the little-endian 32-bit MIPS Malta board 4# 5# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org> 6# 7# SPDX-License-Identifier: GPL-2.0-or-later 8 9from qemu_test import LinuxKernelTest, Asset 10from qemu_test import exec_command_and_wait_for_pattern 11from qemu_test.utils import gzip_uncompress 12 13 14class MaltaMachineConsole(LinuxKernelTest): 15 16 ASSET_KERNEL_2_63_2 = Asset( 17 ('http://snapshot.debian.org/archive/debian/' 18 '20130217T032700Z/pool/main/l/linux-2.6/' 19 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb'), 20 '16ca524148afb0626f483163e5edf352bc1ab0e4fc7b9f9d473252762f2c7a43') 21 22 def test_mips_malta(self): 23 kernel_path = self.archive_extract( 24 self.ASSET_KERNEL_2_63_2, 25 member='boot/vmlinux-2.6.32-5-4kc-malta') 26 27 self.set_machine('malta') 28 self.vm.set_console() 29 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 30 self.vm.add_args('-kernel', kernel_path, 31 '-append', kernel_command_line) 32 self.vm.launch() 33 console_pattern = 'Kernel command line: %s' % kernel_command_line 34 self.wait_for_console_pattern(console_pattern) 35 36 ASSET_KERNEL_4_5_0 = Asset( 37 ('http://snapshot.debian.org/archive/debian/' 38 '20160601T041800Z/pool/main/l/linux/' 39 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb'), 40 '526b17d5889840888b76fc2c36a0ebde182c9b1410a3a1e68203c3b160eb2027') 41 42 ASSET_INITRD = Asset( 43 ('https://github.com/groeck/linux-build-test/raw/' 44 '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' 45 'mips/rootfs.cpio.gz'), 46 'dcfe3a7fe3200da3a00d176b95caaa086495eb158f2bff64afc67d7e1eb2cddc') 47 48 def test_mips_malta_cpio(self): 49 kernel_path = self.archive_extract( 50 self.ASSET_KERNEL_4_5_0, 51 member='boot/vmlinux-4.5.0-2-4kc-malta') 52 initrd_path_gz = self.ASSET_INITRD.fetch() 53 initrd_path = self.scratch_file('rootfs.cpio') 54 gzip_uncompress(initrd_path_gz, initrd_path) 55 56 self.set_machine('malta') 57 self.vm.set_console() 58 kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE 59 + 'console=ttyS0 console=tty ' 60 + 'rdinit=/sbin/init noreboot') 61 self.vm.add_args('-kernel', kernel_path, 62 '-initrd', initrd_path, 63 '-append', kernel_command_line, 64 '-no-reboot') 65 self.vm.launch() 66 self.wait_for_console_pattern('Boot successful.') 67 68 exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 69 'BogoMIPS') 70 exec_command_and_wait_for_pattern(self, 'uname -a', 71 'Debian') 72 exec_command_and_wait_for_pattern(self, 'reboot', 73 'reboot: Restarting system') 74 # Wait for VM to shut down gracefully 75 self.vm.wait() 76 77 78if __name__ == '__main__': 79 LinuxKernelTest.main() 80