summaryrefslogtreecommitdiff
path: root/test/tx/cmake/module_qemu/src/harness.h
diff options
context:
space:
mode:
authorFrédéric Desbiens <[email protected]>2026-10-23 13:06:05 -0400
committerGitHub <[email protected]>2026-10-23 13:06:05 -0400
commit4c2179186c5348175bbce481cfafbc3d13f54a61 (patch)
treeece1b62db161d3aaf6b64dd67896beea5f2024d0 /test/tx/cmake/module_qemu/src/harness.h
parent3a77bc385c6cac82c71e1c36d6817e0860d12526 (diff)
Added a QEMU module execution harness for the Cortex-M3 and M4 ports (#821)dev
No Cortex-M module port ran in CI. gcc_check compiles each port's module manager sources and links nothing that loads a module, and the host tests under test/tx/module_manager compile a few portable sources against stubs. A module's start-up, its kernel calls through the supervisor call, the MPU programming on context switches and the fault path that terminates a misbehaving module were exercised only on the Cortex-R52 FVP. test/tx/cmake/module_qemu is a stand-alone CMake project, like test/tx/cmake/riscv, that builds the kernel and Module Manager with a module port's headers, builds test modules position-independent with the port's module linker script, embeds their raw images in manager images, and registers each image with CTest. A Python runner starts it on QEMU's MPS2 board for the core, mps2-an385 for cortex_m3 and mps2-an386 for cortex_m4 built for its FPU with the hard-float ABI, and judges the result line the image prints over semihosting and the exit status it sets. Three images per port: a protected module loaded, started, exercising queues, semaphores, a worker thread and the timer, stopped and unloaded twice with its memory returned; the same module faulting on a read of kernel memory, reported to the fault notification with its module, thread and address and terminated, then stopped and unloaded; and the module built privileged and unprotected, whose identical read succeeds. The fault image is also the check that QEMU's MPU enforces at all. The new module_qemu workflow runs both ports on changes to common/, common_modules/, the two module ports and the harness, installing QEMU from the Ubuntu archive through the bounded apt helpers in scripts/tx_ci_common.sh. Both ports pass 3/3 on QEMU 8.2.2 with Arm GNU 14.3.rel1, using the workflow's commands, with zero compiler warnings; configure, build and run take 9 seconds for both. The AI disclosure check passes. The workflow itself has not run on GitHub yet. Assisted-by: Claude Code (Opus 5.5) <[email protected]>
Diffstat (limited to 'test/tx/cmake/module_qemu/src/harness.h')
-rw-r--r--test/tx/cmake/module_qemu/src/harness.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/tx/cmake/module_qemu/src/harness.h b/test/tx/cmake/module_qemu/src/harness.h
new file mode 100644
index 00000000..9145531b
--- /dev/null
+++ b/test/tx/cmake/module_qemu/src/harness.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (c) 2026 Eclipse ThreadX contributors
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the MIT License which is available at
+ * https://opensource.org/licenses/MIT.
+ *
+ * AI Disclosure: This file was largely AI-generated by Claude Code (Opus 5.5).
+ * The AI-generated portions may be considered public domain (CC0-1.0)
+ * and not subject to the project's licence. The human contributor has
+ * reviewed and verified that the code is correct.
+ *
+ * SPDX-License-Identifier: MIT and CC0-1.0
+ **************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** ThreadX Test */
+/** */
+/** Module execution harness: manager-side reporting */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+#ifndef HARNESS_H
+#define HARNESS_H
+
+#include "tx_api.h"
+#include "txm_module.h"
+
+/* Record one expectation; a failed one is printed and makes the image fail. */
+VOID harness_expect(const CHAR *description, ULONG actual, ULONG expected);
+
+/* Print a line, or a labelled value, over semihosting. */
+VOID harness_print(const CHAR *text);
+VOID harness_value(const CHAR *label, ULONG value);
+
+/* Print the verdict and end the simulation; never returns. */
+VOID harness_finish(VOID);
+
+/* Wait, in ticks, until a module writes the done word or the limit passes.
+ Returns TX_TRUE if the module finished. */
+UINT harness_wait_for_module(ULONG limit_ticks);
+
+/* Clear the shared area and grant it to a module. */
+VOID harness_shared_clear(VOID);
+UINT harness_shared_grant(TXM_MODULE_INSTANCE *module_instance);
+
+/* What the memory fault notification has seen. */
+extern volatile ULONG harness_fault_count;
+extern TX_THREAD * volatile harness_fault_thread;
+extern TXM_MODULE_INSTANCE * volatile harness_fault_module;
+extern volatile ULONG harness_fault_address;
+extern volatile ULONG harness_fault_status;
+
+VOID harness_fault_notify(TX_THREAD *thread_ptr, TXM_MODULE_INSTANCE *module_instance);
+
+/* The memory handed to the Module Manager, shared by every test image. */
+extern UCHAR harness_module_memory[];
+extern UCHAR harness_object_memory[];
+
+#define HARNESS_MODULE_MEMORY_SIZE ((ULONG) 65536UL)
+#define HARNESS_OBJECT_MEMORY_SIZE ((ULONG) 16384UL)
+
+/* Each test image defines this; it runs on the manager thread. */
+VOID harness_test(VOID);
+
+#endif