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 if (enable_smpi_MBI_testsuite)
36 message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
38 if (NOT enable_model-checking)
39 message(FATAL_ERROR "MBI test suite cannot be enabled without the Mc SimGrid model-checker. Please change either setting.")
42 message(STATUS "Generating the MBI test cases")
43 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp)
44 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
45 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI/tmp)
46 foreach (script ${generator_scripts})
47 message(STATUS " $ ${CMAKE_CURRENT_SOURCE_DIR}/${script}")
48 execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${script}
49 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp
50 RESULT_VARIABLE status)
51 if (NOT status EQUAL 0)
52 message(FATAL_ERROR "Command failed with status: ${status}")
56 set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
57 set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
58 include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
60 # Connect the MBI tests to the other tests
61 add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
62 add_dependencies(tests tests-mbi)
64 file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
65 foreach(cfile ${cfiles})
66 # Copy the generated files only if different (needs cmake ≥ 3.21)
67 if (CMAKE_VERSION VERSION_LESS 3.21)
68 file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
70 file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
72 string(REGEX REPLACE "[.]c" "" basefile ${cfile})
74 # Generate an executable for each of them
75 add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
76 target_link_libraries(mbi_${basefile} simgrid)
77 target_compile_options(mbi_${basefile} PRIVATE "-Wno-unused-variable")
78 set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
79 add_dependencies(tests-mbi mbi_${basefile})
81 # Generate a test case for each source file, using the MBI runner
82 ADD_TEST(NAME mbi-${basefile}
83 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
84 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
85 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS mbi-${basefile})
86 SET_TESTS_PROPERTIES(mbi-${basefile} PROPERTIES DEPENDS simgrid-mc)
88 file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
90 if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
92 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
95 # The following tests are known to fail because simgrid does not intercept local modifications yet
96 # An idea could be to use ASan on the verified application, along with https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
97 # But currently, ASan is not usable at all, since the Checker dislikes this trick when it tries to read the memory of the app.
98 # We should change the checker to not read the app when verifying safty properties
100 LocalConcurrency_Iallgather_nok LocalConcurrency_Iallgatherv_nok LocalConcurrency_Iallreduce_nok LocalConcurrency_Ialltoall_nok
101 LocalConcurrency_Ialltoallv_nok LocalConcurrency_Ibcast_nok LocalConcurrency_Iexscan_nok LocalConcurrency_Igather_nok
102 LocalConcurrency_Irecv_Isend_nok LocalConcurrency_Irecv_Send_init_nok LocalConcurrency_Irecv_Send_nok LocalConcurrency_Ireduce_nok
103 LocalConcurrency_Iscan_nok LocalConcurrency_Iscatter_nok LocalConcurrency_Recv_Isend_nok LocalConcurrency_Recv_Send_init_nok
104 LocalConcurrency_Recv_init_Isend_nok LocalConcurrency_Recv_init_Send_nok LocalConcurrency_Recv_init_Send_init_nok
106 GlobalConcurrency_Get_Isend_Irecv_nok GlobalConcurrency_Get_Isend_Recv_nok GlobalConcurrency_Get_Send_Irecv_nok GlobalConcurrency_Get_Send_Recv_nok
107 GlobalConcurrency_Put_Isend_Irecv_nok GlobalConcurrency_Put_Isend_Recv_nok GlobalConcurrency_Put_Send_Irecv_nok GlobalConcurrency_Put_Send_Recv_nok
109 GlobalConcurrency_rl_Win_fence_Get_rload_nok GlobalConcurrency_rl_Win_fence_Get_rstore_nok
110 GlobalConcurrency_rl_Win_fence_Put_rload_nok GlobalConcurrency_rl_Win_fence_Put_rstore_nok
111 GlobalConcurrency_rl_Win_lock_all_Get_rload_nok GlobalConcurrency_rl_Win_lock_all_Get_rstore_nok
112 GlobalConcurrency_rl_Win_lock_all_Put_rload_nok GlobalConcurrency_rl_Win_lock_all_Put_rstore_nok
114 set_tests_properties(mbi-${localmodif} PROPERTIES WILL_FAIL true)
115 endforeach(localmodif )
118 # Add the needed files to the distribution
119 foreach(script ${generator_scripts})
120 set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
123 set(teshsuite_src ${teshsuite_src}
124 ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
125 ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
126 ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
127 ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py