2024-08-30 16:38:11 +03:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
2023-05-13 04:27:44 +03:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#
|
|
|
|
# LoongArch virt test.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2023 Loongson Technology Corporation Limited
|
|
|
|
#
|
|
|
|
|
2024-08-30 16:38:11 +03:00
|
|
|
from qemu_test import QemuSystemTest, Asset
|
|
|
|
from qemu_test import exec_command_and_wait_for_pattern
|
|
|
|
from qemu_test import wait_for_console_pattern
|
2023-05-13 04:27:44 +03:00
|
|
|
|
|
|
|
class LoongArchMachine(QemuSystemTest):
|
|
|
|
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
|
|
|
|
|
|
|
|
timeout = 120
|
|
|
|
|
2024-08-30 16:38:11 +03:00
|
|
|
ASSET_KERNEL = Asset(
|
|
|
|
('https://github.com/yangxiaojuan-loongson/qemu-binary/'
|
|
|
|
'releases/download/2024-05-30/vmlinuz.efi'),
|
|
|
|
'08b88a45f48a5fd92260bae895be4e5175be2397481a6f7821b9f39b2965b79e')
|
|
|
|
ASSET_INITRD = Asset(
|
|
|
|
('https://github.com/yangxiaojuan-loongson/qemu-binary/'
|
|
|
|
'releases/download/2024-05-30/ramdisk'),
|
|
|
|
'03d6fb6f8ee64ecac961120a0bdacf741f17b3bee2141f17fa01908c8baf176a')
|
|
|
|
ASSET_BIOS = Asset(
|
|
|
|
('https://github.com/yangxiaojuan-loongson/qemu-binary/'
|
|
|
|
'releases/download/2024-05-30/QEMU_EFI.fd'),
|
|
|
|
'937c1e7815e2340150c194a9f8f0474259038a3d7b8845ed62cc08163c46bea1')
|
|
|
|
|
2023-05-13 04:27:44 +03:00
|
|
|
def wait_for_console_pattern(self, success_message, vm=None):
|
|
|
|
wait_for_console_pattern(self, success_message,
|
|
|
|
failure_message='Kernel panic - not syncing',
|
|
|
|
vm=vm)
|
|
|
|
|
|
|
|
def test_loongarch64_devices(self):
|
|
|
|
|
2024-08-30 16:38:11 +03:00
|
|
|
self.set_machine('virt')
|
2023-05-13 04:27:44 +03:00
|
|
|
|
2024-08-30 16:38:11 +03:00
|
|
|
kernel_path = self.ASSET_KERNEL.fetch()
|
|
|
|
initrd_path = self.ASSET_INITRD.fetch()
|
|
|
|
bios_path = self.ASSET_BIOS.fetch()
|
2023-05-13 04:27:44 +03:00
|
|
|
|
|
|
|
self.vm.set_console()
|
|
|
|
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
|
|
|
|
'root=/dev/ram rdinit=/sbin/init console=ttyS0,115200')
|
|
|
|
self.vm.add_args('-nographic',
|
|
|
|
'-smp', '4',
|
|
|
|
'-m', '1024',
|
|
|
|
'-cpu', 'la464',
|
|
|
|
'-kernel', kernel_path,
|
|
|
|
'-initrd', initrd_path,
|
|
|
|
'-bios', bios_path,
|
|
|
|
'-append', kernel_command_line)
|
|
|
|
self.vm.launch()
|
|
|
|
self.wait_for_console_pattern('Run /sbin/init as init process')
|
|
|
|
exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
|
|
|
|
'processor : 3')
|
2024-08-30 16:38:11 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
QemuSystemTest.main()
|