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