Logo AND Algorithmique Numérique Distribuée

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