1#!/usr/bin/env python3 2# 3# Functional tests for the Lemote Fuloong-2E machine. 4# 5# Copyright (c) 2019 Philippe Mathieu-Daudé <f4bug@amsat.org> 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 12import os 13import subprocess 14 15from qemu_test import LinuxKernelTest, Asset 16from qemu_test import wait_for_console_pattern 17from unittest import skipUnless 18 19class MipsFuloong2e(LinuxKernelTest): 20 21 timeout = 60 22 23 ASSET_KERNEL = Asset( 24 ('http://archive.debian.org/debian/pool/main/l/linux/' 25 'linux-image-3.16.0-6-loongson-2e_3.16.56-1+deb8u1_mipsel.deb'), 26 '2a70f15b397f4ced632b0c15cb22660394190644146d804d60a4796eefbe1f50') 27 28 def test_linux_kernel_3_16(self): 29 deb_path = self.ASSET_KERNEL.fetch() 30 kernel_path = self.extract_from_deb(deb_path, 31 '/boot/vmlinux-3.16.0-6-loongson-2e') 32 33 self.set_machine('fuloong2e') 34 self.vm.set_console() 35 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' 36 self.vm.add_args('-kernel', kernel_path, 37 '-append', kernel_command_line) 38 self.vm.launch() 39 console_pattern = 'Kernel command line: %s' % kernel_command_line 40 self.wait_for_console_pattern(console_pattern) 41 42 @skipUnless(os.getenv('QEMU_TEST_ALLOW_UNTRUSTED_CODE'), 'untrusted code') 43 @skipUnless(os.getenv('RESCUE_YL_PATH'), 'RESCUE_YL_PATH not available') 44 def test_linux_kernel_2_6_27_isa_serial(self): 45 # Recovery system for the Yeeloong laptop 46 # (enough to test the fuloong2e southbridge, accessing its ISA bus) 47 # http://dev.lemote.com/files/resource/download/rescue/rescue-yl 48 sha = 'ab588d3316777c62cc81baa20ac92e98b01955c244dff3794b711bc34e26e51d' 49 kernel_path = os.getenv('RESCUE_YL_PATH') 50 output = subprocess.check_output(['sha256sum', kernel_path]) 51 checksum = output.split()[0] 52 assert checksum.decode("utf-8") == sha 53 54 self.set_machine('fuloong2e') 55 self.vm.set_console() 56 self.vm.add_args('-kernel', kernel_path) 57 self.vm.launch() 58 wait_for_console_pattern(self, 'Linux version 2.6.27.7lemote') 59 cpu_revision = 'CPU revision is: 00006302 (ICT Loongson-2)' 60 wait_for_console_pattern(self, cpu_revision) 61 62 63if __name__ == '__main__': 64 LinuxKernelTest.main() 65