128 lines
3.2 KiB
CMake
Executable File
128 lines
3.2 KiB
CMake
Executable File
if (NOT BUILD_TESTING)
|
|
message("-- libdi tests disabled")
|
|
return()
|
|
endif()
|
|
message("-- libdi tests enabled")
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/src")
|
|
|
|
set(test_logdir "${CMAKE_CURRENT_BINARY_DIR}/log")
|
|
file(MAKE_DIRECTORY "${test_logdir}")
|
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
|
|
set(test_reportdir "${CMAKE_CURRENT_BINARY_DIR}/report")
|
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/report" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
|
|
configure_file("${test_reportdir}/libdi-test-report.tex.in" "${test_reportdir}/libdi-test-report.tex")
|
|
|
|
# TODO: we should generate TESTS list from GLOB *.cpp in this folder
|
|
set(TESTS
|
|
assert
|
|
array
|
|
buffer
|
|
can
|
|
can_bitops
|
|
can_crc
|
|
can_send
|
|
can_reassemble
|
|
can_callback
|
|
can_example
|
|
can_log
|
|
can_lowlevel
|
|
can_frame
|
|
can_framing
|
|
can_msg
|
|
can_msg_gc
|
|
can_msg_state
|
|
can_msg_write
|
|
can_msg_read
|
|
can_msg_recv
|
|
can_msg_reqrep
|
|
can_msg_timesync
|
|
can_net
|
|
can_net_discover
|
|
can_net_discover_fsm
|
|
can_net_node_events
|
|
can_net_node_error
|
|
can_net_node_uid
|
|
can_net_self
|
|
can_net_self_leader
|
|
# can_net_self_leader_giveup
|
|
can_raw
|
|
can_rpc
|
|
can_str
|
|
can_zkl
|
|
config
|
|
crc
|
|
# crypt_aes
|
|
# crypt_hmac_md5
|
|
# crypt_ivsi
|
|
# crypt_md5
|
|
device_activation
|
|
device_error
|
|
device_state
|
|
device_state_callback
|
|
device_token
|
|
device_uid
|
|
device_service
|
|
drv_hl854x
|
|
drv_hl854x_con
|
|
drv_hl854x_cme_error
|
|
drv_hl854x_gps_pvt
|
|
drv_hl854x_mec
|
|
drv_hl854x_net
|
|
drv_hl854x_str
|
|
drv_hl854x_read_timeout
|
|
drv_hl854x_tcp
|
|
errno
|
|
hash
|
|
logging
|
|
# encryption
|
|
encoding_me
|
|
misc_hexstr
|
|
pp
|
|
mpack
|
|
rpc
|
|
rpc_serialize
|
|
rpc_serialize_data
|
|
rpc_serialize_msg
|
|
rpc_deserialize_msg
|
|
rpc_deserialize_msg_params
|
|
rpc_lowlevel
|
|
rpc_lowlevel_decode
|
|
rpc_lowlevel_encode
|
|
rpc_lowlevel_rpc_writer
|
|
semaphore
|
|
stdio
|
|
time
|
|
)
|
|
|
|
include("${DI_COMMON_CMAKE_DIR}/libs/gtest.txt")
|
|
find_package(Threads)
|
|
|
|
set(gtest_xml_dir "${CMAKE_CURRENT_BINARY_DIR}/gtest")
|
|
file(MAKE_DIRECTORY ${gtest_xml_dir})
|
|
|
|
foreach(test ${TESTS})
|
|
set(test_path "${CMAKE_CURRENT_BINARY_DIR}/${test}")
|
|
set(test_args "--gtest_output=xml:${gtest_xml_dir}/${test}.xml")
|
|
|
|
add_executable(${test} ${test}.cpp)
|
|
# -Wno-old-style-cast -> Ignore old style warnings because we actual test C
|
|
# -Wno-write-strings -> C++ deprecates string writing, ignore
|
|
# -fno-exceptions -> Disable exceptions because branches are incorrect reported, and this is C code..
|
|
set_source_files_properties(${test}.cpp PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast -Wno-write-strings -fno-exceptions")
|
|
add_dependencies(${test} di gtest)
|
|
target_link_libraries(${test} di)
|
|
target_link_libraries(${test} ${gtest_library})
|
|
target_link_libraries(${test} ${gtest_main_library})
|
|
target_link_libraries(${test} ${CMAKE_THREAD_LIBS_INIT})
|
|
add_test(NAME "${test}" COMMAND "${test_path}" "${test_args}")
|
|
set_property(TEST "${test}" PROPERTY ENVIRONMENT "TESTNAME=${test}")
|
|
endforeach()
|
|
|
|
add_test(NAME "json_validator" COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/json_validator.py" "${test_logdir}")
|
|
set_property(TEST "json_validator" PROPERTY ENVIRONMENT "TESTNAME=json_validator")
|
|
|
|
add_custom_target(test-report COMMAND "${CMAKE_SOURCE_DIR}/common/gtest-report/gtest-report.py" "'${gtest_xml_dir}/*.xml'" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
add_custom_target(test-report-pdf COMMAND "make" WORKING_DIRECTORY ${test_reportdir})
|