File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -166,3 +166,9 @@ IF ( DOXYGEN_EXECUTABLE )
166166 CONFIGURE_FILE (doc /Doxyfile.in Doxyfile @ONLY)
167167 ADD_CUSTOM_TARGET (docs ${DOXYGEN_EXECUTABLE} "Doxyfile" )
168168ENDIF ( DOXYGEN_EXECUTABLE )
169+
170+ ###########################################################
171+ # TESTS
172+ ###########################################################
173+
174+ add_subdirectory (tests)
Original file line number Diff line number Diff line change 1+ include (CTest)
2+
3+ # catkin compatibility
4+ if (NOT TARGET run_tests)
5+ add_custom_target (run_tests)
6+ endif ()
7+
8+ if (BUILD_TESTING)
9+ set (TESTS
10+ testmain
11+ testCategory testFixedContextCategory testNDC testPattern
12+ testErrorCollision testPriority testFilter testProperties
13+ testConfig testPropertyConfig testRollingFileAppender testDailyRollingFileAppender
14+ )
15+
16+ set (DATA log4cpp.init log4cpp.properties testProperties.properties
17+ testConfig.log4cpp.properties testConfig.log4cpp.dailyroll.properties
18+ )
19+
20+ # copy test data
21+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
22+ foreach (file ${DATA} )
23+ configure_file (${file} ${CMAKE_CURRENT_BINARY_DIR} /${file} COPYONLY )
24+ endforeach ()
25+
26+ include_directories (
27+ ${PROJECT_SOURCE_DIR} /include
28+ ${PROJECT_SOURCE_DIR} /src
29+ )
30+
31+ foreach (test ${TESTS} )
32+ add_executable (${test} EXCLUDE_FROM_ALL ${test} .cpp)
33+ target_link_libraries (${test} ${LOG4CPP_LIBRARY_NAME} -pthread)
34+ add_test (NAME ${test} COMMAND ${test} )
35+ endforeach ()
36+
37+ add_executable (testbench EXCLUDE_FROM_ALL Clock.cpp Clock.hh testbench.cpp)
38+ target_link_libraries (testbench ${LOG4CPP_LIBRARY_NAME} -pthread)
39+ add_test (NAME testbench COMMAND testbench)
40+
41+ add_custom_target (check
42+ COMMAND ctest -V
43+ DEPENDS ${TESTS} testbench
44+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
45+ )
46+
47+ add_dependencies (run_tests check)
48+ endif ()
You can’t perform that action at this time.
0 commit comments