On 29/4/26 23:51, Ericson Joseph wrote:
Wire the PIC32MK tests into the build system:

- tests/functional/mipsel: register pic32mk as a quick test (30s),
   build pic32mk_test_fw.bin from assembly source using the mipsel-linux-gnu
   cross toolchain when available, and run test_pic32mk.py which boots the
   board and waits for "Hello, PIC32MK!" on UART1.

- tests/qtest/meson.build: add pic32mk-test and pic32mk-canfd-test to
   qtests_mipsel (gated on CONFIG_PIC32MK).

Signed-off-by: Ericson Joseph <[email protected]>
---
  tests/functional/mipsel/meson.build     | 28 ++++++++++
  tests/functional/mipsel/test_pic32mk.py | 99 +++++++++++----------------------
  tests/qtest/meson.build                 |  4 +-
  3 files changed, 63 insertions(+), 68 deletions(-)


diff --git a/tests/functional/mipsel/test_pic32mk.py 
b/tests/functional/mipsel/test_pic32mk.py
index 4af91c4f88..ebfc94f388 100644
--- a/tests/functional/mipsel/test_pic32mk.py
+++ b/tests/functional/mipsel/test_pic32mk.py
@@ -1,9 +1,12 @@
  #!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0-or-later
  #
-# Functional tests for the PIC32MK board emulation
+# Functional test for the Microchip PIC32MK GPK/MCM board emulation.
  #
-# Copyright (c) 2026 QEMU contributors
-# SPDX-License-Identifier: GPL-2.0-or-later
+# The test firmware (pic32mk_test_fw.S) is a minimal MIPS assembly program
+# that initialises UART1 and writes "Hello, PIC32MK!\r\n" then spins.
+# This verifies that the board boots, the CPU executes code, and UART1 TX
+# produces output on the emulated serial console.
import os @@ -11,81 +14,43 @@
  from qemu_test import wait_for_console_pattern
+def _fw_path():
+    """Return the path to the pre-built test firmware binary."""
+    build_dir = os.environ.get('BUILD_DIR', '')
+    if build_dir:
+        candidate = os.path.join(build_dir,
+                                 'tests', 'functional', 'mipsel',
+                                 'pic32mk_test_fw.bin')
+        if os.path.isfile(candidate):
+            return candidate
+    # Fallback: look next to this file (for out-of-tree runs)
+    here = os.path.dirname(os.path.abspath(__file__))
+    return os.path.join(here, 'pic32mk_test_fw.bin')
+
+
  class PIC32MKMachine(QemuSystemTest):
      """
-    Tests for the PIC32MK MCU board (-M pic32mk).
+    Boot test for the Microchip PIC32MK GPK/MCM board (-M pic32mk).
- The FreeRTOS firmware is expected to be pre-built at
-    tests/freertos/hello_freertos.bin relative to the source tree.
+    Requires pic32mk_test_fw.bin built from pic32mk_test_fw.S by meson.
+    The binary must be present in the meson build tree under
+    tests/functional/mipsel/pic32mk_test_fw.bin.
      """
timeout = 30 - def get_firmware_path(self):
-        """Locate the pre-built FreeRTOS firmware binary."""
-        # data_file() resolves relative to tests/functional/
-        # We need to go up two levels to reach the source root
-        src_root = os.path.join(
-            os.path.dirname(__file__), '..', '..', '..')
-        fw_path = os.path.realpath(
-            os.path.join(src_root, 'tests', 'freertos', 'hello_freertos.bin'))
-        if not os.path.isfile(fw_path):
+    def test_uart_boot_message(self):
+        """Board boots and UART1 TX prints the expected banner."""
+        fw = _fw_path()
+        if not os.path.isfile(fw):
              self.skipTest(
-                f'FreeRTOS firmware not built: {fw_path}\n'
-                'Run: make -C tests/freertos')
-        return fw_path
-
-    def test_boot_message(self):
-        """PIC32MK boots and prints the FreeRTOS banner."""
-        self.set_machine('pic32mk')
-        self.vm.set_console()
-        self.vm.add_args('-bios', self.get_firmware_path(),
-                         '-nographic')
-        self.vm.launch()
-        wait_for_console_pattern(self,
-                                 'PIC32MK QEMU booting FreeRTOS...')
-
-    def test_freertos_hello_task(self):
-        """FreeRTOS scheduler starts and the Hello task fires."""
-        self.set_machine('pic32mk')
-        self.vm.set_console()
-        self.vm.add_args('-bios', self.get_firmware_path(),
-                         '-nographic')
-        self.vm.launch()
-        # First: boot banner
-        wait_for_console_pattern(self,
-                                 'PIC32MK QEMU booting FreeRTOS...')
-        # Second: at least one Hello message (proves Timer1 tick + UART TX IRQ)
-        wait_for_console_pattern(self,
-                                 'Hello from FreeRTOS!')
-
-    def test_freertos_recurring_ticks(self):
-        """Timer1 delivers recurring ticks — multiple Hello messages appear."""
-        self.set_machine('pic32mk')
-        self.vm.set_console()
-        self.vm.add_args('-bios', self.get_firmware_path(),
-                         '-nographic')
-        self.vm.launch()
-        wait_for_console_pattern(self,
-                                 'PIC32MK QEMU booting FreeRTOS...')
-        # Wait for a second Hello — proves the tick ISR fires repeatedly
-        # and context switches work (CS0 yield + Timer1 preemption).
-        wait_for_console_pattern(self,
-                                 'Hello from FreeRTOS!')
-        wait_for_console_pattern(self,
-                                 'Hello from FreeRTOS!')
-
-    def test_freertos_ping_task(self):
-        """Second FreeRTOS task (Ping) also runs — proves multitasking."""
+                'pic32mk_test_fw.bin not found — '
+                'build with: ninja -C <builddir> pic32mk_test_fw.bin')
          self.set_machine('pic32mk')
          self.vm.set_console()
-        self.vm.add_args('-bios', self.get_firmware_path(),
-                         '-nographic')
+        self.vm.add_args('-bios', fw, '-nographic')
          self.vm.launch()
-        wait_for_console_pattern(self,
-                                 'PIC32MK QEMU booting FreeRTOS...')
-        # Ping task fires every 5 seconds
-        wait_for_console_pattern(self, 'Ping')
+        wait_for_console_pattern(self, 'Hello, PIC32MK!')

You just removed the tests you added in the previous patch, is this
really what you aim for?

Reply via email to