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