Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cmake commands are redundant with root CMakeLists.txt.
[simgrid.git] / tools / cmake / Tests.cmake
1 SET(TESH_OPTION "--ignore-jenkins")
2 SET(TESH_COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_BINARY_DIR}/bin/tesh)
3
4 SET(TESH_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib")
5 if(NOT $ENV{LD_LIBRARY_PATH} STREQUAL "")
6   SET(TESH_LIBRARY_PATH "${TESH_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}")
7 endif()
8
9 IF(enable_memcheck)
10   INCLUDE(FindValgrind)
11
12   if (NOT VALGRIND_EXE MATCHES "NOTFOUND")
13     execute_process(COMMAND ${VALGRIND_EXE} --version  OUTPUT_VARIABLE "VALGRIND_VERSION")
14     message(STATUS "Valgrind version: ${VALGRIND_VERSION}")
15
16     set(TESH_WRAPPER ${CMAKE_HOME_DIRECTORY}/tools/cmake/scripts/my_valgrind.pl)
17     set(TESH_WRAPPER ${TESH_WRAPPER}\ --trace-children=yes\ --trace-children-skip=/usr/bin/*,/bin/*\ --leak-check=full\ --show-reachable=yes\ --track-origins=no\ --read-var-info=no\ --num-callers=20\ --suppressions=${CMAKE_HOME_DIRECTORY}/tools/simgrid.supp\ )
18     if(enable_memcheck_xml)
19       SET(TESH_WRAPPER ${TESH_WRAPPER}\ --xml=yes\ --xml-file=memcheck_test_%p.memcheck\ --child-silent-after-fork=yes\ )
20     endif()
21     set(TESH_OPTION ${TESH_OPTION} --setenv VALGRIND_NO_LEAK_CHECK=--leak-check=no\ --show-leak-kinds=none)
22
23 #    message(STATUS "tesh wrapper: ${TESH_WRAPPER}")
24
25     mark_as_advanced(TESH_WRAPPER)
26   else()
27     set(enable_memcheck false)
28     message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
29   endif()
30 ENDIF()
31 SET(TESH_WRAPPER_UNBOXED "${TESH_WRAPPER}")
32 SEPARATE_ARGUMENTS(TESH_WRAPPER_UNBOXED)
33
34 #some tests may take forever on non futexes systems, using busy_wait with n cores < n workers
35 # default to posix for these tests if futexes are not supported
36 IF(NOT HAVE_FUTEX_H)
37   SET(CONTEXTS_SYNCHRO --cfg contexts/synchro:posix)
38 ENDIF()
39
40 MACRO(ADD_TESH NAME)
41   SET(ARGT ${ARGV})
42   LIST(REMOVE_AT ARGT 0)
43   IF(WIN32)
44     STRING(REPLACE "§" "\;" ARGT "${ARGT}")
45   ENDIF()
46   if(TESH_WRAPPER)
47     ADD_TEST(${NAME} ${TESH_COMMAND} --wrapper "${TESH_WRAPPER}" ${TESH_OPTION} ${ARGT})
48   else()
49     ADD_TEST(${NAME} ${TESH_COMMAND} ${TESH_OPTION} ${ARGT})
50   endif()
51 ENDMACRO()
52
53 MACRO(ADD_TESH_FACTORIES NAME FACTORIES)
54   SET(ARGR ${ARGV})
55   LIST(REMOVE_AT ARGR 0) # remove name
56   FOREACH(I ${FACTORIES}) # remove all factories
57     LIST(REMOVE_AT ARGR 0)
58   ENDFOREACH()
59   FOREACH(FACTORY ${FACTORIES})
60     if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
61         (${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR
62         (${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR
63         (${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS))
64       ADD_TESH("${NAME}-${FACTORY}" "--cfg" "contexts/factory:${FACTORY}" ${ARGR})
65     ENDIF()
66   ENDFOREACH()
67 ENDMACRO()
68
69 MACRO(SET_TESH_PROPERTIES NAME FACTORIES)
70   SET(ARGR ${ARGV})
71   LIST(REMOVE_AT ARGR 0) # remove name
72   FOREACH(I ${FACTORIES}) # remove all factories
73     LIST(REMOVE_AT ARGR 0)
74   ENDFOREACH()
75   FOREACH(FACTORY ${FACTORIES})
76     if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads
77         (${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR
78         (${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR
79         (${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS))
80       set_tests_properties("${NAME}-${FACTORY}" PROPERTIES ${ARGR})
81     endif()
82   ENDFOREACH()
83 ENDMACRO()      
84
85 IF(enable_java)
86   IF(WIN32)
87     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/deprecated/java/\;${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_JAR}")
88     STRING(REPLACE "\;" "§" TESH_CLASSPATH "${TESH_CLASSPATH}")
89   ELSE()
90     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/deprecated/java/:${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_JAR}")
91   ENDIF()
92 ENDIF()
93
94 # New tests should use the Catch Framework
95 set(UNIT_TESTS  src/xbt/unit-tests_main.cpp
96                 src/kernel/resource/profile/Profile_test.cpp
97                 src/xbt/config_test.cpp
98                 src/xbt/dict_test.cpp
99                 src/xbt/dynar_test.cpp
100                 src/xbt/random_test.cpp
101                 src/xbt/xbt_str_test.cpp
102                 src/kernel/lmm/maxmin_test.cpp)
103 if (SIMGRID_HAVE_MC)
104   set(UNIT_TESTS ${UNIT_TESTS} src/mc/sosp/Snapshot_test.cpp src/mc/sosp/PageStore_test.cpp)
105 else()
106   set(EXTRA_DIST ${EXTRA_DIST} src/mc/sosp/Snapshot_test.cpp src/mc/sosp/PageStore_test.cpp)
107 endif()  
108
109 add_executable       (unit-tests EXCLUDE_FROM_ALL ${UNIT_TESTS})
110 add_dependencies     (tests unit-tests)
111 target_link_libraries(unit-tests simgrid)
112 ADD_TEST(unit-tests ${CMAKE_BINARY_DIR}/unit-tests)
113 set_property(TARGET unit-tests APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
114 add_dependencies(tests unit-tests)
115 set(EXTRA_DIST ${EXTRA_DIST} ${UNIT_TESTS})
116
117 unset(UNIT_TESTS)