X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/180bb2169a8dbe211647c7790736f8a53c7d552f..97ba2912108d1499c4caf69a2614b2221d686388:/tools/cmake/Tests.cmake diff --git a/tools/cmake/Tests.cmake b/tools/cmake/Tests.cmake index 18f6a56598..35bf1db03f 100644 --- a/tools/cmake/Tests.cmake +++ b/tools/cmake/Tests.cmake @@ -1,17 +1,35 @@ -IF(enable_smpi AND NOT WIN32) - execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicc) - execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpicxx) - execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpiff) - execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpif90) - execute_process(COMMAND chmod a=rwx ${CMAKE_BINARY_DIR}/bin/smpirun) -ENDIF() - SET(TESH_OPTION "--ignore-jenkins") SET(TESH_COMMAND "${PYTHON_EXECUTABLE}" ${CMAKE_BINARY_DIR}/bin/tesh) +SET(TESH_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib") +if(NOT $ENV{LD_LIBRARY_PATH} STREQUAL "") + SET(TESH_LIBRARY_PATH "${TESH_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}") +endif() + IF(enable_memcheck) INCLUDE(FindValgrind) + + if (NOT VALGRIND_EXE MATCHES "NOTFOUND") + execute_process(COMMAND ${VALGRIND_EXE} --version OUTPUT_VARIABLE "VALGRIND_VERSION") + message(STATUS "Valgrind version: ${VALGRIND_VERSION}") + + set(TESH_WRAPPER ${CMAKE_HOME_DIRECTORY}/tools/cmake/scripts/my_valgrind.pl) + 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\ ) + if(enable_memcheck_xml) + SET(TESH_WRAPPER ${TESH_WRAPPER}\ --xml=yes\ --xml-file=memcheck_test_%p.memcheck\ --child-silent-after-fork=yes\ ) + endif() + set(TESH_OPTION ${TESH_OPTION} --setenv VALGRIND_NO_LEAK_CHECK=--leak-check=no\ --show-leak-kinds=none) + +# message(STATUS "tesh wrapper: ${TESH_WRAPPER}") + + mark_as_advanced(TESH_WRAPPER) + else() + set(enable_memcheck false) + message(STATUS "Error: Command valgrind not found --> enable_memcheck autoset to false.") + endif() ENDIF() +SET(TESH_WRAPPER_UNBOXED "${TESH_WRAPPER}") +SEPARATE_ARGUMENTS(TESH_WRAPPER_UNBOXED) #some tests may take forever on non futexes systems, using busy_wait with n cores < n workers # default to posix for these tests if futexes are not supported @@ -39,7 +57,7 @@ MACRO(ADD_TESH_FACTORIES NAME FACTORIES) LIST(REMOVE_AT ARGR 0) ENDFOREACH() FOREACH(FACTORY ${FACTORIES}) - if ((${FACTORY} STREQUAL "thread" AND HAVE_THREAD_CONTEXTS) OR + if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads (${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR (${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR (${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS)) @@ -48,65 +66,52 @@ MACRO(ADD_TESH_FACTORIES NAME FACTORIES) ENDFOREACH() ENDMACRO() +MACRO(SET_TESH_PROPERTIES NAME FACTORIES) + SET(ARGR ${ARGV}) + LIST(REMOVE_AT ARGR 0) # remove name + FOREACH(I ${FACTORIES}) # remove all factories + LIST(REMOVE_AT ARGR 0) + ENDFOREACH() + FOREACH(FACTORY ${FACTORIES}) + if ((${FACTORY} STREQUAL "thread" ) OR # Always available, thanks to C++11 threads + (${FACTORY} STREQUAL "boost" AND HAVE_BOOST_CONTEXTS) OR + (${FACTORY} STREQUAL "raw" AND HAVE_RAW_CONTEXTS) OR + (${FACTORY} STREQUAL "ucontext" AND HAVE_UCONTEXT_CONTEXTS)) + set_tests_properties("${NAME}-${FACTORY}" PROPERTIES ${ARGR}) + endif() + ENDFOREACH() +ENDMACRO() + IF(enable_java) IF(WIN32) - SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/\;${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_JAR}") + SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/deprecated/java/\;${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_JAR}") STRING(REPLACE "\;" "§" TESH_CLASSPATH "${TESH_CLASSPATH}") ELSE() - SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/java/:${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_JAR}") - ENDIF() -ENDIF() - -IF(SIMGRID_HAVE_MC) - ADD_TESH_FACTORIES(mc-bugged1 "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1.tesh) - ADD_TESH_FACTORIES(mc-bugged2 "ucontext;raw" --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged2.tesh) - IF(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) # liveness model-checking works only on 64bits (for now ...) - ADD_TESH(mc-bugged1-liveness-ucontext --setenv bindir=${CMAKE_BINARY_DIR}/examples/msg/mc --cd ${CMAKE_HOME_DIRECTORY}/examples/msg/mc bugged1_liveness.tesh) - 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) - 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) - 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) - IF(HAVE_C_STACK_CLEANER) - # This test checks if the stack cleaner is making a difference: - 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/) - ENDIF() + SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/examples/deprecated/java/:${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_JAR}") ENDIF() ENDIF() -IF(enable_smpi_MPICH3_testsuite AND SMPI_FORTRAN AND HAVE_THREAD_CONTEXTS) - 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}) - SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f77 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!") - 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) - SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f90 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!") -ENDIF() - -IF(SIMGRID_HAVE_LUA) - # Tests testing simulation from C but using lua for platform files. Executed like this - # ~$ ./masterslave platform.lua deploy.lua - 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) - SET_TESTS_PROPERTIES(lua-platform-masterslave PROPERTIES ENVIRONMENT "LUA_CPATH=${CMAKE_BINARY_DIR}/lib/lib?.${LIB_EXE}") -ENDIF() - -ADD_TEST(testall ${CMAKE_BINARY_DIR}/testall) - -# New tests should use the Boost Unit Test Framework -if(Boost_UNIT_TEST_FRAMEWORK_FOUND) - add_executable (unit_tmgr src/surf/trace_mgr_test.cpp) - target_link_libraries(unit_tmgr simgrid ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - ADD_TEST(unit_tmgr ${CMAKE_BINARY_DIR}/unit_tmgr --build_info=yes) - +# New tests should use the Catch Framework +set(UNIT_TESTS src/xbt/unit-tests_main.cpp + src/kernel/resource/profile/Profile_test.cpp + src/xbt/config_test.cpp + src/xbt/dict_test.cpp + src/xbt/dynar_test.cpp + src/xbt/random_test.cpp + src/xbt/xbt_str_test.cpp + src/kernel/lmm/maxmin_test.cpp) +if (SIMGRID_HAVE_MC) + set(UNIT_TESTS ${UNIT_TESTS} src/mc/sosp/Snapshot_test.cpp src/mc/sosp/PageStore_test.cpp) else() - set(EXTRA_DIST ${EXTRA_DIST} src/surf/trace_mgr_test.cpp) -endif() - + set(EXTRA_DIST ${EXTRA_DIST} src/mc/sosp/Snapshot_test.cpp src/mc/sosp/PageStore_test.cpp) +endif() -# Also test the tutorial -ADD_TEST(tuto-msg-0 sh -c "make -C doc/tuto-msg masterworker && doc/tuto-msg/masterworker examples/platforms/small_platform.xml doc/tuto-msg/deployment0.xml") -ADD_TEST(tuto-msg-1 sh -c "make -C doc/tuto-msg masterworker-sol1 && doc/tuto-msg/masterworker-sol1 examples/platforms/small_platform.xml doc/tuto-msg/deployment1.xml") -ADD_TEST(tuto-msg-2 sh -c "make -C doc/tuto-msg masterworker-sol2 && doc/tuto-msg/masterworker-sol2 examples/platforms/small_platform.xml doc/tuto-msg/deployment2.xml") -ADD_TEST(tuto-msg-3 sh -c "make -C doc/tuto-msg masterworker-sol3 && doc/tuto-msg/masterworker-sol3 examples/platforms/small_platform.xml doc/tuto-msg/deployment3.xml") -ADD_TEST(tuto-msg-4 sh -c "make -C doc/tuto-msg masterworker-sol4 && doc/tuto-msg/masterworker-sol4 examples/platforms/small_platform.xml doc/tuto-msg/deployment3.xml") +add_executable (unit-tests EXCLUDE_FROM_ALL ${UNIT_TESTS}) +add_dependencies (tests unit-tests) +target_link_libraries(unit-tests simgrid) +ADD_TEST(unit-tests ${CMAKE_BINARY_DIR}/unit-tests) +set_property(TARGET unit-tests APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}") +add_dependencies(tests unit-tests) +set(EXTRA_DIST ${EXTRA_DIST} ${UNIT_TESTS}) -FOREACH(TUTOTEST tuto-msg-0 tuto-msg-1 tuto-msg-2 tuto-msg-3 tuto-msg-4) - SET_TESTS_PROPERTIES(${TUTOTEST} - PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=lib") -ENDFOREACH() +unset(UNIT_TESTS)