| 1 | #!/usr/bin/env python3 |
| 2 | # |
| 3 | # Functional test that boots a Linux kernel on a Tenstorrent Atlantis machine |
| 4 | # and checks the console |
| 5 | # |
| 6 | # Copyright (c) Linaro Ltd. |
| 7 | # Copyright 2026 Tenstorrent |
| 8 | # |
| 9 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 10 | |
| 11 | from qemu_test import Asset, LinuxKernelTest |
| 12 | |
| 13 | |
| 14 | class TTAtlantis(LinuxKernelTest): |
| 15 | |
| 16 | ASSET_KERNEL = Asset( |
| 17 | 'https://storage.tuxboot.com/kernels/6.11.9/riscv64/Image', |
| 18 | '174f8bb87f08961e54fa3fcd954a8e31f4645f6d6af4dd43983d5e9841490fb0') |
| 19 | ASSET_ROOTFS = Asset( |
| 20 | ('https://github.com/groeck/linux-build-test/raw/' |
| 21 | '9819da19e6eef291686fdd7b029ea00e764dc62f/rootfs/riscv64/' |
| 22 | 'rootfs.ext2.gz'), |
| 23 | 'b6ed95610310b7956f9bf20c4c9c0c05fea647900df441da9dfe767d24e8b28b') |
| 24 | |
| 25 | def do_test_riscv64_tt_atlantis(self, connect_disk): |
| 26 | self.set_machine('tt-atlantis') |
| 27 | kernel_path = self.ASSET_KERNEL.fetch() |
| 28 | rootfs_path = self.uncompress(self.ASSET_ROOTFS) |
| 29 | |
| 30 | self.vm.set_console() |
| 31 | kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'earlycon=sbi ' |
| 32 | |
| 33 | if connect_disk: |
| 34 | kernel_command_line += 'root=/dev/vda panic=-1 noreboot rootwait ' |
| 35 | self.vm.add_args('-device', |
| 36 | 'virtio-blk,drive=drive0,serial=0x1234,bus=pcie.0') |
| 37 | self.vm.add_args('-drive', |
| 38 | f'file={rootfs_path},if=none,id=drive0,format=raw') |
| 39 | pattern = 'Boot successful.' |
| 40 | else: |
| 41 | kernel_command_line += 'panic=0 noreboot ' |
| 42 | pattern = 'Cannot open root device' |
| 43 | |
| 44 | self.vm.add_args('-kernel', kernel_path, |
| 45 | '-append', kernel_command_line, |
| 46 | '-no-reboot') |
| 47 | |
| 48 | self.vm.launch() |
| 49 | self.wait_for_console_pattern(pattern) |
| 50 | |
| 51 | def test_riscv64_tt_atlantis(self): |
| 52 | # tt-atlantis machine has no PCI host yet, so no disk |
| 53 | self.do_test_riscv64_tt_atlantis(False) |
| 54 | |
| 55 | |
| 56 | if __name__ == '__main__': |
| 57 | LinuxKernelTest.main() |