| 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é |
| 6 | # |
| 7 | # This work is licensed under the terms of the GNU GPL, version 2 or later. |
| 8 | # See the COPYING file in the top-level directory. |
| 9 | # |
| 10 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 11 | |
| 12 | from qemu_test import QemuSystemTest, LinuxKernelTest, Asset |
| 13 | from qemu_test import skipFlakyTest |
| 14 | from qemu_test import interrupt_interactive_console_until_pattern |
| 15 | from qemu_test import wait_for_console_pattern |
| 16 | |
| 17 | from mips.test_malta import mips_check_wheezy |
| 18 | |
| 19 | |
| 20 | class MaltaMachineConsole(LinuxKernelTest): |
| 21 | |
| 22 | ASSET_KERNEL_4K = Asset( |
| 23 | ('http://mipsdistros.mips.com/LinuxDistro/nanomips/' |
| 24 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 25 | 'generic_nano32r6el_page4k.xz'), |
| 26 | '019e034094ac6cf3aa77df5e130fb023ce4dbc804b04bfcc560c6403e1ae6bdb') |
| 27 | ASSET_KERNEL_16K = Asset( |
| 28 | ('http://mipsdistros.mips.com/LinuxDistro/nanomips/' |
| 29 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 30 | 'generic_nano32r6el_page16k_up.xz'), |
| 31 | '3a54a10b3108c16a448dca9ea3db378733a27423befc2a45a5bdf990bd85e12c') |
| 32 | ASSET_KERNEL_64K = Asset( |
| 33 | ('http://mipsdistros.mips.com/LinuxDistro/nanomips/' |
| 34 | 'kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/' |
| 35 | 'generic_nano32r6el_page64k_dbg.xz'), |
| 36 | 'ce21ff4b07a981ecb8a39db2876616f5a2473eb2ab459c6f67465b9914b0c6b6') |
| 37 | |
| 38 | def do_test_mips_malta32el_nanomips(self, kernel): |
| 39 | kernel_path = self.uncompress(kernel) |
| 40 | |
| 41 | self.set_machine('malta') |
| 42 | self.vm.set_console() |
| 43 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE |
| 44 | + 'mem=256m@@0x0 ' |
| 45 | + 'console=ttyS0') |
| 46 | self.vm.add_args('-cpu', 'I7200', |
| 47 | '-no-reboot', |
| 48 | '-kernel', kernel_path, |
| 49 | '-append', kernel_command_line) |
| 50 | self.vm.launch() |
| 51 | console_pattern = 'Kernel command line: %s' % kernel_command_line |
| 52 | self.wait_for_console_pattern(console_pattern) |
| 53 | |
| 54 | def test_mips_malta32el_nanomips_4k(self): |
| 55 | self.do_test_mips_malta32el_nanomips(self.ASSET_KERNEL_4K) |
| 56 | |
| 57 | def test_mips_malta32el_nanomips_16k_up(self): |
| 58 | self.do_test_mips_malta32el_nanomips(self.ASSET_KERNEL_16K) |
| 59 | |
| 60 | def test_mips_malta32el_nanomips_64k_dbg(self): |
| 61 | self.do_test_mips_malta32el_nanomips(self.ASSET_KERNEL_64K) |
| 62 | |
| 63 | ASSET_WHEEZY_KERNEL = Asset( |
| 64 | ('https://people.debian.org/~aurel32/qemu/mipsel/' |
| 65 | 'vmlinux-3.2.0-4-4kc-malta'), |
| 66 | 'dc8a3648305b0201ca7a5cd135fe2890067a65d93c38728022bb0e656ad2bf9a') |
| 67 | |
| 68 | ASSET_WHEEZY_DISK = Asset( |
| 69 | ('https://people.debian.org/~aurel32/qemu/mipsel/' |
| 70 | 'debian_wheezy_mipsel_standard.qcow2'), |
| 71 | '454f09ae39f7e6461c84727b927100d2c7813841f2a0a5dce328114887ecf914') |
| 72 | |
| 73 | @skipFlakyTest("https://gitlab.com/qemu-project/qemu/-/issues/3109") |
| 74 | def test_wheezy(self): |
| 75 | kernel_path = self.ASSET_WHEEZY_KERNEL.fetch() |
| 76 | image_path = self.ASSET_WHEEZY_DISK.fetch() |
| 77 | kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE |
| 78 | + 'console=ttyS0 root=/dev/sda1') |
| 79 | mips_check_wheezy(self, |
| 80 | kernel_path, image_path, kernel_command_line, |
| 81 | dl_file='/boot/initrd.img-3.2.0-4-4kc-malta', |
| 82 | hsum='9fc9f250ed56a74e35e704ddfd5a1c5a5625adefc5c9da91f649288d3ca000f0') |
| 83 | |
| 84 | |
| 85 | class MaltaMachineYAMON(QemuSystemTest): |
| 86 | |
| 87 | ASSET_YAMON_ROM = Asset( |
| 88 | ('https://s3-eu-west-1.amazonaws.com/downloads-mips/mips-downloads/' |
| 89 | 'YAMON/yamon-bin-02.22.zip'), |
| 90 | 'eef86f0eed0ef554f041dcd47b87eebea0e6f9f1184ed31f7e9e8b4a803860ab') |
| 91 | |
| 92 | def test_mipsel_malta_yamon(self): |
| 93 | yamon_bin = 'yamon-02.22.bin' |
| 94 | self.archive_extract(self.ASSET_YAMON_ROM) |
| 95 | yamon_path = self.scratch_file(yamon_bin) |
| 96 | |
| 97 | self.set_machine('malta') |
| 98 | self.vm.set_console() |
| 99 | self.vm.add_args('-bios', yamon_path) |
| 100 | self.vm.launch() |
| 101 | |
| 102 | prompt = 'YAMON>' |
| 103 | pattern = 'YAMON ROM Monitor' |
| 104 | interrupt_interactive_console_until_pattern(self, pattern, prompt) |
| 105 | wait_for_console_pattern(self, prompt) |
| 106 | self.vm.shutdown() |
| 107 | |
| 108 | |
| 109 | if __name__ == '__main__': |
| 110 | QemuSystemTest.main() |