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