1cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
2cmake_policy(SET CMP0057 NEW)
3
4project(regression_test LANGUAGES C)
5
6set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../regression)
7
8set(regression_test_cases
9    ${SOURCE_DIR}/threadx_block_memory_basic_test.c
10    ${SOURCE_DIR}/threadx_block_memory_error_detection_test.c
11    ${SOURCE_DIR}/threadx_block_memory_information_test.c
12    ${SOURCE_DIR}/threadx_block_memory_prioritize_test.c
13    ${SOURCE_DIR}/threadx_block_memory_suspension_test.c
14    ${SOURCE_DIR}/threadx_block_memory_suspension_timeout_test.c
15    ${SOURCE_DIR}/threadx_block_memory_thread_terminate_test.c
16    ${SOURCE_DIR}/threadx_byte_memory_basic_test.c
17    ${SOURCE_DIR}/threadx_byte_memory_information_test.c
18    ${SOURCE_DIR}/threadx_byte_memory_prioritize_test.c
19    ${SOURCE_DIR}/threadx_byte_memory_suspension_test.c
20    ${SOURCE_DIR}/threadx_byte_memory_suspension_timeout_test.c
21    ${SOURCE_DIR}/threadx_byte_memory_thread_contention_test.c
22    ${SOURCE_DIR}/threadx_byte_memory_thread_terminate_test.c
23    ${SOURCE_DIR}/threadx_event_flag_basic_test.c
24    ${SOURCE_DIR}/threadx_event_flag_information_test.c
25    ${SOURCE_DIR}/threadx_event_flag_isr_set_clear_test.c
26    ${SOURCE_DIR}/threadx_event_flag_isr_wait_abort_test.c
27    ${SOURCE_DIR}/threadx_event_flag_single_thread_terminate_test.c
28    ${SOURCE_DIR}/threadx_event_flag_suspension_consume_test.c
29    ${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
30    ${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_test.c
31    ${SOURCE_DIR}/threadx_event_flag_suspension_test.c
32    ${SOURCE_DIR}/threadx_event_flag_suspension_timeout_test.c
33    ${SOURCE_DIR}/threadx_event_flag_thread_terminate_test.c
34    ${SOURCE_DIR}/threadx_interrupt_control_test.c
35    ${SOURCE_DIR}/threadx_mutex_basic_test.c
36    ${SOURCE_DIR}/threadx_mutex_delete_test.c
37    ${SOURCE_DIR}/threadx_mutex_information_test.c
38    ${SOURCE_DIR}/threadx_mutex_nested_priority_inheritance_test.c
39    ${SOURCE_DIR}/threadx_mutex_no_preemption_test.c
40    ${SOURCE_DIR}/threadx_mutex_preemption_test.c
41    ${SOURCE_DIR}/threadx_mutex_priority_inheritance_test.c
42    ${SOURCE_DIR}/threadx_mutex_proritize_test.c
43    ${SOURCE_DIR}/threadx_mutex_suspension_timeout_test.c
44    ${SOURCE_DIR}/threadx_mutex_thread_terminate_test.c
45    ${SOURCE_DIR}/threadx_queue_basic_eight_word_test.c
46    ${SOURCE_DIR}/threadx_queue_basic_four_word_test.c
47    ${SOURCE_DIR}/threadx_queue_basic_one_word_test.c
48    ${SOURCE_DIR}/threadx_queue_basic_sixteen_word_test.c
49    ${SOURCE_DIR}/threadx_queue_basic_two_word_test.c
50    ${SOURCE_DIR}/threadx_queue_empty_suspension_test.c
51    ${SOURCE_DIR}/threadx_queue_flush_no_suspension_test.c
52    ${SOURCE_DIR}/threadx_queue_flush_test.c
53    ${SOURCE_DIR}/threadx_queue_front_send_test.c
54    ${SOURCE_DIR}/threadx_queue_full_suspension_test.c
55    ${SOURCE_DIR}/threadx_queue_information_test.c
56    ${SOURCE_DIR}/threadx_queue_prioritize.c
57    ${SOURCE_DIR}/threadx_queue_suspension_timeout_test.c
58    ${SOURCE_DIR}/threadx_queue_thread_terminate_test.c
59    ${SOURCE_DIR}/threadx_semaphore_basic_test.c
60    ${SOURCE_DIR}/threadx_semaphore_ceiling_put_test.c
61    ${SOURCE_DIR}/threadx_semaphore_delete_test.c
62    ${SOURCE_DIR}/threadx_semaphore_information_test.c
63    ${SOURCE_DIR}/threadx_semaphore_non_preemption_test.c
64    ${SOURCE_DIR}/threadx_semaphore_preemption_test.c
65    ${SOURCE_DIR}/threadx_semaphore_prioritize.c
66    ${SOURCE_DIR}/threadx_semaphore_thread_terminate_test.c
67    ${SOURCE_DIR}/threadx_semaphore_timeout_test.c
68    ${SOURCE_DIR}/threadx_thread_basic_execution_test.c
69    ${SOURCE_DIR}/threadx_thread_basic_time_slice_test.c
70    ${SOURCE_DIR}/threadx_thread_completed_test.c
71    ${SOURCE_DIR}/threadx_thread_create_preemption_threshold_test.c
72    ${SOURCE_DIR}/threadx_thread_delayed_suspension_test.c
73    ${SOURCE_DIR}/threadx_thread_information_test.c
74    ${SOURCE_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
75    ${SOURCE_DIR}/threadx_thread_multiple_non_current_test.c
76    ${SOURCE_DIR}/threadx_thread_multiple_sleep_test.c
77    ${SOURCE_DIR}/threadx_thread_multiple_suspension_test.c
78    ${SOURCE_DIR}/threadx_thread_multiple_time_slice_test.c
79    ${SOURCE_DIR}/threadx_thread_preemptable_suspension_test.c
80    ${SOURCE_DIR}/threadx_thread_preemption_change_test.c
81    ${SOURCE_DIR}/threadx_thread_priority_change.c
82    ${SOURCE_DIR}/threadx_thread_relinquish_test.c
83    ${SOURCE_DIR}/threadx_thread_reset_test.c
84    ${SOURCE_DIR}/threadx_thread_simple_sleep_non_clear_test.c
85    ${SOURCE_DIR}/threadx_thread_simple_sleep_test.c
86    ${SOURCE_DIR}/threadx_thread_simple_suspend_test.c
87    ${SOURCE_DIR}/threadx_thread_sleep_for_100ticks_test.c
88    ${SOURCE_DIR}/threadx_thread_sleep_terminate_test.c
89    ${SOURCE_DIR}/threadx_thread_stack_checking_test.c
90    ${SOURCE_DIR}/threadx_thread_terminate_delete_test.c
91    ${SOURCE_DIR}/threadx_thread_time_slice_change_test.c
92    ${SOURCE_DIR}/threadx_thread_wait_abort_and_isr_test.c
93    ${SOURCE_DIR}/threadx_thread_wait_abort_test.c
94    ${SOURCE_DIR}/threadx_time_get_set_test.c
95    ${SOURCE_DIR}/threadx_timer_activate_deactivate_test.c
96    ${SOURCE_DIR}/threadx_timer_deactivate_accuracy_test.c
97    ${SOURCE_DIR}/threadx_timer_information_test.c
98    ${SOURCE_DIR}/threadx_timer_large_timer_accuracy_test.c
99    ${SOURCE_DIR}/threadx_timer_multiple_accuracy_test.c
100    ${SOURCE_DIR}/threadx_timer_multiple_test.c
101    ${SOURCE_DIR}/threadx_timer_simple_test.c
102    ${SOURCE_DIR}/threadx_trace_basic_test.c
103    ${SOURCE_DIR}/threadx_initialize_kernel_setup_test.c)
104
105add_custom_command(
106  OUTPUT ${SOURCE_DIR}/tx_initialize_low_level.c
107  COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_test_file.sh
108  COMMENT "Generating tx_initialize_low_level.c for test")
109
110add_library(test_utility ${SOURCE_DIR}/tx_initialize_low_level.c
111                         ${SOURCE_DIR}/testcontrol.c)
112target_link_libraries(test_utility PUBLIC azrtos::threadx)
113target_compile_definitions(test_utility PUBLIC CTEST BATCH_TEST
114                                               TEST_STACK_SIZE_PRINTF=4096)
115
116foreach(test_case ${regression_test_cases})
117  get_filename_component(test_name ${test_case} NAME_WE)
118  add_executable(${test_name} ${test_case})
119  target_link_libraries(${test_name} PRIVATE test_utility)
120  add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
121endforeach()
122