Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a MC version of the s4u-synchro-mutex test
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 24 Feb 2022 11:43:22 +0000 (12:43 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 24 Feb 2022 11:43:28 +0000 (12:43 +0100)
examples/cpp/CMakeLists.txt
examples/cpp/synchro-mutex/s4u-mc-synchro-mutex.tesh [new file with mode: 0644]
examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp
include/xbt/config.hpp

index cd6f65e..90e2b0f 100644 (file)
@@ -53,6 +53,19 @@ if(SIMGRID_HAVE_MC)
     set(_mc-bugged1-liveness_disable 1)
   endif()
 
+  # Hijack some regular tests to run them on top of the MC
+  foreach (example synchro-mutex)
+    ADD_TESH(s4u-mc-${example} 
+                       --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example}
+                       --setenv libdir=${CMAKE_BINARY_DIR}/lib
+                       --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms
+                       --setenv srcdir=${CMAKE_CURRENT_SOURCE_DIR}/${example}
+                       --cd ${CMAKE_CURRENT_SOURCE_DIR}/${example}
+                       ${CMAKE_HOME_DIRECTORY}/examples/cpp/${example}/s4u-mc-${example}.tesh)
+    set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/${example}/s4u-mc-${example}.tesh)
+  endforeach()
+
+
   # This example never ends, disable it for now
   set(_mc-bugged2-liveness_disable 1)
   
diff --git a/examples/cpp/synchro-mutex/s4u-mc-synchro-mutex.tesh b/examples/cpp/synchro-mutex/s4u-mc-synchro-mutex.tesh
new file mode 100644 (file)
index 0000000..685e522
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/env tesh
+
+$ ${bindir:=.}/../../../bin/simgrid-mc -- ${bindir:=.}/s4u-synchro-mutex --cfg=actors:1 --log=s4u_test.thres:critical
+> [0.000000] [mc_safety/INFO] Start a DFS exploration. Reduction is: dpor.
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'actors' to '1'
+> [0.000000] [mc_safety/INFO] DFS exploration ended. 13 unique states visited; 3 backtracks (18 transition replays, 3 states visited overall)
+
+$ ${bindir:=.}/../../../bin/simgrid-mc -- ${bindir:=.}/s4u-synchro-mutex --cfg=actors:2 --log=s4u_test.thres:critical
+> [0.000000] [mc_safety/INFO] Start a DFS exploration. Reduction is: dpor.
+> [0.000000] [xbt_cfg/INFO] Configuration change: Set 'actors' to '2'
+> [0.000000] [mc_safety/INFO] DFS exploration ended. 241 unique states visited; 79 backtracks (744 transition replays, 425 states visited overall)
index 9c9f45d..c73a6bc 100644 (file)
@@ -4,11 +4,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/s4u.hpp" /* All of S4U */
-#include "simgrid/modelchecker.h" // This example is also used to test the modelchecker on mutexes
+#include "xbt/config.hpp"
 
 #include <mutex> /* std::mutex and std::lock_guard */
 
-int NB_ACTOR = 6;
+static simgrid::config::Flag<int> cfg_actor_count("actors", "How many pairs of actors should be started?", 6);
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category");
 
@@ -48,7 +48,7 @@ static void master()
   int result = 0;
   simgrid::s4u::MutexPtr mutex = simgrid::s4u::Mutex::create();
 
-  for (int i = 0; i < NB_ACTOR * 2 ; i++) {
+  for (int i = 0; i < cfg_actor_count * 2; i++) {
     // To create a worker use the static method simgrid::s4u::Actor.
     if((i % 2) == 0 )
       simgrid::s4u::Actor::create("worker", simgrid::s4u::Host::by_name("Jupiter"), workerLockGuard, mutex,
@@ -64,10 +64,6 @@ static void master()
 int main(int argc, char **argv)
 {
   simgrid::s4u::Engine e(&argc, argv);
-
-  if (MC_is_active()) // Reduce the size of that test when running in the model-checker
-    NB_ACTOR = 2;
-
   e.load_platform("../../platforms/two_hosts.xml");
   simgrid::s4u::Actor::create("main", e.host_by_name("Tremblay"), master);
   e.run();
index ac6c292..b6ebe3e 100644 (file)
@@ -204,9 +204,9 @@ bind_flag(T& value, const char* name, const char* description, F callback)
 /** A variable bound to a CLI option
  *
  *  <pre><code>
- *  static simgrid::config::flag<int> answer("answer", "Expected answer", 42);
- *  static simgrid::config::flag<std::string> name("name", "Ford Perfect", "John Doe");
- *  static simgrid::config::flag<double> gamma("gamma", "Gamma factor", 1.987);
+ *  static simgrid::config::Flag<int> answer("answer", "Expected answer", 42);
+ *  static simgrid::config::Flag<std::string> name("name", "Ford Perfect", "John Doe");
+ *  static simgrid::config::Flag<double> gamma("gamma", "Gamma factor", 1.987);
  *  </code></pre>
  */
 template<class T>