Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MBI: use file globbing to make sure that we don't forget any generator
[simgrid.git] / teshsuite / smpi / MBI / CMakeLists.txt
1 # Copyright 2021-2022. The SimGrid Team. All rights reserved.
2
3 # Integrates the MBI tests into the SimGrid build chain when asked to
4
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.
7
8 if (enable_smpi_MBI_testsuite)
9   if (NOT enable_smpi)
10     message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
11   endif()
12   if (NOT enable_model-checking)
13     message(FATAL_ERROR "MBI test suite cannot be enabled without the Mc SimGrid model-checker. Please change either setting.")
14   endif()
15
16   message(STATUS "Generating the MBI test cases")
17   file(REMOVE_RECURSE  ${CMAKE_BINARY_DIR}/MBI/tmp)
18   file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp)
19   file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI/tmp)
20   file(GLOB generator_scripts *Generator.py)
21   foreach (script ${generator_scripts})
22     message(STATUS "  $ ${CMAKE_CURRENT_SOURCE_DIR}/${script}")
23     execute_process(COMMAND ${PYTHON_EXECUTABLE} ${script}
24                     WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI/tmp
25                     RESULT_VARIABLE status)
26     if (NOT status EQUAL 0)
27       message(FATAL_ERROR "Command failed with status: ${status}")
28     endif()
29   endforeach()
30
31   set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
32   set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
33   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
34
35   # Connect the MBI tests to the other tests
36   add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
37   add_dependencies(tests tests-mbi)
38   add_dependencies(tests-mbi simgrid-mc smpimain)
39
40   file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
41   foreach(cfile ${cfiles})
42     # Copy the generated files only if different (needs cmake ≥ 3.21)
43     if (CMAKE_VERSION VERSION_LESS 3.21)
44       file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
45     else()
46       file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
47     endif()
48     string(REGEX REPLACE "[.]c" "" basefile ${cfile})
49
50     # Generate an executable for each of them
51     add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
52     target_link_libraries(mbi_${basefile} simgrid)
53     target_compile_options(mbi_${basefile} PRIVATE "-Wno-unused-variable")
54     set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
55     add_dependencies(tests-mbi mbi_${basefile})
56
57     # Generate a test case for each source file, using the MBI runner
58     ADD_TEST(NAME mbi-${basefile}
59              COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
60              WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
61     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS mbi-${basefile})
62     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS simgrid-mc)
63   endforeach()
64   file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
65
66   if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
67   else()
68     file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
69   endif()
70
71   # The following tests are known to fail because simgrid does not intercept local modifications yet
72   # An idea could be to use ASan on the verified application, along with https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning
73   # But currently, ASan is not usable at all, since the Checker dislikes this trick when it tries to read the memory of the app.
74   # We should change the checker to not read the app when verifying safty properties
75   foreach(localmodif
76           LocalConcurrency_Iallgather_nok      LocalConcurrency_Iallgatherv_nok     LocalConcurrency_Iallreduce_nok      LocalConcurrency_Ialltoall_nok
77           LocalConcurrency_Ialltoallv_nok      LocalConcurrency_Ibcast_nok          LocalConcurrency_Iexscan_nok         LocalConcurrency_Igather_nok
78           LocalConcurrency_Irecv_Isend_nok     LocalConcurrency_Irecv_Send_init_nok LocalConcurrency_Irecv_Send_nok      LocalConcurrency_Ireduce_nok
79           LocalConcurrency_Iscan_nok           LocalConcurrency_Iscatter_nok        LocalConcurrency_Recv_Isend_nok      LocalConcurrency_Recv_Send_init_nok
80           LocalConcurrency_Recv_init_Isend_nok LocalConcurrency_Recv_init_Send_nok  LocalConcurrency_Recv_init_Send_init_nok
81
82           GlobalConcurrency_Get_Isend_Irecv_nok GlobalConcurrency_Get_Isend_Recv_nok GlobalConcurrency_Get_Send_Irecv_nok GlobalConcurrency_Get_Send_Recv_nok
83           GlobalConcurrency_Put_Isend_Irecv_nok GlobalConcurrency_Put_Isend_Recv_nok GlobalConcurrency_Put_Send_Irecv_nok GlobalConcurrency_Put_Send_Recv_nok
84
85           GlobalConcurrency_rl_Win_fence_Get_rstore_nok   GlobalConcurrency_rl_Win_lock_all_Get_rstore_nok
86           GlobalConcurrency_rl_Win_fence_Put_rstore_nok   GlobalConcurrency_rl_Win_lock_all_Put_rstore_nok
87
88           GlobalConcurrency_rl_Win_fence_Get_Get_nok
89           GlobalConcurrency_rl_Win_fence_Put_Get_nok
90           GlobalConcurrency_rl_Win_fence_Put_Put_nok
91           GlobalConcurrency_rl_Win_fence_Put_rload_nok
92
93           GlobalConcurrency_rl_Win_lock_Get_Get_nok
94           GlobalConcurrency_rl_Win_lock_Get_rstore_nok
95           GlobalConcurrency_rl_Win_lock_Put_Get_nok
96           GlobalConcurrency_rl_Win_lock_Put_Put_nok
97           GlobalConcurrency_rl_Win_lock_Put_rload_nok
98           GlobalConcurrency_rl_Win_lock_Put_rstore_nok
99           GlobalConcurrency_rl_Win_lock_all_Get_Get_nok
100           GlobalConcurrency_rl_Win_lock_all_Put_Get_nok
101           GlobalConcurrency_rl_Win_lock_all_Put_Put_nok
102           GlobalConcurrency_rl_Win_lock_all_Put_rload_nok
103           GlobalConcurrency_rr_Win_fence_Get_Put_nok
104           GlobalConcurrency_rr_Win_fence_Put_Put_nok
105           GlobalConcurrency_rr_Win_lock_Get_Put_nok
106           GlobalConcurrency_rr_Win_lock_Put_Put_nok
107           GlobalConcurrency_rr_Win_lock_all_Get_Put_nok
108           GlobalConcurrency_rr_Win_lock_all_Put_Put_nok
109        )
110     set_tests_properties(mbi-${localmodif} PROPERTIES WILL_FAIL true)
111   endforeach(localmodif )
112 endif()
113
114 # Add the needed files to the distribution
115 foreach(script ${generator_scripts})
116   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
117 endforeach()
118
119 set(teshsuite_src ${teshsuite_src}
120                   ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
121                   ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
122                   ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
123                   ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py
124                   PARENT_SCOPE)