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 InputHazardGenerator.py
17 MissingWaitandStartGenerator.py
19 P2PBufferingGenerator.py
21 P2PInvalidComGenerator.py
22 P2PLocalConcurrencyGenerator.py
23 P2PMatchingANYSRCGenerator.py
24 P2PMatchingGenerator.py
25 P2PMessageRaceGenerator.py
26 P2PMessageRaceTagsGenerator.py
30 RMAInvalidArgGenerator.py
31 RMALocalLocalConcurrencyGenerator.py
32 RMAP2PGlobalConcurrencyGenerator.py
33 RMAP2PLocalConcurrencyGenerator.py
34 RMARemoteLocalConcurrencyGenerator.py
35 RMARemoteRemoteConcurrencyGenerator.py
36 RMAReqLifecycleGenerator.py
37 RMAWinBufferGenerator.py)
39 if (enable_smpi_MBI_testsuite)
41 message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
43 if (NOT enable_model-checking)
44 message(FATAL_ERROR "MBI test suite cannot be enabled without the Mc SimGrid model-checker. Please change either setting.")
47 message(STATUS "Generating the MBI test cases")
48 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp)
49 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
50 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI/tmp)
51 foreach (script ${generator_scripts})
52 message(STATUS " $ ${CMAKE_CURRENT_SOURCE_DIR}/${script}")
53 execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${script}
54 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp
55 RESULT_VARIABLE status)
56 if (NOT status EQUAL 0)
57 message(FATAL_ERROR "Command failed with status: ${status}")
61 set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
62 set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
63 include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
65 # Connect the MBI tests to the other tests
66 add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
67 add_dependencies(tests tests-mbi)
69 file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
70 foreach(cfile ${cfiles})
71 # Copy the generated files only if different (needs cmake ≥ 3.21)
72 if (CMAKE_VERSION VERSION_LESS 3.21)
73 file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
75 file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
77 string(REGEX REPLACE "[.]c" "" basefile ${cfile})
79 # Generate an executable for each of them
80 add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
81 target_link_libraries(mbi_${basefile} simgrid)
82 target_compile_options(mbi_${basefile} PRIVATE "-Wno-unused-variable")
83 set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
84 add_dependencies(tests-mbi mbi_${basefile})
86 # Generate a test case for each source file, using the MBI runner
87 ADD_TEST(NAME mbi-${basefile}
88 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
89 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
90 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS mbi-${basefile})
91 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS simgrid-mc)
93 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
95 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
97 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
100 # The following tests are known to fail because simgrid does not intercept local modifications yet
101 # An idea could be to use ASan on the verified application, along with https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
102 # But currently, ASan is not usable at all, since the Checker dislikes this trick when it tries to read the memory of the app.
103 # We should change the checker to not read the app when verifying safty properties
105 LocalConcurrency_Iallgather_nok LocalConcurrency_Iallgatherv_nok LocalConcurrency_Iallreduce_nok LocalConcurrency_Ialltoall_nok
106 LocalConcurrency_Ialltoallv_nok LocalConcurrency_Ibcast_nok LocalConcurrency_Iexscan_nok LocalConcurrency_Igather_nok
107 LocalConcurrency_Irecv_Isend_nok LocalConcurrency_Irecv_Send_init_nok LocalConcurrency_Irecv_Send_nok LocalConcurrency_Ireduce_nok
108 LocalConcurrency_Iscan_nok LocalConcurrency_Iscatter_nok LocalConcurrency_Recv_Isend_nok LocalConcurrency_Recv_Send_init_nok
109 LocalConcurrency_Recv_init_Isend_nok LocalConcurrency_Recv_init_Send_nok LocalConcurrency_Recv_init_Send_init_nok
111 GlobalConcurrency_Get_Isend_Irecv_nok GlobalConcurrency_Get_Isend_Recv_nok GlobalConcurrency_Get_Send_Irecv_nok GlobalConcurrency_Get_Send_Recv_nok
112 GlobalConcurrency_Put_Isend_Irecv_nok GlobalConcurrency_Put_Isend_Recv_nok GlobalConcurrency_Put_Send_Irecv_nok GlobalConcurrency_Put_Send_Recv_nok
114 # GlobalConcurrency_rl_Win_fence_Get_rload_nok GlobalConcurrency_rl_Win_fence_Get_rstore_nok
115 # GlobalConcurrency_rl_Win_fence_Put_rload_nok GlobalConcurrency_rl_Win_fence_Put_rstore_nok
116 # GlobalConcurrency_rl_Win_lock_all_Get_rload_nok GlobalConcurrency_rl_Win_lock_all_Get_rstore_nok
117 # GlobalConcurrency_rl_Win_lock_all_Put_rload_nok GlobalConcurrency_rl_Win_lock_all_Put_rstore_nok
119 set_tests_properties(mbi-${localmodif} PROPERTIES WILL_FAIL true)
120 endforeach(localmodif )
123 # Add the needed files to the distribution
124 foreach(script ${generator_scripts})
125 set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
128 set(teshsuite_src ${teshsuite_src}
129 ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
130 ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
131 ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
132 ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py