Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
provide a backtrace implementation that uses boost.stacktrace
[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
25 #    message(STATUS "tesh wrapper: ${TESH_WRAPPER}")
26
27     mark_as_advanced(TESH_WRAPPER)
28   else()
29     set(enable_memcheck false)
30     message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.")
31   endif()
32 ENDIF()
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" AND HAVE_THREAD_CONTEXTS) OR
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 IF(enable_java)
70   IF(WIN32)
71     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/\;${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_JAR}")
72     STRING(REPLACE "\;" "§" TESH_CLASSPATH "${TESH_CLASSPATH}")
73   ELSE()
74     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/:${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_JAR}")
75   ENDIF()
76 ENDIF()
77
78 IF(SIMGRID_HAVE_MC)
79   ADD_TESH_FACTORIES(mc-bugged1                "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1.tesh)
80   ADD_TESH_FACTORIES(mc-bugged2                "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged2.tesh)
81   IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...)
82     ADD_TESH(mc-bugged1-liveness-ucontext         --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness.tesh)
83     ADD_TESH(mc-bugged1-liveness-ucontext-sparse  --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness_sparse.tesh)
84     ADD_TESH(mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness_visited.tesh)
85     ADD_TESH(mc-bugged1-liveness-visited-ucontext-sparse --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness_visited_sparse.tesh)
86     IF(HAVE_C_STACK_CLEANER)
87       # This test checks if the stack cleaner is making a difference:
88       ADD_TEST(mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/msg/mc/bugged1_liveness_stack_cleaner ${CMAKE_HOME_DIRECTORY}/examples/msg/mc/ ${CMAKE_BINARY_DIR}/examples/msg/mc/)
89     ENDIF()
90   ENDIF()
91 ENDIF()
92
93 IF(enable_smpi_MPICH3_testsuite AND SMPI_FORTRAN AND HAVE_THREAD_CONTEXTS)
94   ADD_TEST(test-smpi-mpich3-thread-f77     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f77/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests "-wrapper=${TESH_WRAPPER}" -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f77/ -tests=testlist -privatization=${HAVE_PRIVATIZATION} -execarg=--cfg=contexts/stack-size:8000 -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/privatization:${HAVE_PRIVATIZATION})
95   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f77 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
96   ADD_TEST(test-smpi-mpich3-thread-f90     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f90/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests "-wrapper=${TESH_WRAPPER}" -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/ -tests=testlist -privatization=${HAVE_PRIVATIZATION} -execarg=--cfg=smpi/privatization:${HAVE_PRIVATIZATION} -execarg=--cfg=contexts/factory:thread)
97   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f90 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
98 ENDIF()
99
100 IF(SIMGRID_HAVE_LUA)
101   # Tests testing simulation from C but using lua for platform files. Executed like this
102   # ~$ ./masterslave platform.lua deploy.lua
103   ADD_TESH(lua-platform-masterslave                --setenv srcdir=${CMAKE_HOME_DIRECTORY} --setenv bindir=${CMAKE_BINARY_DIR} --cd ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/teshsuite/lua/lua_platforms.tesh)
104   SET_TESTS_PROPERTIES(lua-platform-masterslave    PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/lib/lib?.${LIB_EXE}")
105 ENDIF()
106
107 ADD_TEST(testall                                 ${CMAKE_BINARY_DIR}/testall)
108
109 # New tests should use the Boost Unit Test Framework
110 if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
111   add_library(boost_unit_test_framework SHARED IMPORTED)
112   set_target_properties(boost_unit_test_framework PROPERTIES IMPORTED_LOCATION ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
113   
114   add_executable       (unit-tmgr src/surf/trace_mgr_test.cpp)
115   target_link_libraries(unit-tmgr simgrid boost_unit_test_framework)
116   ADD_TEST(unit-tmgr ${CMAKE_BINARY_DIR}/unit-tmgr --build_info=yes)
117   set_property(
118     TARGET unit-tmgr
119     APPEND PROPERTY
120            INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
121            )
122   if (SIMGRID_HAVE_MC)
123     # snapshot
124     add_executable       (unit-mc-snapshot src/mc/sosp/mc_snapshot_test.cpp)
125     target_link_libraries(unit-mc-snapshot simgrid boost_unit_test_framework)
126     ADD_TEST(unit-mc-snapshot ${CMAKE_BINARY_DIR}/unit-mc-snapshot --build_info=yes)
127     set_property(
128       TARGET unit-mc-snapshot
129       APPEND PROPERTY
130              INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
131              )
132     # pagestore
133     add_executable       (unit-mc-pagestore src/mc/sosp/PageStore_test.cpp)
134     target_link_libraries(unit-mc-pagestore simgrid boost_unit_test_framework)
135     ADD_TEST(unit-mc-pagestore ${CMAKE_BINARY_DIR}/unit-mc-pagestore --build_info=yes)
136     set_property(
137       TARGET unit-mc-pagestore
138       APPEND PROPERTY
139              INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
140              )
141   endif()
142
143 else()
144   set(EXTRA_DIST       ${EXTRA_DIST}       src/surf/trace_mgr_test.cpp)
145 endif()