Skip to content

Commit c597601

Browse files
committed
tests: run cJSON_test{,_utils} along with the other tests
1 parent e3d5798 commit c597601

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,24 @@ if(ENABLE_CJSON_TEST)
167167
add_executable("${TEST_CJSON}" test.c)
168168
target_link_libraries("${TEST_CJSON}" "${CJSON_LIB}")
169169

170+
add_test(NAME ${TEST_CJSON} COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TEST_CJSON}")
171+
# Disable -fsanitize=float-divide-by-zero for cJSON_test
172+
list(FIND custom_compiler_flags "-fsanitize=float-divide-by-zero" float_divide_by_zero_found)
173+
if (float_divide_by_zero_found)
174+
target_compile_options(${TEST_CJSON} PRIVATE "-fno-sanitize=float-divide-by-zero")
175+
endif()
176+
170177
if(ENABLE_CJSON_UTILS)
171178
set(TEST_CJSON_UTILS cJSON_test_utils)
172179
add_executable("${TEST_CJSON_UTILS}" test_utils.c)
173180
target_link_libraries("${TEST_CJSON_UTILS}" "${CJSON_UTILS_LIB}")
181+
182+
add_test(NAME ${TEST_CJSON_UTILS} COMMAND "${CMAKE_CURRENT_BINARY_DIR}/${TEST_CJSON_UTILS}")
174183
endif()
184+
185+
#"check" target that automatically builds everything and runs the tests
186+
add_custom_target(check
187+
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
188+
DEPENDS ${unity_tests} ${TEST_CJSON} ${TEST_CJSON_UTILS})
189+
175190
endif()

tests/CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,12 @@ if(ENABLE_CJSON_TEST)
4646
endif()
4747
endif()
4848

49-
#"check" target that automatically builds everything and runs the tests
50-
add_custom_target(check
51-
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
52-
DEPENDS ${unity_tests})
53-
5449
foreach(unity_test ${unity_tests})
5550
add_executable("${unity_test}" "${unity_test}.c")
5651
target_link_libraries("${unity_test}" "${CJSON_LIB}" unity test-common)
5752
if(MEMORYCHECK_COMMAND)
5853
add_test(NAME "${unity_test}"
59-
COMMAND "${MEMORYCHECK_COMMAND}" ${MEMORYCHECK_COMMAND_OPTIONS} "./${unity_test}")
54+
COMMAND "${MEMORYCHECK_COMMAND}" ${MEMORYCHECK_COMMAND_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${unity_test}")
6055
else()
6156
add_test(NAME "${unity_test}"
6257
COMMAND "./${unity_test}")

0 commit comments

Comments
 (0)