Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further factorize our cmake code to run the s4u examples
[simgrid.git] / examples / s4u / CMakeLists.txt
index 784968c..663a1cd 100644 (file)
@@ -1,20 +1,30 @@
 
-# Regular examples: with only one source and tested with all factories
-######################################################################
+# Regular examples: with only one source and tested with all factories by default
+#################################################################################
+set(_actor-stacksize_factories "raw;boost;ucontext") # Threads ignore modifications of the stack size
+
+# The maestro-set example only works for threads and when not using windows.
+set(_maestro-set_factories "thread")
+if(WIN32)
+  set(_maestro-set_disable 1)
+endif()
 
-foreach (example actor-create actor-daemon actor-join actor-kill
-                 actor-lifetime actor-migrate actor-suspend actor-yield
+foreach (example actor-create actor-daemon actor-exiting actor-join actor-kill
+                 actor-lifetime actor-migrate actor-suspend actor-yield actor-stacksize
                  app-chainsend app-pingpong app-token-ring
                  async-ready async-wait async-waitany async-waitall async-waituntil
+                 comm-dependent
                  cloud-capping cloud-migration cloud-simple
-                 energy-exec energy-boot energy-link energy-vm
+                 energy-exec energy-boot energy-link energy-vm energy-exec-ptask
                  engine-filtering
-                 exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
-                 io-async io-file-system io-file-remote io-storage-raw
-                 platform-failures platform-properties plugin-hostload 
-                 replay-comm replay-storage
+                 exec-async exec-basic exec-dvfs exec-ptask exec-remote exec-waitany exec-waitfor exec-dependent
+                maestro-set
+                 io-async io-file-system io-file-remote io-disk-raw io-dependent
+                 platform-failures platform-profile platform-properties
+                 plugin-hostload
+                 replay-comm replay-io
                  routing-get-clusters
-                 synchro-barrier synchro-mutex synchro-semaphore)
+                 synchro-barrier synchro-condition-variable synchro-mutex synchro-semaphore)
   add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
   add_dependencies     (tests s4u-${example})
   target_link_libraries(s4u-${example} simgrid)
@@ -22,15 +32,50 @@ foreach (example actor-create actor-daemon actor-join actor-kill
 
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
   set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
+
+  # Use default factories unless specified otherwise
+  if(NOT DEFINED _${example}_factories)
+    set(_${example}_factories "thread;ucontext;raw;boost")
+  endif()
+#  message("Factories of ${example}: ${_${example}_factories}")
+
+  if(NOT DEFINED _${example}_disabled)
+    ADD_TESH_FACTORIES(s4u-${example} "${_${example}_factories}"
+                                      --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
+                                     --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
+                                     --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example} 
+                                     ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
+  else()
+    message(STATUS "Example disabled on this system/architecture")
+    unset(_${example}_disabled)
+  endif()
+
+  unset(_${example}_factories)
+endforeach()
+
+
+# Model-checking examples: with only one source and tested with all factories but thread
+######################################################################
+
+foreach (example mc-failing-assert)
+  if(SIMGRID_HAVE_MC)
+    add_executable       (s4u-${example} EXCLUDE_FROM_ALL ${example}/s4u-${example}.cpp)
+    add_dependencies     (tests s4u-${example})
+    target_link_libraries(s4u-${example} simgrid)
+    set_target_properties(s4u-${example} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${example})
+
   
-  ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost"
-                                    --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
+    ADD_TESH_FACTORIES(s4u-${example} "ucontext;raw;boost"
+                                      --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
                                    --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
                                    --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example} 
                                    ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
+  endif()
+  
+  set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.tesh)
+  set(examples_src  ${examples_src}  ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-${example}.cpp)
 endforeach()
 
-set_tesh_properties(s4u-platform-failures "thread;ucontext;raw;boost" WILL_FAIL TRUE) # FIXME
 
 # Multi-files examples
 ######################
@@ -78,6 +123,16 @@ foreach (file s4u-bittorrent s4u-peer s4u-tracker)
                                      ${CMAKE_CURRENT_SOURCE_DIR}/app-bittorrent/${file}.hpp)
 endforeach()
 
+# The tests of DHT, along with the parallel variant
+
+if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+  # Thread-local storage (TLS) is needed for parallel execution, but it doesn't
+  # play well with Ucontexts on 64bit SunOS (at least on x86_64).
+  set(parallel-factories "thread;raw;boost")
+else()
+  set(parallel-factories "thread;ucontext;raw;boost")
+endif()
+
 foreach(example app-bittorrent app-masterworkers 
                 dht-chord dht-kademlia
                 )
@@ -86,6 +141,12 @@ foreach(example app-bittorrent app-masterworkers
                                    --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
                                    --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example} 
                                    ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
+
+  ADD_TESH_FACTORIES(s4u-${example}-parallel "${parallel-factories}" --cfg contexts/nthreads:4 ${CONTEXTS_SYNCHRO}
+                                             --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
+                                            --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms 
+                                            --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example} 
+                                            ${CMAKE_HOME_DIRECTORY}/examples/s4u/${example}/s4u-${example}.tesh)
 endforeach()
 
 # Examples not accepting factories
@@ -128,7 +189,6 @@ set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-a
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitany/s4u-async-waitany_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waitall/s4u-async-waitall_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/async-wait/s4u-async-wait_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-ready/s4u-async-ready_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/async-waituntil/s4u-async-waituntil_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/dht-chord/s4u-dht-chord_d.xml
@@ -136,15 +196,14 @@ set(xml_files     ${xml_files}    ${CMAKE_CURRENT_SOURCE_DIR}/actor-create/s4u-a
                                   ${CMAKE_CURRENT_SOURCE_DIR}/energy-boot/platform_boot.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/io-file-remote/s4u-io-file-remote_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/platform-properties/s4u-platform-properties_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-masterworker-failures_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/platform-failures/s4u-platform-failures_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split_d.xml
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm_d.xml
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/replay-storage/s4u-replay-storage_d.xml
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io_d.xml
                   PARENT_SCOPE)
 set(bin_files     ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/dht-kademlia/generate.py                     PARENT_SCOPE)
 set(txt_files     ${txt_files}    ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p0.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm-split-p1.txt
                                   ${CMAKE_CURRENT_SOURCE_DIR}/replay-comm/s4u-replay-comm.txt
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/replay-storage/s4u-replay-storage.txt
-                                  ${CMAKE_CURRENT_SOURCE_DIR}/README.rst                                   PARENT_SCOPE)
+                                  ${CMAKE_CURRENT_SOURCE_DIR}/replay-io/s4u-replay-io.txt                  PARENT_SCOPE)