Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tuto-msg: fix parallel execution.
[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 ENDIF()
15
16 #some tests may take forever on non futexes systems, using busy_wait with n cores < n workers
17 # default to posix for these tests if futexes are not supported
18 IF(NOT HAVE_FUTEX_H)
19   SET(CONTEXTS_SYNCHRO --cfg contexts/synchro:posix)
20 ENDIF()
21
22 MACRO(ADD_TESH NAME)
23   SET(ARGT ${ARGV})
24   LIST(REMOVE_AT ARGT 0)
25   IF(WIN32)
26     STRING(REPLACE "§" "\;" ARGT "${ARGT}")
27   ENDIF()
28   if(TESH_WRAPPER)
29     ADD_TEST(${NAME} ${TESH_COMMAND} --wrapper "${TESH_WRAPPER}" ${TESH_OPTION} ${ARGT})
30   else()
31     ADD_TEST(${NAME} ${TESH_COMMAND} ${TESH_OPTION} ${ARGT})
32   endif()
33 ENDMACRO()
34
35 MACRO(ADD_TESH_FACTORIES NAME FACTORIES)
36   SET(ARGR ${ARGV})
37   LIST(REMOVE_AT ARGR 0) # remove name
38   FOREACH(I ${FACTORIES}) # remove all factories
39     LIST(REMOVE_AT ARGR 0)
40   ENDFOREACH()
41   FOREACH(FACTORY ${FACTORIES})
42     if ((${FACTORY} STREQUAL "thread" AND HAVE_THREAD_CONTEXTS) OR
43         (${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR
44         (${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR
45         (${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS))
46       ADD_TESH("${NAME}-${FACTORY}" "--cfg" "contexts/factory:${FACTORY}" ${ARGR})
47     ENDIF()
48   ENDFOREACH()
49 ENDMACRO()
50
51 IF(enable_java)
52   IF(WIN32)
53     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/\;${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_JAR}")
54     STRING(REPLACE "\;" "§" TESH_CLASSPATH "${TESH_CLASSPATH}")
55   ELSE()
56     SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/:${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_JAR}")
57   ENDIF()
58 ENDIF()
59
60 IF(SIMGRID_HAVE_MC)
61   ADD_TESH_FACTORIES(mc-bugged1                "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1.tesh)
62   ADD_TESH_FACTORIES(mc-bugged2                "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged2.tesh)
63   IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...)
64     ADD_TESH(mc-bugged1-liveness-ucontext         --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness.tesh)
65     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)
66     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)
67     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)
68     IF(HAVE_C_STACK_CLEANER)
69       # This test checks if the stack cleaner is making a difference:
70       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/)
71     ENDIF()
72   ENDIF()
73 ENDIF()
74
75 IF(enable_smpi_MPICH3_testsuite AND SMPI_FORTRAN AND HAVE_THREAD_CONTEXTS)
76   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 ${TESH_OPTION} -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})
77   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f77 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
78   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 ${TESH_OPTION} -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)
79   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f90 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
80 ENDIF()
81
82 IF(SIMGRID_HAVE_LUA)
83   # Tests testing simulation from C but using lua for platform files. Executed like this
84   # ~$ ./masterslave platform.lua deploy.lua
85   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)
86   SET_TESTS_PROPERTIES(lua-platform-masterslave    PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/lib/lib?.${LIB_EXE}")
87 ENDIF()
88
89 ADD_TEST(testall                                 ${CMAKE_BINARY_DIR}/testall)
90
91 # New tests should use the Boost Unit Test Framework
92 if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
93   add_executable       (unit_tmgr src/surf/trace_mgr_test.cpp)
94   target_link_libraries(unit_tmgr simgrid ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
95   ADD_TEST(unit_tmgr ${CMAKE_BINARY_DIR}/unit_tmgr --build_info=yes)
96   
97 else()
98   set(EXTRA_DIST       ${EXTRA_DIST}       src/surf/trace_mgr_test.cpp)
99 endif()
100
101 # Also test the tutorial, unless under Sanitizer or memcheck
102 if((NOT enable_memcheck) AND (NOT enable_address_sanitizer) AND (NOT enable_undefined_sanitizer) AND (NOT enable_thread_sanitizer))
103   FILE(COPY doc/tuto-msg DESTINATION doc FILES_MATCHING PATTERN "Makefile" PATTERN "*.c")
104   set(tuto-src-path "${CMAKE_SOURCE_DIR}/doc/tuto-msg")
105   set(tuto-bin-path "${CMAKE_BINARY_DIR}/doc/tuto-msg")
106   set(tuto-platform-file "${CMAKE_SOURCE_DIR}/examples/platforms/small_platform.xml")
107   set(tuto-make "make -C ${tuto-bin-path} CC=${CMAKE_C_COMPILER} EXTRA_CFLAGS=\"-I${CMAKE_SOURCE_DIR}/include -I${CMAKE_BINARY_DIR}/include -L${CMAKE_BINARY_DIR}/lib\"")
108   ADD_TEST(tuto-msg-clean sh -xc "${tuto-make} clean")
109   ADD_TEST(tuto-msg-0 sh -xc "${tuto-make} masterworker      && ${tuto-bin-path}/masterworker      ${tuto-platform-file} ${tuto-src-path}/deployment0.xml")
110   ADD_TEST(tuto-msg-1 sh -xc "${tuto-make} masterworker-sol1 && ${tuto-bin-path}/masterworker-sol1 ${tuto-platform-file} ${tuto-src-path}/deployment1.xml")
111   ADD_TEST(tuto-msg-2 sh -xc "${tuto-make} masterworker-sol2 && ${tuto-bin-path}/masterworker-sol2 ${tuto-platform-file} ${tuto-src-path}/deployment2.xml")
112   ADD_TEST(tuto-msg-3 sh -xc "${tuto-make} masterworker-sol3 && ${tuto-bin-path}/masterworker-sol3 ${tuto-platform-file} ${tuto-src-path}/deployment3.xml")
113   ADD_TEST(tuto-msg-4 sh -xc "${tuto-make} masterworker-sol4 && ${tuto-bin-path}/masterworker-sol4 ${tuto-platform-file} ${tuto-src-path}/deployment3.xml")
114
115   SET_TESTS_PROPERTIES(tuto-msg-clean PROPERTIES FIXTURES_SETUP tuto-msg-clean)
116   SET_TESTS_PROPERTIES(tuto-msg-0 tuto-msg-1 tuto-msg-2 tuto-msg-3 tuto-msg-4 PROPERTIES FIXTURES_REQUIRED tuto-msg-clean)
117
118   FOREACH(TUTOTEST tuto-msg-0 tuto-msg-1 tuto-msg-2 tuto-msg-3 tuto-msg-4)
119   SET_TESTS_PROPERTIES(${TUTOTEST} 
120                        PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib")
121   ENDFOREACH()
122 endif()