summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrédéric Desbiens <[email protected]>2026-06-22 08:03:46 -0400
committerGitHub <[email protected]>2026-06-22 08:03:46 -0400
commitb880ffeadab06d008529fad99bb50457af4d9d16 (patch)
tree04d9e2c76e28502dc1557e67362f55015f28d99e /test
parent859c098747ce58dc9b88b662aac67a704af4614a (diff)
Fixed SMP execution profile total getters (#553)
Updated the SMP execution profile aggregate getters to copy each core's total into the matching output array element. Added a focused regression test for thread, ISR, and idle total getters. Co-authored-by: Codex <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/smp/cmake/regression/CMakeLists.txt16
-rw-r--r--test/smp/regression/execution_profile_test/tx_api.h40
-rw-r--r--test/smp/regression/threadx_smp_execution_profile_get_test.c126
3 files changed, 182 insertions, 0 deletions
diff --git a/test/smp/cmake/regression/CMakeLists.txt b/test/smp/cmake/regression/CMakeLists.txt
index b448ae3e..908ac5c7 100644
--- a/test/smp/cmake/regression/CMakeLists.txt
+++ b/test/smp/cmake/regression/CMakeLists.txt
@@ -162,3 +162,19 @@ foreach(test_case ${regression_test_cases})
target_link_libraries(${test_name} PRIVATE azrtos::threadx_smp)
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
endforeach()
+
+add_executable(threadx_smp_execution_profile_get_test
+ ${SOURCE_DIR}/threadx_smp_execution_profile_get_test.c
+ ${REPO_ROOT}/utility/execution_profile_kit/smp_version/tx_execution_profile.c)
+target_include_directories(threadx_smp_execution_profile_get_test
+ PRIVATE
+ ${SOURCE_DIR}/execution_profile_test
+ ${REPO_ROOT}/utility/execution_profile_kit/smp_version)
+target_compile_definitions(threadx_smp_execution_profile_get_test
+ PRIVATE CTEST BATCH_TEST TEST_STACK_SIZE_PRINTF=4096)
+if(NOT MSVC)
+ target_compile_options(threadx_smp_execution_profile_get_test PRIVATE -m64)
+ target_link_options(threadx_smp_execution_profile_get_test PRIVATE -m64)
+endif()
+add_test(${CMAKE_BUILD_TYPE}::threadx_smp_execution_profile_get_test
+ threadx_smp_execution_profile_get_test)
diff --git a/test/smp/regression/execution_profile_test/tx_api.h b/test/smp/regression/execution_profile_test/tx_api.h
new file mode 100644
index 00000000..aef253c6
--- /dev/null
+++ b/test/smp/regression/execution_profile_test/tx_api.h
@@ -0,0 +1,40 @@
+/***************************************************************************
+ * 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
+ **************************************************************************/
+
+#ifndef TX_API_H
+#define TX_API_H
+
+#define TX_THREAD_SMP_MAX_CORES 4U
+#define TX_SUCCESS 0U
+#define TX_NOT_DONE 20U
+#define TX_NULL ((void *) 0)
+#define TX_SMP_CORE_ID 0U
+
+typedef unsigned int UINT;
+typedef unsigned long ULONG;
+typedef void VOID;
+
+typedef struct TX_THREAD_STRUCT
+{
+ unsigned long long tx_thread_execution_time_total;
+ unsigned long tx_thread_execution_time_last_start;
+ struct TX_THREAD_STRUCT *tx_thread_created_next;
+} TX_THREAD;
+
+#define TX_INTERRUPT_SAVE_AREA
+#define TX_DISABLE
+#define TX_RESTORE
+
+#endif
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);
+}