initial test harness for smp regression

This commit is contained in:
2026-03-24 18:00:50 +01:00
parent 7253aadd52
commit c11f68d20c
8 changed files with 605 additions and 12 deletions

View File

@@ -19,6 +19,10 @@ add_subdirectory(${THREADX4TGFS_ROOT}/third-party/threadx ${CMAKE_BINARY_DIR}/th
target_link_libraries(threadx PUBLIC c)
target_compile_definitions(threadx PUBLIC TX_REGRESSION_TEST)
add_subdirectory(${THREADX4TGFS_ROOT}/port/threadx_smp ${CMAKE_BINARY_DIR}/port/threadx_smp)
target_link_libraries(threadx_smp PUBLIC c)
target_compile_definitions(threadx_smp PUBLIC TX_REGRESSION_TEST TX_THREAD_SMP_ONLY_CORE_0_DEFAULT TX_SMP_NOT_POSSIBLE)
project(threadx_regression C ASM)
enable_testing()
set(TARGET_MEM "ram_dram" CACHE STRING "memory map to use")
@@ -60,11 +64,15 @@ set_source_files_properties(${MOONLIGHT_TRAP_SOURCE} PROPERTIES GENERATED TRUE)
add_subdirectory(${THREADX4TGFS_ROOT}/port/moonlight ${CMAKE_BINARY_DIR}/port/moonlight)
add_dependencies(moonlight_platform_common threadx_regression_generated_trap)
if(TARGET moonlight_platform_common_smp)
add_dependencies(moonlight_platform_common_smp threadx_regression_generated_trap)
endif()
function(setup_target TARGET)
set(options)
set(oneValueArgs PLATFORM_TARGET)
set(multiValueArgs LIBRARIES SOURCES)
cmake_parse_arguments(ST "${options}" "" "${multiValueArgs}" ${ARGN})
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(ST_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
endif()
@@ -73,7 +81,11 @@ function(setup_target TARGET)
set_target_properties(${TARGET} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
)
target_add_moonlight_platform(${TARGET})
if(ST_PLATFORM_TARGET)
target_add_moonlight_platform(${TARGET} PLATFORM_TARGET ${ST_PLATFORM_TARGET})
else()
target_add_moonlight_platform(${TARGET})
endif()
if(ST_SOURCES)
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
@@ -100,3 +112,4 @@ function(setup_target TARGET)
endfunction()
add_subdirectory(threadx regression_targets)
add_subdirectory(smp smp_regression_targets)

178
test/smp/CMakeLists.txt Normal file
View File

@@ -0,0 +1,178 @@
set(TX_REGRESSION_DIR
${THREADX4TGFS_ROOT}/third-party/threadx/test/smp/regression
)
set(TX_CMAKE_DIR
${THREADX4TGFS_ROOT}/third-party/threadx/test/tx/cmake
)
set(TX_REGRESSION_CASES
${TX_REGRESSION_DIR}/threadx_block_memory_basic_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_error_detection_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_information_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_prioritize_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_suspension_timeout_test.c
${TX_REGRESSION_DIR}/threadx_block_memory_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_basic_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_information_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_prioritize_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_suspension_timeout_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_contention_test.c
${TX_REGRESSION_DIR}/threadx_byte_memory_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_basic_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_information_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_isr_set_clear_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_isr_wait_abort_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_single_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_consume_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_different_bits_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_suspension_timeout_test.c
${TX_REGRESSION_DIR}/threadx_event_flag_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_interrupt_control_test.c
${TX_REGRESSION_DIR}/threadx_mutex_basic_test.c
${TX_REGRESSION_DIR}/threadx_mutex_delete_test.c
${TX_REGRESSION_DIR}/threadx_mutex_information_test.c
${TX_REGRESSION_DIR}/threadx_mutex_nested_priority_inheritance_test.c
${TX_REGRESSION_DIR}/threadx_mutex_no_preemption_test.c
${TX_REGRESSION_DIR}/threadx_mutex_preemption_test.c
${TX_REGRESSION_DIR}/threadx_mutex_priority_inheritance_test.c
${TX_REGRESSION_DIR}/threadx_mutex_proritize_test.c
${TX_REGRESSION_DIR}/threadx_mutex_suspension_timeout_test.c
${TX_REGRESSION_DIR}/threadx_mutex_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_eight_word_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_four_word_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_one_word_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_sixteen_word_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_two_word_test.c
${TX_REGRESSION_DIR}/threadx_queue_basic_max_message_size_test.c
${TX_REGRESSION_DIR}/threadx_queue_empty_suspension_test.c
${TX_REGRESSION_DIR}/threadx_queue_flush_no_suspension_test.c
${TX_REGRESSION_DIR}/threadx_queue_flush_test.c
${TX_REGRESSION_DIR}/threadx_queue_front_send_test.c
${TX_REGRESSION_DIR}/threadx_queue_full_suspension_test.c
${TX_REGRESSION_DIR}/threadx_queue_information_test.c
${TX_REGRESSION_DIR}/threadx_queue_prioritize.c
${TX_REGRESSION_DIR}/threadx_queue_suspension_timeout_test.c
${TX_REGRESSION_DIR}/threadx_queue_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_basic_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_ceiling_put_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_delete_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_information_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_non_preemption_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_preemption_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_prioritize.c
${TX_REGRESSION_DIR}/threadx_semaphore_thread_terminate_test.c
${TX_REGRESSION_DIR}/threadx_semaphore_timeout_test.c
${TX_REGRESSION_DIR}/threadx_smp_multiple_threads_one_core_test.c
${TX_REGRESSION_DIR}/threadx_smp_non_trivial_scheduling_test.c
${TX_REGRESSION_DIR}/threadx_smp_one_thread_dynamic_exclusion_test.c
${TX_REGRESSION_DIR}/threadx_smp_preemption_threshold_test.c
${TX_REGRESSION_DIR}/threadx_smp_random_resume_suspend_exclusion_pt_test.c
${TX_REGRESSION_DIR}/threadx_smp_random_resume_suspend_exclusion_test.c
${TX_REGRESSION_DIR}/threadx_smp_random_resume_suspend_test.c
${TX_REGRESSION_DIR}/threadx_smp_rebalance_exclusion_test.c
${TX_REGRESSION_DIR}/threadx_smp_relinquish_test.c
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_accending_order_test.c
${TX_REGRESSION_DIR}/threadx_smp_resume_suspend_decending_order_test.c
${TX_REGRESSION_DIR}/threadx_smp_time_slice_test.c
${TX_REGRESSION_DIR}/threadx_smp_two_threads_one_core_test.c
${TX_REGRESSION_DIR}/threadx_thread_basic_execution_test.c
${TX_REGRESSION_DIR}/threadx_thread_basic_time_slice_test.c
${TX_REGRESSION_DIR}/threadx_thread_completed_test.c
${TX_REGRESSION_DIR}/threadx_thread_create_preemption_threshold_test.c
${TX_REGRESSION_DIR}/threadx_thread_delayed_suspension_test.c
${TX_REGRESSION_DIR}/threadx_thread_information_test.c
${TX_REGRESSION_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
${TX_REGRESSION_DIR}/threadx_thread_multiple_non_current_test.c
${TX_REGRESSION_DIR}/threadx_thread_multiple_sleep_test.c
${TX_REGRESSION_DIR}/threadx_thread_multiple_suspension_test.c
${TX_REGRESSION_DIR}/threadx_thread_multiple_time_slice_test.c
${TX_REGRESSION_DIR}/threadx_thread_preemptable_suspension_test.c
${TX_REGRESSION_DIR}/threadx_thread_preemption_change_test.c
${TX_REGRESSION_DIR}/threadx_thread_priority_change.c
${TX_REGRESSION_DIR}/threadx_thread_relinquish_test.c
${TX_REGRESSION_DIR}/threadx_thread_reset_test.c
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_non_clear_test.c
${TX_REGRESSION_DIR}/threadx_thread_simple_sleep_test.c
${TX_REGRESSION_DIR}/threadx_thread_simple_suspend_test.c
${TX_REGRESSION_DIR}/threadx_thread_sleep_for_100ticks_test.c
${TX_REGRESSION_DIR}/threadx_thread_sleep_terminate_test.c
${TX_REGRESSION_DIR}/threadx_thread_stack_checking_test.c
${TX_REGRESSION_DIR}/threadx_thread_terminate_delete_test.c
${TX_REGRESSION_DIR}/threadx_thread_time_slice_change_test.c
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_and_isr_test.c
${TX_REGRESSION_DIR}/threadx_thread_wait_abort_test.c
${TX_REGRESSION_DIR}/threadx_time_get_set_test.c
${TX_REGRESSION_DIR}/threadx_timer_activate_deactivate_test.c
${TX_REGRESSION_DIR}/threadx_timer_deactivate_accuracy_test.c
${TX_REGRESSION_DIR}/threadx_timer_information_test.c
${TX_REGRESSION_DIR}/threadx_timer_large_timer_accuracy_test.c
${TX_REGRESSION_DIR}/threadx_timer_multiple_accuracy_test.c
${TX_REGRESSION_DIR}/threadx_timer_multiple_test.c
${TX_REGRESSION_DIR}/threadx_timer_simple_test.c
#${TX_REGRESSION_DIR}/threadx_trace_basic_test.c # requires windows specific port
${TX_REGRESSION_DIR}/threadx_initialize_kernel_setup_test.c
)
set(TX_REGRESSION_TARGETS)
add_library(
threadx_smp_regression_support STATIC
${TX_REGRESSION_DIR}/testcontrol.c
${TX_CMAKE_DIR}/samples/fake.c
)
target_link_libraries(threadx_smp_regression_support PUBLIC threadx_smp c)
target_compile_definitions(
threadx_smp_regression_support
PUBLIC
TX_REGRESSION_TEST
TX_THREAD_SMP_ONLY_CORE_0_DEFAULT
TX_SMP_NOT_POSSIBLE
CTEST
BATCH_TEST
TEST_STACK_SIZE_PRINTF=4096
)
function(add_threadx_regression_test TEST_SOURCE)
get_filename_component(TEST_NAME ${TEST_SOURCE} NAME_WE)
set(TARGET_NAME smp_${TEST_NAME})
set(CTEST_NAME smp_${TEST_NAME})
if(TEST_NAME STREQUAL "threadx_initialize_kernel_setup_test")
set(test_libraries threadx_smp)
else()
set(test_libraries threadx_smp_regression_support)
endif()
setup_target(
${TARGET_NAME}
PLATFORM_TARGET moonlight_platform_common_smp
LIBRARIES ${test_libraries}
SOURCES ${TEST_SOURCE}
)
list(APPEND TX_REGRESSION_TARGETS ${TARGET_NAME})
set(TX_REGRESSION_TARGETS ${TX_REGRESSION_TARGETS} PARENT_SCOPE)
add_test(
NAME ${CTEST_NAME}
COMMAND ${THREADX_TEST_SIMULATOR}
--isa=${THREADX_TEST_ISA}
-f $<TARGET_FILE:${TARGET_NAME}>
-m 60s
)
set_tests_properties(${CTEST_NAME} PROPERTIES TIMEOUT 10)
endfunction()
foreach(test_case ${TX_REGRESSION_CASES})
add_threadx_regression_test(${test_case})
endforeach()
add_custom_target(
threadx_smp_regression_build
DEPENDS ${TX_REGRESSION_TARGETS}
)

View File

@@ -16,7 +16,7 @@ if [ -z "$line" ]; then
exit 1
fi
sed "${line}a\\
extern void test_interrupt_dispatch(void);" "$src" > "$tmp1"
void test_interrupt_dispatch(void) __attribute__((weak));\nvoid test_interrupt_dispatch(void) {}" "$src" > "$tmp1"
line=$(grep -n -F "$call_anchor" "$tmp1" | head -n 1 | cut -d: -f1)
if [ -z "$line" ]; then