Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix make distcheck, stupid bummer
[simgrid.git] / examples / cpp / CMakeLists.txt
1 # Regular examples: with only one source and tested with all factories by default
2 #################################################################################
3 ### Define the examples' specificities
4
5 set(_app-bittorrent_sources app-bittorrent/s4u-bittorrent.cpp app-bittorrent/s4u-bittorrent.hpp
6                             app-bittorrent/s4u-peer.cpp app-bittorrent/s4u-peer.hpp
7                             app-bittorrent/s4u-tracker.cpp app-bittorrent/s4u-tracker.hpp)
8 set(_dht-chord_sources    dht-chord/s4u-dht-chord.cpp dht-chord/s4u-dht-chord.hpp dht-chord/s4u-dht-chord-node.cpp)
9 set(_dht-kademlia_sources dht-kademlia/s4u-dht-kademlia.cpp dht-kademlia/s4u-dht-kademlia.hpp
10                           dht-kademlia/node.cpp dht-kademlia/node.hpp
11                           dht-kademlia/routing_table.cpp dht-kademlia/routing_table.hpp
12                           dht-kademlia/answer.cpp dht-kademlia/answer.hpp dht-kademlia/message.hpp)
13
14 set(_actor-stacksize_factories "^thread") # Threads ignore modifications of the stack size
15
16 # The maestro-set example only works for threads
17 set(_maestro-set_factories "thread")
18
19 if(SIMGRID_HAVE_MC)
20   # These tests timeout with threads, not sure why
21   foreach(example mc-bugged1 mc-bugged2 mc-failing-assert mc-electric-fence)
22     set(_${example}_factories "^thread") # Timeout
23     add_dependencies(tests-mc s4u-${example})
24   endforeach()
25
26   if(enable_coverage)
27     foreach (example mc-bugged1 mc-bugged2 mc-electric-fence mc-failing-assert)
28       ADD_TEST(cover-${example} ${CMAKE_CURRENT_BINARY_DIR}/${example}/s4u-${example} ${CMAKE_HOME_DIRECTORY}/examples/platforms/model_checker_platform.xml)
29     endforeach()
30   endif()
31 else()
32   foreach (example mc-bugged1 mc-bugged2  mc-centralized-mutex mc-failing-assert mc-electric-fence)
33     set(_${example}_disable 1)
34   endforeach()
35 endif()
36
37 if(SIMGRID_HAVE_STATEFUL_MC)
38   if(HAVE_C_STACK_CLEANER)
39     add_executable       (s4u-mc-bugged1-liveness-cleaner-on  EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
40     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-on  simgrid)
41     set_target_properties(s4u-mc-bugged1-liveness-cleaner-on  PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fstack-cleaner")
42     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-on)
43
44     add_executable       (s4u-mc-bugged1-liveness-cleaner-off EXCLUDE_FROM_ALL s4u-mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp)
45     target_link_libraries(s4u-mc-bugged1-liveness-cleaner-off simgrid)
46     set_target_properties(s4u-mc-bugged1-liveness-cleaner-off PROPERTIES COMPILE_FLAGS "-DGARBAGE_STACK -fno-stack-cleaner")
47     add_dependencies(tests-mc s4u-mc-bugged1-liveness-cleaner-off)
48   endif()
49
50   # Model-checking liveness
51   if(HAVE_UCONTEXT_CONTEXTS AND SIMGRID_PROCESSOR_x86_64)
52     # liveness model-checking works only on 64bits (for now ...)
53     set(_mc-bugged1-liveness_factories "ucontext")
54     add_dependencies(tests-mc s4u-mc-bugged1-liveness)
55     set(_mc-bugged2-liveness_factories "ucontext")
56
57     # This example never ends, disable it for now
58     set(_mc-bugged2-liveness_disable 1)
59
60     ADD_TESH(s4u-mc-bugged1-liveness-visited-ucontext --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness
61                                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
62                                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness
63                                                        ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh)
64     IF(HAVE_C_STACK_CLEANER)
65       add_dependencies(tests-mc s4u-mc-bugged1-liveness-stack-cleaner)
66       # This test checks if the stack cleaner is making a difference:
67       ADD_TEST(s4u-mc-bugged1-liveness-stack-cleaner ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
68                                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/mc-bugged1-liveness/
69                                                      ${CMAKE_CURRENT_BINARY_DIR}/mc-bugged1-liveness/)
70     ENDIF()
71   else()
72     set(_mc-bugged1-liveness_disable 1)
73     set(_mc-bugged2-liveness_disable 1)
74   endif()
75
76   if(enable_coverage)
77     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)
78   endif()
79
80 else()
81   foreach (example mc-bugged1-liveness mc-bugged2-liveness)
82     set(_${example}_disable 1)
83   endforeach()
84 endif()
85
86 # Hijack some regular tests to run them on top of the MC
87 foreach (example synchro-barrier synchro-mutex synchro-semaphore)
88   set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-mc-${example}.tesh)
89
90   if (SIMGRID_HAVE_MC)
91     ADD_TESH(s4u-mc-${example}
92               --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
93               --setenv libdir=${CMAKE_BINARY_DIR}/lib
94               --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
95               --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
96               --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
97               ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-mc-${example}.tesh)
98
99     add_dependencies(tests-mc s4u-${example})
100   endif()
101 endforeach()
102
103 if (SIMGRID_HAVE_MC)
104   # Dependency on the regular tests
105   foreach(example mc-centralized-mutex)
106     add_dependencies(tests-mc s4u-${example})
107   endforeach()
108 endif()
109
110 if(NOT HAVE_GRAPHVIZ)
111   set(_dag-from-dot_disable 1)
112   set(_dag-from-dot-simple_disable 1)
113 endif()
114
115 if (NOT SIMGRID_HAVE_JSON)
116   set(_dag-from-json-simple_disable 1)
117 endif()
118
119 if(SIMGRID_HAVE_NS3)
120   if(NS3_VERSION VERSION_GREATER_EQUAL 3.37)
121     set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
122     set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
123   else()
124     set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
125     set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
126   endif()
127
128 else()
129   # Even if ns3 is not found, we need to override the teshfile name and make sure that everything gets included in the archive
130   set(_network-ns3_teshfile         ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
131   set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
132
133   foreach (example network-ns3 network-ns3-wifi)
134     set(_${example}_disable 1)
135   endforeach()
136 endif()
137
138 # Deal with each example
139
140 foreach (example activity-testany activity-waitany
141                  actor-create actor-daemon actor-exiting actor-join actor-kill
142                  actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
143                  app-bittorrent app-chainsend app-token-ring
144                  battery-degradation battery-simple battery-energy
145                  comm-pingpong comm-ready comm-suspend comm-testany comm-wait comm-waitany comm-waitall comm-waituntil
146                  comm-dependent comm-host2host comm-failure comm-throttling
147                  cloud-capping cloud-migration cloud-simple
148                  dag-comm dag-from-json-simple dag-from-dax-simple dag-from-dax dag-from-dot-simple dag-from-dot dag-failure dag-io dag-scheduling dag-simple dag-tuto
149                  dht-chord dht-kademlia
150                  energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
151                  engine-filtering engine-run-partial
152                  exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
153                  exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure exec-threads
154                  maestro-set
155                  mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert
156                  network-ns3 network-ns3-wifi network-wifi
157                  io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
158                  platform-comm-serialize platform-failures platform-profile platform-properties
159                  plugin-host-load plugin-link-load plugin-prodcons
160                  replay-comm replay-io
161                  routing-get-clusters
162                  synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
163                  clusters-multicpu network-factors network-nonlinear)
164
165   # Use default source file unless specified otherwise
166   if(NOT DEFINED _${example}_sources)
167     set(_${example}_sources ${example}/s4u-${example}.cpp)
168   endif()
169
170   # Use default tesh file unless specified otherwise
171   if(NOT DEFINED _${example}_teshfile)
172     set(_${example}_teshfile ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
173   endif()
174
175   if(NOT DEFINED _${example}_disable)
176     add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
177     add_dependencies     (tests s4u-${example})
178     add_dependencies     (s4u-${example} platf_cpp)
179     target_link_libraries(s4u-${example} simgrid)
180     set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
181
182     # Use default factories unless specified otherwise
183     if(NOT DEFINED _${example}_factories)
184       set(_${example}_factories "*")
185     endif()
186 #    message("Factories of ${example}: ${_${example}_factories}")
187
188     ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
189                                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
190                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
191                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
192                                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
193                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
194                                       ${_${example}_teshfile})
195   else()
196     message(STATUS "Example ${example} disabled, thus not compiled.")
197     unset(_${example}_disable)
198   endif()
199
200   set(tesh_files    ${tesh_files}    ${_${example}_teshfile})
201   foreach(file ${_${example}_sources})
202     set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
203   endforeach()
204
205   unset(_${example}_factories)
206   unset(_${example}_sources)
207   unset(_${example}_teshfile)
208 endforeach()
209
210
211 # Specific examples
212 ###################
213
214 # MASTERWORKERS EXAMPLE
215 foreach(variant fun class)
216   add_executable       (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
217   target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
218   set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
219   add_dependencies(tests s4u-app-masterworkers-${variant})
220
221   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
222 endforeach()
223 set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
224
225 # The tests the parallel variant of of DHTs
226
227 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
228   # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
229   # play well with Ucontexts on 64bit SunOS (at least on x86_64).
230   set(parallel-factories "^ucontext")
231 else()
232   set(parallel-factories "*")
233 endif()
234
235 foreach(example app-bittorrent app-masterworkers
236                 dht-chord dht-kademlia
237                 )
238   ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
239                                              --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
240                                              --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
241                                              --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
242                                              ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
243 endforeach()
244
245 # Test non-DPOR reductions on a given MC test
246 foreach(example mc-failing-assert)
247 # State equality is not tested because it would take about 15 hours to run that test on my machine.
248 # We should first optimize mmalloc_heap_differ() which takes ~4sec for each pair to compare (maybe {175 x 174/ 2} pairs here)
249 # See the comment on mmalloc_heap_differ() in compare.cpp for more info on why it's hard to optimize.
250 #
251 #  if(SIMGRID_HAVE_STATEFUL_MC)
252 #    ADD_TESH(s4u-${example}-statequality  --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
253 #                                      --setenv libdir=${CMAKE_BINARY_DIR}/lib
254 #                                      --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
255 #                                      --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
256 #                                      --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
257 #                                      ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
258 #  endif()
259
260   if(SIMGRID_HAVE_MC)
261     ADD_TESH(s4u-${example}-nodpor    --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
262                                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
263                                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
264                                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
265                                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
266                                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
267   endif()                                    
268   set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
269   set(tesh_files    ${tesh_files}   ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
270 endforeach()
271
272 # Examples not accepting factories
273 ##################################
274
275 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
276                  trace-host-user-variables trace-link-user-variables trace-route-user-variables)
277   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
278   target_link_libraries(s4u-${example} simgrid)
279   set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
280   add_dependencies(tests s4u-${example})
281
282   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
283   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
284
285   ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
286                           --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
287                           --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
288                           --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
289                           ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
290 endforeach()
291
292 if (NOT enable_memcheck)
293   ADD_TESH(debug-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
294                             --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
295                             ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh)
296 endif()
297
298 # Add all extra files to the archive
299 ####################################
300 set(examples_src  ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp        PARENT_SCOPE)
301 set(tesh_files    ${tesh_files}   ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh
302                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
303                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh  PARENT_SCOPE)
304 set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
305                                   ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
306                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
307                                   ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
308                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
309                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
310                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
311                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
312                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
313                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
314                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
315                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
316                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
317                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
318                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
319                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
320                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
321                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
322                                   ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml                PARENT_SCOPE)
323 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/battery-degradation/plot_battery_degradation.py
324                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
325                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
326                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness
327                                   ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged2-liveness/promela_bugged2_liveness PARENT_SCOPE)
328 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
329                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml
330                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax-simple/dag.xml
331                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
332                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot-simple/dag.dot
333                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
334                                   ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-json-simple/dag.json
335                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
336                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
337                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
338                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)