1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_policy(SET CMP0057 NEW)
project(module_manager_test LANGUAGES C)
set(REPO_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../..)
set(SOURCE_DIR ${REPO_ROOT}/test/tx/module_manager)
# The Module Manager is not part of the ThreadX library this test tree builds, and
# its control blocks come from a module port rather than a base port. These tests
# therefore compile the manager sources they exercise directly against one module
# port's headers, and stand stubs behind the kernel services those sources call, so
# that they run on the host like every other test here. It is the same technique the
# thread_transition directory uses, for the same reason: the code under test cannot
# be reached through the library the suite links.
#
# Every module port is an embedded architecture, so the interrupt primitives those
# sources use are inline assembly the host assembler cannot take. The port shim
# header is force-included ahead of every translation unit here and replaces the
# three of them with host equivalents that count.
set(module_manager_dir ${REPO_ROOT}/common_modules/module_manager)
set(cortex_a7_module_dir ${REPO_ROOT}/ports_module/cortex_a7/gnu)
set(cortex_m4_module_dir ${REPO_ROOT}/ports_module/cortex_m4/gnu)
add_executable(
threadx_module_manager_thread_kernel_stack_test
${SOURCE_DIR}/threadx_module_manager_thread_kernel_stack_test.c
${module_manager_dir}/src/txm_module_manager_util.c
${module_manager_dir}/src/txm_module_manager_object_allocate.c
${module_manager_dir}/src/txm_module_manager_object_deallocate.c)
target_include_directories(
threadx_module_manager_thread_kernel_stack_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_a7_module_dir}/inc)
# The dispatch layer is one header of static functions, one per kernel service. A
# test reaches the dispatcher it exercises by including that header, which defines
# every other dispatcher too, and an unoptimised build emits them all -- so their
# references to services this harness stands behind nothing for would reach the
# linker.
#
# The header guards each dispatcher with its own TXM_<SERVICE>_CALL_NOT_USED macro,
# which is the supported way to trim the dispatch table. Defining every guard except
# the ones a test needs leaves that test's translation unit holding only the
# dispatcher under test. The list is read out of the header rather than written down
# here, so a service added later is excluded without anyone having to remember.
file(STRINGS ${module_manager_dir}/inc/txm_module_manager_dispatch.h
dispatch_guard_lines REGEX "^#ifndef TXM_[A-Z0-9_]+_CALL_NOT_USED")
set(dispatch_guards "")
foreach(guard_line ${dispatch_guard_lines})
string(REGEX MATCH "TXM_[A-Z0-9_]+_CALL_NOT_USED" guard "${guard_line}")
list(APPEND dispatch_guards ${guard})
endforeach()
list(REMOVE_DUPLICATES dispatch_guards)
# The dispatchers this test calls, which therefore must stay in.
set(kernel_stack_dispatchers TXM_THREAD_DELETE_CALL_NOT_USED)
set(kernel_stack_guards ${dispatch_guards})
list(REMOVE_ITEM kernel_stack_guards ${kernel_stack_dispatchers})
target_compile_definitions(threadx_module_manager_thread_kernel_stack_test
PRIVATE ${kernel_stack_guards})
# The port shim is force-included ahead of every translation unit, the test included,
# because the manager sources and the dispatch header both reach for the port's
# interrupt primitives.
target_compile_options(
threadx_module_manager_thread_kernel_stack_test
PRIVATE -Wall
-Wextra
-include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_thread_kernel_stack_test
threadx_module_manager_thread_kernel_stack_test)
# This test drives the manager services directly rather than through a dispatcher,
# so it needs none of the dispatch table and no guard list.
add_executable(
threadx_module_manager_object_authentication_test
${SOURCE_DIR}/threadx_module_manager_object_authentication_test.c
${module_manager_dir}/src/txm_module_manager_util.c
${module_manager_dir}/src/txm_module_manager_object_allocate.c
${module_manager_dir}/src/txm_module_manager_object_deallocate.c
${module_manager_dir}/src/txm_module_manager_thread_reset.c)
target_include_directories(
threadx_module_manager_object_authentication_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_a7_module_dir}/inc)
target_compile_options(
threadx_module_manager_object_authentication_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_object_authentication_test
threadx_module_manager_object_authentication_test)
# This test drives the manager services directly rather than through a dispatcher,
# so it needs none of the dispatch table and no guard list.
add_executable(
threadx_module_manager_delete_ownership_test
${SOURCE_DIR}/threadx_module_manager_delete_ownership_test.c
${module_manager_dir}/src/txm_module_manager_util.c
${module_manager_dir}/src/txm_module_manager_object_allocate.c
${module_manager_dir}/src/txm_module_manager_object_deallocate.c)
target_include_directories(
threadx_module_manager_delete_ownership_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_a7_module_dir}/inc)
target_compile_options(
threadx_module_manager_delete_ownership_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_delete_ownership_test
threadx_module_manager_delete_ownership_test)
# This test drives the allocation and deallocation services directly rather than
# through a dispatcher, so it needs none of the dispatch table and no guard list.
add_executable(
threadx_module_manager_live_object_deallocation_test
${SOURCE_DIR}/threadx_module_manager_live_object_deallocation_test.c
${module_manager_dir}/src/txm_module_manager_util.c
${module_manager_dir}/src/txm_module_manager_object_allocate.c
${module_manager_dir}/src/txm_module_manager_object_deallocate.c)
target_include_directories(
threadx_module_manager_live_object_deallocation_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_a7_module_dir}/inc)
target_compile_options(
threadx_module_manager_live_object_deallocation_test
PRIVATE -Wall
-Wextra
-include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_live_object_deallocation_test
threadx_module_manager_live_object_deallocation_test)
add_executable(
threadx_module_manager_object_allocate_overflow_test
${SOURCE_DIR}/threadx_module_manager_object_allocate_overflow_test.c
${module_manager_dir}/src/txm_module_manager_util.c
${module_manager_dir}/src/txm_module_manager_object_allocate.c
${module_manager_dir}/src/txm_module_manager_object_deallocate.c)
target_include_directories(
threadx_module_manager_object_allocate_overflow_test
PRIVATE ${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_a7_module_dir}/inc)
target_compile_options(
threadx_module_manager_object_allocate_overflow_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_object_allocate_overflow_test
threadx_module_manager_object_allocate_overflow_test)
add_executable(
threadx_module_manager_block_pool_parameters_test
${SOURCE_DIR}/threadx_module_manager_block_pool_parameters_test.c
${module_manager_dir}/src/txm_module_manager_util.c)
target_include_directories(
threadx_module_manager_block_pool_parameters_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_m4_module_dir}/inc)
target_compile_options(
threadx_module_manager_block_pool_parameters_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_block_pool_parameters_test
threadx_module_manager_block_pool_parameters_test)
add_executable(
threadx_module_manager_object_name_range_test
${SOURCE_DIR}/threadx_module_manager_object_name_range_test.c
${module_manager_dir}/src/txm_module_manager_object_pointer_get.c
${module_manager_dir}/src/txm_module_manager_object_pointer_get_extended.c
${module_manager_dir}/src/txm_module_manager_util.c)
target_include_directories(
threadx_module_manager_object_name_range_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_m4_module_dir}/inc)
target_compile_options(
threadx_module_manager_object_name_range_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_object_name_range_test
threadx_module_manager_object_name_range_test)
add_executable(
threadx_module_manager_queue_message_range_test
${SOURCE_DIR}/threadx_module_manager_queue_message_range_test.c
${module_manager_dir}/src/txm_module_manager_util.c)
target_include_directories(
threadx_module_manager_queue_message_range_test
PRIVATE ${SOURCE_DIR}
${REPO_ROOT}/common/inc
${REPO_ROOT}/common_modules/inc
${module_manager_dir}/inc
${cortex_m4_module_dir}/inc)
target_compile_options(
threadx_module_manager_queue_message_range_test
PRIVATE -include ${SOURCE_DIR}/threadx_module_manager_host_test_port.h)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_queue_message_range_test
threadx_module_manager_queue_message_range_test)
add_executable(
threadx_module_manager_cortex_a7_range_check_test
${SOURCE_DIR}/threadx_module_manager_cortex_a7_range_check_test.c
${cortex_a7_module_dir}/module_manager/src/txm_module_manager_inside_data_check.c)
target_include_directories(
threadx_module_manager_cortex_a7_range_check_test
PRIVATE ${REPO_ROOT}/common/inc
${REPO_ROOT}/ports/cortex_a7/gnu/inc
${REPO_ROOT}/common_modules/inc
${REPO_ROOT}/common_modules/module_manager/inc
${cortex_a7_module_dir}/inc)
add_test(${CMAKE_BUILD_TYPE}::threadx_module_manager_cortex_a7_range_check_test
threadx_module_manager_cortex_a7_range_check_test)
|