sitl_tests.cmake
4.35 KB
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
#=============================================================================
# tests
#
# tests command arguments
set(tests
atomic_bitset
bezier
bitset
bson
conv
dataman
file2
float
hrt
int
IntrusiveQueue
IntrusiveSortedList
List
mathlib
matrix
microbench_atomic
microbench_hrt
microbench_math
microbench_matrix
microbench_uorb
mixer
param
parameters
perf
search_min
servo
sleep
versioning
)
foreach(test_name ${tests})
set(test_name_prefix sitl-${test_name})
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_${test_name}_generated)
add_test(NAME ${test_name_prefix}
COMMAND $<TARGET_FILE:px4>
-s ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_${test_name}_generated
-t ${PX4_SOURCE_DIR}/test_data
${PX4_SOURCE_DIR}/ROMFS/px4fmu_test
WORKING_DIRECTORY ${SITL_WORKING_DIR}
)
set_tests_properties(${test_name_prefix} PROPERTIES FAIL_REGULAR_EXPRESSION "${test_name} FAILED")
set_tests_properties(${test_name_prefix} PROPERTIES PASS_REGULAR_EXPRESSION "${test_name} PASSED")
sanitizer_fail_test_on_error(${test_name_prefix})
endforeach()
# standalone tests
set(cmd_tests
commander_tests
controllib_test
lightware_laser_test
rc_tests
uorb_tests
)
foreach(test_name ${cmd_tests})
set(test_name_prefix sitl-${test_name})
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_cmd_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_${test_name}_generated)
add_test(NAME ${test_name_prefix}
COMMAND $<TARGET_FILE:px4>
-s ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_${test_name}_generated
-t ${PX4_SOURCE_DIR}/test_data
${PX4_SOURCE_DIR}/ROMFS/px4fmu_test
WORKING_DIRECTORY ${SITL_WORKING_DIR}
)
set_tests_properties(${test_name_prefix} PROPERTIES FAIL_REGULAR_EXPRESSION "FAIL")
set_tests_properties(${test_name_prefix} PROPERTIES PASS_REGULAR_EXPRESSION "PASS")
sanitizer_fail_test_on_error(${test_name_prefix})
endforeach()
# Mavlink test requires mavlink running
add_test(NAME sitl-mavlink
COMMAND $<TARGET_FILE:px4>
-s ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_mavlink
-t ${PX4_SOURCE_DIR}/test_data
${PX4_SOURCE_DIR}/ROMFS/px4fmu_test
WORKING_DIRECTORY ${SITL_WORKING_DIR}
)
set_tests_properties(sitl-mavlink PROPERTIES FAIL_REGULAR_EXPRESSION "FAIL")
set_tests_properties(sitl-mavlink PROPERTIES PASS_REGULAR_EXPRESSION "ALL TESTS PASSED")
sanitizer_fail_test_on_error(sitl-mavlink)
# # Shutdown test
# add_test(NAME sitl-shutdown
# COMMAND $<TARGET_FILE:px4>
# -s ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_shutdown
# -t ${PX4_SOURCE_DIR}/test_data
# ${PX4_SOURCE_DIR}/ROMFS/px4fmu_test
# WORKING_DIRECTORY ${SITL_WORKING_DIR}
# )
# #set_tests_properties(shutdown PROPERTIES FAIL_REGULAR_EXPRESSION "shutdown FAILED")
# set_tests_properties(sitl-shutdown PROPERTIES PASS_REGULAR_EXPRESSION "Exiting NOW.")
# sanitizer_fail_test_on_error(sitl-shutdown)
# Dynamic module loading test
add_test(NAME dyn
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
none
none
test_dyn_hello
none
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
$<TARGET_FILE:examples__dyn_hello>
WORKING_DIRECTORY ${SITL_WORKING_DIR})
set_tests_properties(dyn PROPERTIES PASS_REGULAR_EXPRESSION "1: PASSED")
sanitizer_fail_test_on_error(dyn)
# run arbitrary commands
set(test_cmds
hrt_test
cdev_test
wqueue_test
)
foreach(cmd_name ${test_cmds})
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/cmd_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/cmd_${cmd_name}_generated)
add_test(NAME posix_${cmd_name}
COMMAND $<TARGET_FILE:px4>
${PX4_SOURCE_DIR}/ROMFS/px4fmu_test
-s ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/cmd_${cmd_name}_generated
-t ${PX4_SOURCE_DIR}/test_data
WORKING_DIRECTORY ${SITL_WORKING_DIR}
)
sanitizer_fail_test_on_error(posix_${cmd_name})
set_tests_properties(posix_${cmd_name} PROPERTIES PASS_REGULAR_EXPRESSION "Exiting NOW.")
endforeach()
if(CMAKE_BUILD_TYPE STREQUAL Coverage)
setup_target_for_coverage(test_coverage "${CMAKE_CTEST_COMMAND} --output-on-failure -T Test" tests)
setup_target_for_coverage(generate_coverage "${CMAKE_COMMAND} -E echo" generic)
# TODO:
#setup_target_for_coverage(mavsdk_coverage "${PX4_SOURCE_DIR}/test/mavsdk_tests/mavsdk_test_runner.py --speed-factor 20 --iterations 1 --fail-early" mavsdk)
endif()