summaryrefslogtreecommitdiff
path: root/test/smp/regression/threadx_smp_execution_profile_get_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/smp/regression/threadx_smp_execution_profile_get_test.c')
-rw-r--r--test/smp/regression/threadx_smp_execution_profile_get_test.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/test/smp/regression/threadx_smp_execution_profile_get_test.c b/test/smp/regression/threadx_smp_execution_profile_get_test.c
new file mode 100644
index 00000000..ccfd3b2a
--- /dev/null
+++ b/test/smp/regression/threadx_smp_execution_profile_get_test.c
@@ -0,0 +1,126 @@
+/***************************************************************************
+ * 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 Codex (GPT-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
+ **************************************************************************/
+
+/* This test verifies that the SMP execution profile aggregate getters copy every core value. */
+
+#include <stdio.h>
+#include "tx_api.h"
+#include "tx_execution_profile.h"
+
+extern EXECUTION_TIME _tx_execution_thread_time_total[TX_THREAD_SMP_MAX_CORES];
+extern EXECUTION_TIME _tx_execution_isr_time_total[TX_THREAD_SMP_MAX_CORES];
+extern EXECUTION_TIME _tx_execution_idle_time_total[TX_THREAD_SMP_MAX_CORES];
+
+ULONG _tx_thread_system_state[TX_THREAD_SMP_MAX_CORES];
+UINT _tx_thread_preempt_disable;
+TX_THREAD *_tx_thread_current_ptr[TX_THREAD_SMP_MAX_CORES];
+TX_THREAD *_tx_thread_execute_ptr[TX_THREAD_SMP_MAX_CORES];
+TX_THREAD *_tx_thread_created_ptr;
+ULONG _tx_thread_created_count;
+
+
+ULONG _tx_thread_smp_time_get(void)
+{
+
+ return(0);
+}
+
+
+static UINT verify_time_values(EXECUTION_TIME *actual, EXECUTION_TIME *expected)
+{
+
+UINT core;
+
+
+ for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++)
+ {
+
+ if (actual[core] != expected[core])
+ {
+
+ return(1);
+ }
+ }
+
+ return(0);
+}
+
+
+int main(void)
+{
+
+EXECUTION_TIME thread_time[TX_THREAD_SMP_MAX_CORES];
+EXECUTION_TIME isr_time[TX_THREAD_SMP_MAX_CORES];
+EXECUTION_TIME idle_time[TX_THREAD_SMP_MAX_CORES];
+EXECUTION_TIME expected_thread_time[TX_THREAD_SMP_MAX_CORES];
+EXECUTION_TIME expected_isr_time[TX_THREAD_SMP_MAX_CORES];
+EXECUTION_TIME expected_idle_time[TX_THREAD_SMP_MAX_CORES];
+UINT core;
+UINT status;
+
+
+ printf("Running SMP Execution Profile Get Test............................... ");
+
+ for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++)
+ {
+
+ expected_thread_time[core] = ((EXECUTION_TIME) 1000U) + ((EXECUTION_TIME) core);
+ expected_isr_time[core] = ((EXECUTION_TIME) 2000U) + ((EXECUTION_TIME) core);
+ expected_idle_time[core] = ((EXECUTION_TIME) 3000U) + ((EXECUTION_TIME) core);
+
+ _tx_execution_thread_time_total[core] = expected_thread_time[core];
+ _tx_execution_isr_time_total[core] = expected_isr_time[core];
+ _tx_execution_idle_time_total[core] = expected_idle_time[core];
+
+ thread_time[core] = 0xFFFFFFFFFFFFFFFFULL;
+ isr_time[core] = 0xFFFFFFFFFFFFFFFFULL;
+ idle_time[core] = 0xFFFFFFFFFFFFFFFFULL;
+ }
+
+ status = _tx_execution_thread_total_time_get(thread_time);
+ status += _tx_execution_isr_time_get(isr_time);
+ status += _tx_execution_idle_time_get(idle_time);
+
+ if (status != TX_SUCCESS)
+ {
+
+ printf("ERROR #1\n");
+ return(1);
+ }
+
+ if (verify_time_values(thread_time, expected_thread_time) != 0U)
+ {
+
+ printf("ERROR #2\n");
+ return(1);
+ }
+
+ if (verify_time_values(isr_time, expected_isr_time) != 0U)
+ {
+
+ printf("ERROR #3\n");
+ return(1);
+ }
+
+ if (verify_time_values(idle_time, expected_idle_time) != 0U)
+ {
+
+ printf("ERROR #4\n");
+ return(1);
+ }
+
+ printf("SUCCESS!\n");
+ return(0);
+}