Files
qemu/tests/functional/riscv64/test_sifive_u.py
Bin Meng 8fb3075916 tests/functional/riscv64: sifive_u: Fix kernel command line
Build the complete kernel command line before adding it to the QEMU
arguments. This ensures the panic, noreboot and rootwait options are
passed to the guest.

Fixes: 7db162fa01 ("tests/functional: Test SPI-SD adapter without SD card connected")
Signed-off-by: Bin Meng <bin.meng@processmission.com>

Reviewed-by: Chao Liu <chao.liu@processmission.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260713120245.781959-1-bin.meng@processmission.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2026-07-14 11:56:14 +10:00

63 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Functional test that boots a Linux kernel on a Sifive U machine
# and checks the console
#
# Copyright (c) Linaro Ltd.
#
# Author:
# Philippe Mathieu-Daudé
#
# SPDX-License-Identifier: GPL-2.0-or-later
import os
from qemu_test import Asset, LinuxKernelTest
class SifiveU(LinuxKernelTest):
ASSET_KERNEL = Asset(
'https://storage.tuxboot.com/buildroot/20241119/riscv64/Image',
'2bd8132a3bf21570290042324fff48c987f42f2a00c08de979f43f0662ebadba')
ASSET_ROOTFS = Asset(
('https://github.com/groeck/linux-build-test/raw/'
'9819da19e6eef291686fdd7b029ea00e764dc62f/rootfs/riscv64/'
'rootfs.ext2.gz'),
'b6ed95610310b7956f9bf20c4c9c0c05fea647900df441da9dfe767d24e8b28b')
def do_test_riscv64_sifive_u_mmc_spi(self, connect_card):
self.set_machine('sifive_u')
kernel_path = self.ASSET_KERNEL.fetch()
rootfs_path = self.uncompress(self.ASSET_ROOTFS)
self.vm.set_console()
kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
'earlycon=sbi console=ttySIF0 '
'root=/dev/mmcblk0 ')
if connect_card:
kernel_command_line += 'panic=-1 noreboot rootwait '
self.vm.add_args('-drive', f'file={rootfs_path},if=sd,format=raw')
pattern = 'Boot successful.'
else:
kernel_command_line += 'panic=0 noreboot '
pattern = 'Cannot open root device "mmcblk0" or unknown-block(0,0)'
self.vm.add_args('-kernel', kernel_path,
'-append', kernel_command_line,
'-no-reboot')
self.vm.launch()
self.wait_for_console_pattern(pattern)
os.remove(rootfs_path)
def test_riscv64_sifive_u_nommc_spi(self):
self.do_test_riscv64_sifive_u_mmc_spi(False)
def test_riscv64_sifive_u_mmc_spi(self):
self.do_test_riscv64_sifive_u_mmc_spi(True)
if __name__ == '__main__':
LinuxKernelTest.main()