1 # Copyright 2021-2022. The SimGrid Team. All rights reserved.
3 # Integrates the MBI tests into the SimGrid build chain when asked to
5 # Only the python scripts are embeeded in the archive, and the C test files are generated at config time using these scripts.
6 # These python scripts are copied over from the MBI repository with as little changes as possible.
11 CollLocalConcurrencyGenerator.py
12 CollMatchingGenerator.py
13 CollP2PMatchingGenerator.py
14 CollP2PMessageRaceGenerator.py
16 MissingWaitandStartGenerator.py
19 P2PInvalidComGenerator.py
20 P2PLocalConcurrencyGenerator.py
21 P2PMatchingANYSRCGenerator.py
22 P2PMatchingGenerator.py
26 RMAInvalidArgGenerator.py
27 RMALocalLocalConcurrencyGenerator.py
28 # RMAP2PGlobalConcurrencyGenerator.py
29 RMARemoteLocalConcurrencyGenerator.py
30 RMARemoteRemoteConcurrencyGenerator.py
31 RMAReqLifecycleGenerator.py
32 RMAWinBufferGenerator.py)
34 set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/RMAP2PGlobalConcurrencyGenerator.py)
36 if (enable_smpi_MBI_testsuite)
38 message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
40 if (NOT enable_model-checking)
41 message(FATAL_ERROR "MBI test suite cannot be enabled without the Mc SimGrid model-checker. Please change either setting.")
44 message(STATUS "Generating the MBI scripts")
45 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp)
46 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
47 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI/tmp)
48 foreach (script ${generator_scripts})
49 message(STATUS " $ ${CMAKE_CURRENT_SOURCE_DIR}/${script}")
50 execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${script}
51 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
54 set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
55 set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
56 include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
58 # Connect the MBI tests to the other tests
59 add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
60 add_dependencies(tests tests-mbi)
62 file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
63 foreach(cfile ${cfiles})
64 # Copy the generated files only if different (needs cmake ≥ 3.21)
65 if (CMAKE_VERSION VERSION_LESS 3.21)
66 file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
68 file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
70 string(REGEX REPLACE "[.]c" "" basefile ${cfile})
72 # Generate an executable for each of them
73 add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
74 target_link_libraries(mbi_${basefile} simgrid)
75 target_compile_options(mbi_${basefile} PRIVATE "-Wno-error")
76 set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
77 add_dependencies(tests-mbi mbi_${basefile})
79 # Generate a test case for each source file, using the MBI runner
80 ADD_TEST(NAME mbi-${basefile}
81 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
82 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
83 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS mbi-${basefile})
84 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS simgrid-mc)
86 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
88 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
90 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
94 # Add the needed files to the distribution
95 foreach(script ${generator_scripts})
96 set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
99 set(teshsuite_src ${teshsuite_src}
100 ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
101 ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
102 ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
103 ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py