xref: /qemu/tests/functional/test_mips_malta.py (revision 897c68fb795cf03b89b6688a6f945d68a765c3e4)
1#!/usr/bin/env python3
2#
3# Functional tests for the big-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
11
12
13class MaltaMachineConsole(LinuxKernelTest):
14
15    ASSET_KERNEL_2_63_2 = Asset(
16        ('http://snapshot.debian.org/archive/debian/'
17         '20130217T032700Z/pool/main/l/linux-2.6/'
18         'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb'),
19        '16ca524148afb0626f483163e5edf352bc1ab0e4fc7b9f9d473252762f2c7a43')
20
21    def test_mips_malta(self):
22        kernel_path = self.archive_extract(
23            self.ASSET_KERNEL_2_63_2,
24            member='boot/vmlinux-2.6.32-5-4kc-malta')
25
26        self.set_machine('malta')
27        self.vm.set_console()
28        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0'
29        self.vm.add_args('-kernel', kernel_path,
30                         '-append', kernel_command_line)
31        self.vm.launch()
32        console_pattern = 'Kernel command line: %s' % kernel_command_line
33        self.wait_for_console_pattern(console_pattern)
34
35    ASSET_KERNEL_4_5_0 = Asset(
36        ('http://snapshot.debian.org/archive/debian/'
37         '20160601T041800Z/pool/main/l/linux/'
38         'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb'),
39        '526b17d5889840888b76fc2c36a0ebde182c9b1410a3a1e68203c3b160eb2027')
40
41    ASSET_INITRD = Asset(
42        ('https://github.com/groeck/linux-build-test/raw/'
43         '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/'
44         'mips/rootfs.cpio.gz'),
45        'dcfe3a7fe3200da3a00d176b95caaa086495eb158f2bff64afc67d7e1eb2cddc')
46
47    def test_mips_malta_cpio(self):
48        self.require_netdev('user')
49        self.set_machine('malta')
50        self.require_device('pcnet')
51
52        kernel_path = self.archive_extract(
53            self.ASSET_KERNEL_4_5_0,
54            member='boot/vmlinux-4.5.0-2-4kc-malta')
55        initrd_path = self.uncompress(self.ASSET_INITRD)
56
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                         '-netdev', 'user,id=n1,tftp=' + self.scratch_file('boot'),
65                         '-device', 'pcnet,netdev=n1',
66                         '-no-reboot')
67        self.vm.launch()
68        self.wait_for_console_pattern('Boot successful.')
69
70        exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
71                                                'BogoMIPS')
72        exec_command_and_wait_for_pattern(self, 'uname -a',
73                                                'Debian')
74
75        exec_command_and_wait_for_pattern(self, 'ip link set eth0 up',
76                                          'eth0: link up')
77        exec_command_and_wait_for_pattern(self,
78                                          'ip addr add 10.0.2.15 dev eth0',
79                                          '#')
80        exec_command_and_wait_for_pattern(self, 'route add default eth0', '#')
81        exec_command_and_wait_for_pattern(self,
82                         'tftp -g -r vmlinux-4.5.0-2-4kc-malta 10.0.2.2', '#')
83        exec_command_and_wait_for_pattern(self,
84                                          'md5sum vmlinux-4.5.0-2-4kc-malta',
85                                          'a98218a7efbdefb2dfdf9ecd08c98318')
86
87        exec_command_and_wait_for_pattern(self, 'reboot',
88                                                'reboot: Restarting system')
89        # Wait for VM to shut down gracefully
90        self.vm.wait()
91
92
93if __name__ == '__main__':
94    LinuxKernelTest.main()
95