| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Boot a Linux kernel on a e500 ppc64 machine and check the console |
| 4 | # |
| 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | |
| 7 | from qemu_test import LinuxKernelTest, Asset |
| 8 | from qemu_test import exec_command_and_wait_for_pattern |
| 9 | |
| 10 | |
| 11 | class E500Test(LinuxKernelTest): |
| 12 | |
| 13 | ASSET_BR2_E5500_UIMAGE = Asset( |
| 14 | 'https://github.com/legoater/qemu-ppc-boot/raw/refs/heads/main/buildroot/qemu_ppc64_e5500-2023.11-8-gdcd9f0f6eb-20240104/uImage', |
| 15 | '2478187c455d6cca3984e9dfde9c635d824ea16236b85fd6b4809f744706deda') |
| 16 | |
| 17 | ASSET_BR2_E5500_ROOTFS = Asset( |
| 18 | 'https://github.com/legoater/qemu-ppc-boot/raw/refs/heads/main//buildroot/qemu_ppc64_e5500-2023.11-8-gdcd9f0f6eb-20240104/rootfs.ext2', |
| 19 | '9035ef97237c84c7522baaff17d25cdfca4bb7a053d5e296e902919473423d76') |
| 20 | |
| 21 | def test_ppc64_e500_buildroot(self): |
| 22 | self.set_machine('ppce500') |
| 23 | self.require_netdev('user') |
| 24 | self.cpu = 'e5500' |
| 25 | |
| 26 | uimage_path = self.ASSET_BR2_E5500_UIMAGE.fetch() |
| 27 | rootfs_path = self.ASSET_BR2_E5500_ROOTFS.fetch() |
| 28 | |
| 29 | self.vm.set_console() |
| 30 | self.vm.add_args('-kernel', uimage_path, |
| 31 | '-append', 'root=/dev/vda', |
| 32 | '-drive', f'file={rootfs_path},if=virtio,format=raw', |
| 33 | '-snapshot', '-no-shutdown') |
| 34 | self.vm.launch() |
| 35 | |
| 36 | self.wait_for_console_pattern('Linux version') |
| 37 | self.wait_for_console_pattern('/init as init process') |
| 38 | self.wait_for_console_pattern('lease of 10.0.2.15') |
| 39 | self.wait_for_console_pattern('buildroot login:') |
| 40 | exec_command_and_wait_for_pattern(self, 'root', '#') |
| 41 | exec_command_and_wait_for_pattern(self, 'poweroff', 'Power down') |
| 42 | |
| 43 | if __name__ == '__main__': |
| 44 | LinuxKernelTest.main() |