Hi!
On 01/10/2025 11.49, Djordje Todorovic wrote:
Add functional test for Boston AIA board. The P8700 RISC-V based
CPU by MIPS supports it at the moment.
Signed-off-by: Chao-ying Fu <[email protected]>
Signed-off-by: Djordje Todorovic <[email protected]>
---
tests/functional/riscv64/meson.build | 1 +
.../functional/riscv64/test_riscv64_boston.py | 164 ++++++++++++++++++
2 files changed, 165 insertions(+)
create mode 100755 tests/functional/riscv64/test_riscv64_boston.py
diff --git a/tests/functional/riscv64/meson.build
b/tests/functional/riscv64/meson.build
index c1704d9275..9bce341b80 100644
--- a/tests/functional/riscv64/meson.build
+++ b/tests/functional/riscv64/meson.build
@@ -7,6 +7,7 @@ test_riscv64_timeouts = {
tests_riscv64_system_quick = [
'migration',
'opensbi',
+ 'riscv64_boston',
]
tests_riscv64_system_thorough = [
diff --git a/tests/functional/riscv64/test_riscv64_boston.py
b/tests/functional/riscv64/test_riscv64_boston.py
new file mode 100755
index 0000000000..0527571847
--- /dev/null
+++ b/tests/functional/riscv64/test_riscv64_boston.py
@@ -0,0 +1,164 @@
+#!/usr/bin/env python3
+#
+# Boston board test for RISC-V P8700 processor by MIPS
+#
+# Copyright (c) 2025 MIPS
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+
+import os
+from qemu_test import QemuSystemTest, Asset
+from qemu_test import wait_for_console_pattern
+
Cosmetic nit: Most tests use two empty lines between the imports and the
class ... might be nicer to use it here, too.
+class RiscvBostonTest(QemuSystemTest):
+ """
+ Test the boston-aia board with P8700 processor
+ """
+
+ timeout = 120 # Timeout for boot tests
Please remove the timeout line here, it's of no use in the functional tests
anymore (yeah, I know, we also have to remove this from a bunch of other
files...).
If you need a timeout > 90s for the total test time, please specify it in
the meson.build file instead.
+ ASSET_FW_PAYLOAD = Asset(
+
'https://github.com/MIPS/linux-test-downloads/raw/main/p8700/fw_payload.bin',
+ 'd6f4ae14d0c178c1d0bb38ddf64557536ca8602a588b220729a8aa17caa383aa')
+
+ ASSET_ROOTFS = Asset(
+
'https://github.com/MIPS/linux-test-downloads/raw/main/p8700/rootfs.ext2',
+ 'f937e21b588f0d1d17d10a063053979686897bbbbc5e9617a5582f7c1f48e565')
+
+ def _fetch_rootfs(self):
+ """Fetch rootfs and fix permissions"""
+ rootfs_path = self.ASSET_ROOTFS.fetch()
+ # Ensure the rootfs file is readable
+ try:
+ os.chmod(rootfs_path, 0o644)
+ except:
+ pass # If we can't change permissions, try anyway
Please don't make the files in the cache writable, otherwise the hashsum of
the file might get changed and then you have to re-download.
The correct way to allow the guest to write to the disk (and throw away the
changes afterwards), is to use ",snapshot=on" in your -drive statement below.
+ return rootfs_path
+
+ def test_boston_boot_linux(self):
+ """
+ Test full Linux kernel boot with rootfs on Boston board
+ """
+ self.set_machine('boston-aia')
+ fw_payload_path = self.ASSET_FW_PAYLOAD.fetch()
+ rootfs_path = self._fetch_rootfs()
+
+ self.vm.add_args('-cpu', 'mips-p8700')
+ self.vm.add_args('-m', '2G')
+ self.vm.add_args('-smp', '2')
+ self.vm.add_args('-kernel', fw_payload_path)
+ self.vm.add_args('-drive', f'file={rootfs_path},format=raw')
+
+ self.vm.set_console()
+ self.vm.launch()
+
+ # Wait for OpenSBI
+ wait_for_console_pattern(self, 'OpenSBI')
+
+ # Wait for Linux kernel boot
+ wait_for_console_pattern(self, 'Linux version')
+ wait_for_console_pattern(self, 'Machine model: MIPS P8700')
+
+ # Test e1000e network card functionality
+ wait_for_console_pattern(self, 'e1000e')
+ wait_for_console_pattern(self, 'Network Connection')
+
+ # Wait for boot to complete - system reaches login prompt
+ wait_for_console_pattern(self, 'Run /sbin/init as init process')
+
+ def test_boston_7_vps_boot_linux(self):
+ """
+ Test full Linux kernel boot with rootfs on Boston board
+ """
+ self.set_machine('boston-aia')
+ fw_payload_path = self.ASSET_FW_PAYLOAD.fetch()
+ rootfs_path = self._fetch_rootfs()
+
+ self.vm.add_args('-cpu', 'mips-p8700')
+ self.vm.add_args('-m', '2G')
+ self.vm.add_args('-smp', '7')
+ self.vm.add_args('-kernel', fw_payload_path)
+ self.vm.add_args('-drive', f'file={rootfs_path},format=raw')
+
+ self.vm.set_console()
+ self.vm.launch()
+
+ # Wait for OpenSBI
+ wait_for_console_pattern(self, 'OpenSBI')
+
+ # Wait for Linux kernel boot
+ wait_for_console_pattern(self, 'Linux version')
+ wait_for_console_pattern(self, 'Machine model: MIPS P8700')
+
+ # Test e1000e network card functionality
+ wait_for_console_pattern(self, 'e1000e')
+ wait_for_console_pattern(self, 'Network Connection')
+
+ # Wait for boot to complete - system reaches login prompt
+ wait_for_console_pattern(self, 'Run /sbin/init as init process')
+
+ def test_boston_35_vps_boot_linux(self):
+ """
+ Test full Linux kernel boot with rootfs on Boston board
+ """
+ self.set_machine('boston-aia')
+ fw_payload_path = self.ASSET_FW_PAYLOAD.fetch()
+ rootfs_path = self._fetch_rootfs()
+
+ self.vm.add_args('-cpu', 'mips-p8700')
+ self.vm.add_args('-m', '2G')
+ self.vm.add_args('-smp', '35')
+ self.vm.add_args('-kernel', fw_payload_path)
+ self.vm.add_args('-drive', f'file={rootfs_path},format=raw')
+
+ self.vm.set_console()
+ self.vm.launch()
+
+ # Wait for OpenSBI
+ wait_for_console_pattern(self, 'OpenSBI')
+
+ # Wait for Linux kernel boot
+ wait_for_console_pattern(self, 'Linux version')
+ wait_for_console_pattern(self, 'Machine model: MIPS P8700')
+
+ # Test e1000e network card functionality
+ wait_for_console_pattern(self, 'e1000e')
+ wait_for_console_pattern(self, 'Network Connection')
+
+ # Wait for boot to complete - system reaches login prompt
+ wait_for_console_pattern(self, 'Run /sbin/init as init process')
Do you really need to repeat the same test three times, just with different
amount of CPUs? Once with the smallest possible amount and once with the
biggest possible amount should be sufficient, shouldn't it? (Otherwise
please state in the comments at the beginning of the function why certain
amounts of CPUs are special and should be tested separately).
Please also consider to merge the parts that are common between the tests
into a shared setup function.
Thanks,
Thomas