1 # Regular examples: with only one source and tested with all factories by default
2 #################################################################################
3 ### Define the examples' specificities
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)
14 set(_actor-stacksize_factories "^thread") # Threads ignore modifications of the stack size
16 # The maestro-set example only works for threads
17 set(_maestro-set_factories "thread")
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})
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)
32 foreach (example mc-bugged1 mc-bugged2 mc-centralized-mutex mc-failing-assert mc-electric-fence)
33 set(_${example}_disable 1)
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)
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)
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")
57 # This example never ends, disable it for now
58 set(_mc-bugged2-liveness_disable 1)
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/)
72 set(_mc-bugged1-liveness_disable 1)
73 set(_mc-bugged2-liveness_disable 1)
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)
81 foreach (example mc-bugged1-liveness mc-bugged2-liveness)
82 set(_${example}_disable 1)
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)
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)
99 add_dependencies(tests-mc s4u-${example})
104 # Dependency on the regular tests
105 foreach(example mc-centralized-mutex)
106 add_dependencies(tests-mc s4u-${example})
110 if(NOT HAVE_GRAPHVIZ)
111 set(_dag-from-dot_disable 1)
112 set(_dag-from-dot-simple_disable 1)
115 if (NOT SIMGRID_HAVE_JSON)
116 set(_dag-from-json-simple_disable 1)
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)
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)
128 foreach (example network-ns3 network-ns3-wifi)
129 add_dependencies(tests-ns3 s4u-${example})
133 # Even if ns3 is not found, we need to override the teshfile name and make sure that everything gets included in the archive
134 set(_network-ns3_teshfile ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-notime.tesh)
135 set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/network-ns3/s4u-network-ns3-timed.tesh)
137 foreach (example network-ns3 network-ns3-wifi)
138 set(_${example}_disable 1)
142 # Deal with each example
144 foreach (example activity-testany activity-waitany
145 actor-create actor-daemon actor-exiting actor-join actor-kill
146 actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
147 app-bittorrent app-chainsend app-token-ring
148 battery-degradation battery-simple battery-energy
149 comm-pingpong comm-ready comm-suspend comm-testany comm-wait comm-waitany comm-waitall comm-waituntil
150 comm-dependent comm-host2host comm-failure comm-throttling
151 cloud-capping cloud-migration cloud-simple
152 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
153 dht-chord dht-kademlia
154 energy-exec energy-boot energy-link energy-vm energy-exec-ptask energy-wifi
155 engine-filtering engine-run-partial
156 exec-async exec-basic exec-dvfs exec-remote exec-waitany exec-waitfor exec-dependent exec-unassigned
157 exec-ptask-multicore exec-ptask-multicore-latency exec-cpu-nonlinear exec-cpu-factors exec-failure exec-threads
159 mc-bugged1 mc-bugged1-liveness mc-bugged2 mc-bugged2-liveness mc-centralized-mutex mc-electric-fence mc-failing-assert
160 network-ns3 network-ns3-wifi network-wifi
161 io-async io-priority io-degradation io-file-system io-file-remote io-disk-raw io-dependent
162 operation-simple operation-variable-load operation-switch-host
163 platform-comm-serialize platform-failures platform-profile platform-properties
164 plugin-host-load plugin-link-load plugin-prodcons
165 replay-comm replay-io
167 synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
168 clusters-multicpu network-factors network-nonlinear)
170 # Use default source file unless specified otherwise
171 if(NOT DEFINED _${example}_sources)
172 set(_${example}_sources ${example}/s4u-${example}.cpp)
175 # Use default tesh file unless specified otherwise
176 if(NOT DEFINED _${example}_teshfile)
177 set(_${example}_teshfile ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
180 if(NOT DEFINED _${example}_disable)
181 add_executable (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
182 add_dependencies (tests s4u-${example})
183 add_dependencies (s4u-${example} platf_cpp)
184 target_link_libraries(s4u-${example} simgrid)
185 set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
187 # Use default factories unless specified otherwise
188 if(NOT DEFINED _${example}_factories)
189 set(_${example}_factories "*")
191 # message("Factories of ${example}: ${_${example}_factories}")
193 ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
194 --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
195 --setenv libdir=${CMAKE_BINARY_DIR}/lib
196 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
197 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
198 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
199 ${_${example}_teshfile})
201 message(STATUS "Example ${example} disabled, thus not compiled.")
202 unset(_${example}_disable)
205 set(tesh_files ${tesh_files} ${_${example}_teshfile})
206 foreach(file ${_${example}_sources})
207 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
210 unset(_${example}_factories)
211 unset(_${example}_sources)
212 unset(_${example}_teshfile)
215 # Don't run mc-*-liveness tests in parallel, as they can use a lot of memory and timeout.
216 get_directory_property(_serial_tests TESTS)
217 list(FILTER _serial_tests INCLUDE REGEX "-mc-.*-liveness-")
218 set_tests_properties(${_serial_tests} PROPERTIES RUN_SERIAL "TRUE")
223 # MASTERWORKERS EXAMPLE
224 foreach(variant fun class)
225 add_executable (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
226 target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
227 set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
228 add_dependencies(tests s4u-app-masterworkers-${variant})
230 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
232 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
234 # The tests the parallel variant of of DHTs
236 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
237 # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
238 # play well with Ucontexts on 64bit SunOS (at least on x86_64).
239 set(parallel-factories "^ucontext")
241 set(parallel-factories "*")
244 foreach(example app-bittorrent app-masterworkers
245 dht-chord dht-kademlia
247 ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
248 --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
249 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
250 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
251 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
254 # Test non-DPOR reductions on a given MC test
255 foreach(example mc-failing-assert)
256 # State equality is not tested because it would take about 15 hours to run that test on my machine.
257 # We should first optimize mmalloc_heap_differ() which takes ~4sec for each pair to compare (maybe {175 x 174/ 2} pairs here)
258 # See the comment on mmalloc_heap_differ() in compare.cpp for more info on why it's hard to optimize.
260 # if(SIMGRID_HAVE_STATEFUL_MC)
261 # ADD_TESH(s4u-${example}-statequality --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}-statequality.tesh)
270 ADD_TESH(s4u-${example}-nodpor --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
271 --setenv libdir=${CMAKE_BINARY_DIR}/lib
272 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
273 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
274 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
275 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
277 set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
278 set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
281 # Examples not accepting factories
282 ##################################
284 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
285 trace-host-user-variables trace-link-user-variables trace-route-user-variables)
286 add_executable (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
287 target_link_libraries(s4u-${example} simgrid)
288 set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
289 add_dependencies(tests s4u-${example})
291 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
292 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
294 ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
295 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
296 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
297 --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
298 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
301 if (NOT enable_memcheck)
302 ADD_TESH(debug-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
303 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
304 ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh)
307 # Add all extra files to the archive
308 ####################################
309 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp PARENT_SCOPE)
310 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh
311 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
312 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh PARENT_SCOPE)
313 set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
314 ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
315 ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
316 ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
317 ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
318 ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
319 ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
320 ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
321 ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
322 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
323 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
324 ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
325 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
326 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
327 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
328 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
329 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
330 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
331 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml PARENT_SCOPE)
332 set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/battery-degradation/plot_battery_degradation.py
333 ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
334 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
335 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness
336 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged2-liveness/promela_bugged2_liveness PARENT_SCOPE)
337 set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
338 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml
339 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax-simple/dag.xml
340 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
341 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot-simple/dag.dot
342 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
343 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-json-simple/dag.json
344 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
345 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
346 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
347 ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt PARENT_SCOPE)