Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a MC version of the s4u-synchro-mutex test
[simgrid.git] / examples / cpp / CMakeLists.txt
1
2 # Regular examples: with only one source and tested with all factories by default
3 #################################################################################
4 ### Define the examples' specificities
5
6 set(_app-bittorrent_sources app-bittorrent/s4u-bittorrent.cpp app-bittorrent/s4u-bittorrent.hpp
7                             app-bittorrent/s4u-peer.cpp app-bittorrent/s4u-peer.hpp
8                             app-bittorrent/s4u-tracker.cpp app-bittorrent/s4u-tracker.hpp)
9 set(_dht-chord_sources    dht-chord/s4u-dht-chord.cpp dht-chord/s4u-dht-chord.hpp dht-chord/s4u-dht-chord-node.cpp)
10 set(_dht-kademlia_sources dht-kademlia/s4u-dht-kademlia.cpp dht-kademlia/s4u-dht-kademlia.hpp
11                           dht-kademlia/node.cpp dht-kademlia/node.hpp
12                           dht-kademlia/routing_table.cpp dht-kademlia/routing_table.hpp
13                           dht-kademlia/answer.cpp dht-kademlia/answer.hpp dht-kademlia/message.hpp)
14
15 set(_actor-stacksize_factories "^thread") # Threads ignore modifications of the stack size
16
17 # The maestro-set example only works for threads and when not using windows.
18 set(_maestro-set_factories "thread")
19 if(WIN32)
20   set(_maestro-set_disable 1)
21 endif()
22
23 if(SIMGRID_HAVE_MC)
24   # These tests timeout with threads, maybe because of dwarf parsing? not sure
25   foreach(example mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
26      set(_${example}_factories "^thread") # Timeout
27      add_dependencies(tests-mc s4u-${example})
28   endforeach()
29
30   # Make all MC tests buildable together
31   #foreach(example ) # no test to be build in any case
32   #endforeach()
33   
34   if(HAVE_C_STACK_CLEANER)
35     add_executable       (s4u-mc-bugged1-liveness-cleaner-on  EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
36     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-on  simgrid)
37     set_target_properties(s4u-mc-bugged1-liveness-cleaner-on  PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fstack-cleaner")
38     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-on)
39
40     add_executable       (s4u-mc-bugged1-liveness-cleaner-off EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
41     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-off simgrid)
42     set_target_properties(s4u-mc-bugged1-liveness-cleaner-off PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fno-stack-cleaner")
43     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-off)
44   endif()
45
46   # Model-checking liveness
47   if(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64) 
48     # liveness model-checking works only on 64bits (for now ...)
49     set(_mc-bugged1-liveness_factories "ucontext") # Timeout
50     add_dependencies(tests-mc s4u-mc-bugged1-liveness)
51     set(_mc-bugged2-liveness_factories "ucontext") # Timeout
52   else()
53     set(_mc-bugged1-liveness_disable 1)
54   endif()
55
56   # Hijack some regular tests to run them on top of the MC
57   foreach (example synchro-mutex)
58     ADD_TESH(s4u-mc-${example} 
59                        --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
60                        --setenv libdir=${CMAKE_BINARY_DIR}/lib
61                        --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
62                        --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
63                        --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
64                        ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-mc-${example}.tesh)
65     set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-mc-${example}.tesh)
66   endforeach()
67
68
69   # This example never ends, disable it for now
70   set(_mc-bugged2-liveness_disable 1)
71   
72   # This example hit the 5' timeout on CI, disable it for now
73   #    ADD_TESH(s4u-mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
74   #                                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
75   #                                                      --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
76   #                                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh)
77   IF(HAVE_C_STACK_CLEANER)
78     add_dependencies(tests-mc s4u-mc-bugged1-liveness-stack-cleaner)
79     # This test checks if the stack cleaner is making a difference:
80     ADD_TEST(s4u-mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
81                                                    ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/
82                                                    ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/)
83   ENDIF()
84   
85   if(enable_coverage)
86     foreach (example mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert)
87       ADD_TEST(cover-${example} ${CMAKE_CURRENT_BINARY_DIR}/${example}/s4u-${example} ${CMAKE_HOME_DIRECTORY}/examples/platforms/model_checker_platform.xml)
88     endforeach()
89     ADD_TEST(cover-mc-bugged1-liveness ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness ${CMAKE_HOME_DIRECTORY}/examples/platforms/small_platform.xml 1 1001)
90   endif()
91
92 else()
93   foreach (example mc-bugged1 mc-bugged2  mc-centralized-mutex mc-failing-assert mc-electric-fence 
94                    mc-bugged1-liveness mc-bugged2-liveness)
95     set(_${example}_disable 1)
96   endforeach()
97 endif()
98
99 if(NOT HAVE_GRAPHVIZ)
100   set(_dag-from-dot_disable 1)
101 endif()
102
103 if(NOT SIMGRID_HAVE_NS3)
104   foreach (example network-ns3 network-ns3-wifi)
105     set(_${example}_disable 1)
106   endforeach()
107 endif()
108
109 # Deal with each example
110
111 foreach (example activity-testany activity-waitany
112                  actor-create actor-daemon actor-exiting actor-join actor-kill
113                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
114                  app-bittorrent app-chainsend app-token-ring
115                  comm-pingpong comm-ready comm-serialize comm-suspend comm-testany comm-wait comm-waitany comm-waitall comm-waituntil
116                  comm-dependent comm-host2host comm-failure comm-throttling
117                  cloud-capping cloud-migration cloud-simple
118                  dag-comm dag-from-dax dag-from-dot dag-failure dag-io dag-scheduling dag-simple
119                  dht-chord dht-kademlia
120                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
121                  engine-filtering engine-run-partial
122                  exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
123                  exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure
124                  maestro-set
125                  mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert
126                  network-ns3 network-ns3-wifi network-wifi
127                  io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
128                  platform-failures platform-profile platform-properties
129                  plugin-host-load plugin-link-load plugin-prodcons
130                  replay-comm replay-io
131                  routing-get-clusters
132                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
133                  clusters-multicpu network-factors network-nonlinear)
134
135   # Use default source file unless specified otherwise
136   if(NOT DEFINED _${example}_sources)
137     set(_${example}_sources ${example}/s4u-${example}.cpp)
138   endif()
139
140   if(NOT DEFINED _${example}_disable)
141     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
142     add_dependencies     (tests s4u-${example})
143     add_dependencies     (s4u-${example} platf_cpp)
144     target_link_libraries(s4u-${example} simgrid)
145     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
146
147     # Use default factories unless specified otherwise
148     if(NOT DEFINED _${example}_factories)
149       set(_${example}_factories "*")
150     endif()
151 #    message("Factories of ${example}: ${_${example}_factories}")
152
153     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
154                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
155                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
156                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
157                                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
158                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
159                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
160   else()
161     message(STATUS "Example ${example} disabled, thus not compiled.")
162     unset(_${example}_disable)
163   endif()
164
165   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
166   foreach(file ${_${example}_sources})
167     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
168   endforeach()
169
170   unset(_${example}_factories)
171   unset(_${example}_sources)
172 endforeach()
173
174
175 # Specific examples
176 ###################
177
178 # MASTERWORKERS EXAMPLE
179 foreach(variant fun class)
180   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
181   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
182   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
183   add_dependencies(tests s4u-app-masterworkers-${variant})
184
185   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
186 endforeach()
187 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
188
189 # The tests the parallel variant of of DHTs
190
191 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
192   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
193   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
194   set(parallel-factories "^ucontext")
195 else()
196   set(parallel-factories "*")
197 endif()
198
199 foreach(example app-bittorrent app-masterworkers
200                 dht-chord dht-kademlia
201                 )
202   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
203                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
204                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
205                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
206                                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
207 endforeach()
208
209 # Examples not accepting factories
210 ##################################
211
212 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
213                  trace-host-user-variables trace-link-user-variables trace-route-user-variables)
214   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
215   target_link_libraries(s4u-${example} simgrid)
216   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
217   add_dependencies(tests s4u-${example})
218
219   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
220   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
221
222   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
223                           --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
224                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
225                           --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
226                           ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
227 endforeach()
228
229 if (NOT enable_memcheck AND NOT WIN32)
230   ADD_TESH(simix-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
231                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
232                             ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh)
233 endif()
234
235 # Add all extra files to the archive
236 ####################################
237 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp        PARENT_SCOPE)
238 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/simix-breakpoint.tesh
239                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
240                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh  PARENT_SCOPE)
241 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
242                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
243                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
244                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
245                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
246                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
247                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
248                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
249                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
250                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
251                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
252                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
253                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
254                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
255                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
256                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
257                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
258                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
259                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
260 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
261                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
262                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness
263                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged2-liveness/promela_bugged2_liveness PARENT_SCOPE)
264 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
265                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml     
266                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
267                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
268                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
269                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
270                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
271                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)