Logo AND Algorithmique Numérique Distribuée

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