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 platform-comm-serialize platform-failures platform-profile platform-properties
163 plugin-host-load plugin-link-load plugin-prodcons
164 replay-comm replay-io
166 synchro-barrier synchro-condition-variable synchro-condition-variable-waituntil synchro-mutex synchro-semaphore
167 clusters-multicpu network-factors network-nonlinear)
169 # Use default source file unless specified otherwise
170 if(NOT DEFINED _${example}_sources)
171 set(_${example}_sources ${example}/s4u-${example}.cpp)
174 # Use default tesh file unless specified otherwise
175 if(NOT DEFINED _${example}_teshfile)
176 set(_${example}_teshfile ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
179 if(NOT DEFINED _${example}_disable)
180 add_executable (s4u-${example} EXCLUDE_FROM_ALL ${_${example}_sources})
181 add_dependencies (tests s4u-${example})
182 add_dependencies (s4u-${example} platf_cpp)
183 target_link_libraries(s4u-${example} simgrid)
184 set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
186 # Use default factories unless specified otherwise
187 if(NOT DEFINED _${example}_factories)
188 set(_${example}_factories "*")
190 # message("Factories of ${example}: ${_${example}_factories}")
192 ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
193 --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
194 --setenv libdir=${CMAKE_BINARY_DIR}/lib
195 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
196 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
197 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
198 ${_${example}_teshfile})
200 message(STATUS "Example ${example} disabled, thus not compiled.")
201 unset(_${example}_disable)
204 set(tesh_files ${tesh_files} ${_${example}_teshfile})
205 foreach(file ${_${example}_sources})
206 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${file})
209 unset(_${example}_factories)
210 unset(_${example}_sources)
211 unset(_${example}_teshfile)
218 # MASTERWORKERS EXAMPLE
219 foreach(variant fun class)
220 add_executable (s4u-app-masterworkers-${variant} EXCLUDE_FROM_ALL app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
221 target_link_libraries(s4u-app-masterworkers-${variant} simgrid)
222 set_target_properties(s4u-app-masterworkers-${variant} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/app-masterworkers)
223 add_dependencies(tests s4u-app-masterworkers-${variant})
225 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers-${variant}.cpp)
227 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers.tesh)
229 # The tests the parallel variant of of DHTs
231 if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
232 # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
233 # play well with Ucontexts on 64bit SunOS (at least on x86_64).
234 set(parallel-factories "^ucontext")
236 set(parallel-factories "*")
239 foreach(example app-bittorrent app-masterworkers
240 dht-chord dht-kademlia
242 ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
243 --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
244 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
245 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
246 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
249 # Test non-DPOR reductions on a given MC test
250 foreach(example mc-failing-assert)
251 # State equality is not tested because it would take about 15 hours to run that test on my machine.
252 # We should first optimize mmalloc_heap_differ() which takes ~4sec for each pair to compare (maybe {175 x 174/ 2} pairs here)
253 # See the comment on mmalloc_heap_differ() in compare.cpp for more info on why it's hard to optimize.
255 # if(SIMGRID_HAVE_STATEFUL_MC)
256 # ADD_TESH(s4u-${example}-statequality --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
257 # --setenv libdir=${CMAKE_BINARY_DIR}/lib
258 # --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
259 # --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
260 # --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
261 # ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
265 ADD_TESH(s4u-${example}-nodpor --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
266 --setenv libdir=${CMAKE_BINARY_DIR}/lib
267 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
268 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
269 --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
270 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
272 set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-statequality.tesh)
273 set(tesh_files ${tesh_files} ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}-nodpor.tesh)
276 # Examples not accepting factories
277 ##################################
279 foreach (example exec-ptask trace-categories trace-masterworkers trace-platform trace-process-migration
280 trace-host-user-variables trace-link-user-variables trace-route-user-variables)
281 add_executable (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
282 target_link_libraries(s4u-${example} simgrid)
283 set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
284 add_dependencies(tests s4u-${example})
286 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
287 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
289 ADD_TESH(s4u-${example} --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
290 --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
291 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
292 --cd ${CMAKE_CURRENT_BINARY_DIR}/${example}
293 ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-${example}.tesh)
296 if (NOT enable_memcheck)
297 ADD_TESH(debug-breakpoint --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/comm-pingpong
298 --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
299 ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh)
302 # Add all extra files to the archive
303 ####################################
304 set(examples_src ${examples_src} ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp PARENT_SCOPE)
305 set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/comm-pingpong/debug-breakpoint.tesh
306 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness.tesh
307 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-visited.tesh PARENT_SCOPE)
308 set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-actor-create_d.xml
309 ${CMAKE_CURRENT_SOURCE_DIR}/actor-lifetime/s4u-actor-lifetime_d.xml
310 ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/s4u-app-bittorrent_d.xml
311 ${CMAKE_CURRENT_SOURCE_DIR}/app-masterworkers/s4u-app-masterworkers_d.xml
312 ${CMAKE_CURRENT_SOURCE_DIR}/dag-scheduling/Montage_25.xml
313 ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
314 ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/s4u-dht-kademlia_d.xml
315 ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
316 ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
317 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
318 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
319 ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
320 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3hosts_2links_d.xml
321 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links-timer_d.xml
322 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/3links_d.xml
323 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/crosstraffic_d.xml
324 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/dogbone_d.xml
325 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/onelink_d.xml
326 ${CMAKE_CURRENT_SOURCE_DIR}/network-ns3/one_cluster_d.xml PARENT_SCOPE)
327 set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/battery-degradation/plot_battery_degradation.py
328 ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py
329 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/s4u-mc-bugged1-liveness-stack-cleaner
330 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged1-liveness/promela_bugged1_liveness
331 ${CMAKE_CURRENT_SOURCE_DIR}/mc-bugged2-liveness/promela_bugged2_liveness PARENT_SCOPE)
332 set(txt_files ${txt_files} ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/simple_dax_with_cycle.xml
333 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax/smalldax.xml
334 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dax-simple/dag.xml
335 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag.dot
336 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot-simple/dag.dot
337 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-dot/dag_with_cycle.dot
338 ${CMAKE_CURRENT_SOURCE_DIR}/dag-from-json-simple/dag.json
339 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
340 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
341 ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
342 ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt PARENT_SCOPE)