1*bc4d45b2SPeter Maydell#!/usr/bin/env python3 2*bc4d45b2SPeter Maydell# 3*bc4d45b2SPeter Maydell# Copyright (c) 2024 Linaro Ltd. 4*bc4d45b2SPeter Maydell# 5*bc4d45b2SPeter Maydell# Functional test that boots a Linux kernel on an sx1 machine 6*bc4d45b2SPeter Maydell# and checks the console. We have three variants: 7*bc4d45b2SPeter Maydell# * just boot initrd 8*bc4d45b2SPeter Maydell# * boot with filesystem on SD card 9*bc4d45b2SPeter Maydell# * boot from flash 10*bc4d45b2SPeter Maydell# In all cases these images have a userspace that is configured 11*bc4d45b2SPeter Maydell# to immediately reboot the system on successful boot, so we 12*bc4d45b2SPeter Maydell# only need to wait for QEMU to exit (via -no-reboot). 13*bc4d45b2SPeter Maydell# 14*bc4d45b2SPeter Maydell# SPDX-License-Identifier: GPL-2.0-or-later 15*bc4d45b2SPeter Maydell 16*bc4d45b2SPeter Maydellfrom qemu_test import LinuxKernelTest, Asset 17*bc4d45b2SPeter Maydellfrom qemu_test.utils import archive_extract 18*bc4d45b2SPeter Maydell 19*bc4d45b2SPeter Maydellclass SX1Test(LinuxKernelTest): 20*bc4d45b2SPeter Maydell 21*bc4d45b2SPeter Maydell ASSET_ZIMAGE = Asset( 22*bc4d45b2SPeter Maydell 'https://github.com/groeck/linux-test-downloads/raw/225223f2ad7d637b34426810bf6c3b727b76a718/sx1/zImage', 23*bc4d45b2SPeter Maydell 'a0271899a8dc2165f9e0adb2d0a57fc839ae3a469722ffc56c77e108a8887615') 24*bc4d45b2SPeter Maydell 25*bc4d45b2SPeter Maydell ASSET_INITRD = Asset( 26*bc4d45b2SPeter Maydell 'https://github.com/groeck/linux-test-downloads/raw/225223f2ad7d637b34426810bf6c3b727b76a718/sx1/rootfs-armv4.cpio', 27*bc4d45b2SPeter Maydell '35b0721249821aa544cd85b85d3cb8901db4c6d128eed86ab261e5d9e37d58f8') 28*bc4d45b2SPeter Maydell 29*bc4d45b2SPeter Maydell ASSET_SD_FS = Asset( 30*bc4d45b2SPeter Maydell 'https://github.com/groeck/linux-test-downloads/raw/225223f2ad7d637b34426810bf6c3b727b76a718/sx1/rootfs-armv4.ext2', 31*bc4d45b2SPeter Maydell 'c1db7f43ef92469ebc8605013728c8950e7608439f01d13678994f0ce101c3a8') 32*bc4d45b2SPeter Maydell 33*bc4d45b2SPeter Maydell ASSET_FLASH = Asset( 34*bc4d45b2SPeter Maydell 'https://github.com/groeck/linux-test-downloads/raw/225223f2ad7d637b34426810bf6c3b727b76a718/sx1/flash', 35*bc4d45b2SPeter Maydell '17e6a2758fa38efd2666be0879d4751fd37d194f25168a8deede420df519b676') 36*bc4d45b2SPeter Maydell 37*bc4d45b2SPeter Maydell CONSOLE_ARGS = 'console=ttyS0,115200 earlycon=uart8250,mmio32,0xfffb0000,115200n8' 38*bc4d45b2SPeter Maydell 39*bc4d45b2SPeter Maydell def test_arm_sx1_initrd(self): 40*bc4d45b2SPeter Maydell self.set_machine('sx1') 41*bc4d45b2SPeter Maydell zimage_path = self.ASSET_ZIMAGE.fetch() 42*bc4d45b2SPeter Maydell initrd_path = self.ASSET_INITRD.fetch() 43*bc4d45b2SPeter Maydell self.vm.add_args('-append', f'kunit.enable=0 rdinit=/sbin/init {self.CONSOLE_ARGS}') 44*bc4d45b2SPeter Maydell self.vm.add_args('-no-reboot') 45*bc4d45b2SPeter Maydell self.launch_kernel(zimage_path, 46*bc4d45b2SPeter Maydell initrd=initrd_path) 47*bc4d45b2SPeter Maydell self.vm.wait() 48*bc4d45b2SPeter Maydell 49*bc4d45b2SPeter Maydell def test_arm_sx1_sd(self): 50*bc4d45b2SPeter Maydell self.set_machine('sx1') 51*bc4d45b2SPeter Maydell zimage_path = self.ASSET_ZIMAGE.fetch() 52*bc4d45b2SPeter Maydell sd_fs_path = self.ASSET_SD_FS.fetch() 53*bc4d45b2SPeter Maydell self.vm.add_args('-append', f'kunit.enable=0 root=/dev/mmcblk0 rootwait {self.CONSOLE_ARGS}') 54*bc4d45b2SPeter Maydell self.vm.add_args('-no-reboot') 55*bc4d45b2SPeter Maydell self.vm.add_args('-snapshot') 56*bc4d45b2SPeter Maydell self.vm.add_args('-drive', f'format=raw,if=sd,file={sd_fs_path}') 57*bc4d45b2SPeter Maydell self.launch_kernel(zimage_path) 58*bc4d45b2SPeter Maydell self.vm.wait() 59*bc4d45b2SPeter Maydell 60*bc4d45b2SPeter Maydell def test_arm_sx1_flash(self): 61*bc4d45b2SPeter Maydell self.set_machine('sx1') 62*bc4d45b2SPeter Maydell zimage_path = self.ASSET_ZIMAGE.fetch() 63*bc4d45b2SPeter Maydell flash_path = self.ASSET_FLASH.fetch() 64*bc4d45b2SPeter Maydell self.vm.add_args('-append', f'kunit.enable=0 root=/dev/mtdblock3 rootwait {self.CONSOLE_ARGS}') 65*bc4d45b2SPeter Maydell self.vm.add_args('-no-reboot') 66*bc4d45b2SPeter Maydell self.vm.add_args('-snapshot') 67*bc4d45b2SPeter Maydell self.vm.add_args('-drive', f'format=raw,if=pflash,file={flash_path}') 68*bc4d45b2SPeter Maydell self.launch_kernel(zimage_path) 69*bc4d45b2SPeter Maydell self.vm.wait() 70*bc4d45b2SPeter Maydell 71*bc4d45b2SPeter Maydellif __name__ == '__main__': 72*bc4d45b2SPeter Maydell LinuxKernelTest.main() 73