Logo AND Algorithmique Numérique Distribuée

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