Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reactivate the last MBI generator now that it produces tests that compile
[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 set(generator_scripts 
9     CollArgGenerator.py
10     CollComGenerator.py
11     CollLocalConcurrencyGenerator.py
12     CollMatchingGenerator.py
13     CollP2PMatchingGenerator.py
14     CollP2PMessageRaceGenerator.py
15     CollTopoGenerator.py
16     MissingWaitandStartGenerator.py
17     P2PArgGenerator.py
18     P2PComGenerator.py
19     P2PInvalidComGenerator.py
20     P2PLocalConcurrencyGenerator.py
21     P2PMatchingANYSRCGenerator.py
22     P2PMatchingGenerator.py
23     P2PProbeGenerator.py
24     ResleakGenerator.py
25     RMAArgGenerator.py
26     RMAInvalidArgGenerator.py
27     RMALocalLocalConcurrencyGenerator.py
28     RMAP2PGlobalConcurrencyGenerator.py
29     RMARemoteLocalConcurrencyGenerator.py
30     RMARemoteRemoteConcurrencyGenerator.py
31     RMAReqLifecycleGenerator.py
32     RMAWinBufferGenerator.py)
33
34 if (enable_smpi_MBI_testsuite)
35   if (NOT enable_smpi)
36     message(FATAL_ERROR "MBI test suite cannot be enabled without SMPI. Please change either setting.")
37   endif()
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.")
40   endif()
41
42   message(STATUS "Generating the MBI scripts")
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   endforeach()
51
52   set(CMAKE_C_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicc")
53   set(CMAKE_CXX_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpicxx")
54   include_directories(BEFORE "${CMAKE_HOME_DIRECTORY}/include/smpi")
55
56   # Connect the MBI tests to the other tests
57   add_custom_target(tests-mbi COMMENT "Recompiling the MBI tests and tools.")
58   add_dependencies(tests tests-mbi)
59
60   file(GLOB cfiles RELATIVE ${CMAKE_BINARY_DIR}/MBI/tmp ${CMAKE_BINARY_DIR}/MBI/tmp/*.c )
61   foreach(cfile ${cfiles})
62     # Copy the generated files only if different (needs cmake ≥ 3.21)
63     if (CMAKE_VERSION VERSION_LESS 3.21)
64       file(COPY ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} DESTINATION ${CMAKE_BINARY_DIR}/MBI/)
65     else()
66       file(COPY_FILE ${CMAKE_BINARY_DIR}/MBI/tmp/${cfile} ${CMAKE_BINARY_DIR}/MBI/${cfile} ONLY_IF_DIFFERENT)
67     endif()
68     string(REGEX REPLACE "[.]c" "" basefile ${cfile})
69
70     # Generate an executable for each of them
71     add_executable(mbi_${basefile} EXCLUDE_FROM_ALL ${CMAKE_BINARY_DIR}/MBI/${cfile})
72     target_link_libraries(mbi_${basefile} simgrid)
73     target_compile_options(mbi_${basefile} PRIVATE "-Wno-error")
74     set_target_properties(mbi_${basefile} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
75     add_dependencies(tests-mbi mbi_${basefile})
76
77     # Generate a test case for each source file, using the MBI runner
78     ADD_TEST(NAME mbi-${basefile}
79              COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py ${CMAKE_BINARY_DIR} ./mbi_${basefile} ${cfile}
80              WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/MBI)
81     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS mbi-${basefile})
82     SET_TESTS_PROPERTIES(mbi-${basefile}  PROPERTIES DEPENDS simgrid-mc)
83   endforeach()
84   file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/MBI/tmp) # Clean temp files
85
86   if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_HOME_DIRECTORY}")
87   else()
88     file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py DESTINATION ${CMAKE_BINARY_DIR}/MBI)
89   endif()
90 endif()
91
92 # Add the needed files to the distribution
93 foreach(script ${generator_scripts})
94   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${script})
95 endforeach()
96
97 set(teshsuite_src ${teshsuite_src}
98                   ${CMAKE_CURRENT_SOURCE_DIR}/generator_utils.py
99                   ${CMAKE_CURRENT_SOURCE_DIR}/MBI.py
100                   ${CMAKE_CURRENT_SOURCE_DIR}/MBIutils.py
101                   ${CMAKE_CURRENT_SOURCE_DIR}/simgrid.py
102                   PARENT_SCOPE)