Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
activity-lifecycle: make tests shorter to ensure that they are really done when we...
[simgrid.git] / teshsuite / s4u / activity-lifecycle / activity-lifecycle.cpp
index 11feb0c..97bc3fd 100644 (file)
@@ -59,7 +59,7 @@ static void test_sleep()
     simgrid::s4u::this_actor::sleep_for(5);
     global = true;
   });
-  simgrid::s4u::this_actor::sleep_for(10);
+  simgrid::s4u::this_actor::sleep_for(9);
   xbt_assert(global, "The forked actor did not modify the global after sleeping. Was it killed before?");
 }
 
@@ -133,7 +133,7 @@ static void test_sleep_restart_end()
     all_hosts[1]->turn_off(); // kill the host right at the end of this sleep and of this actor
     sleeper_done = true;
   });
-  simgrid::s4u::this_actor::sleep_for(10);
+  simgrid::s4u::this_actor::sleep_for(9);
   xbt_assert(sleeper_done, "Not sure of how the actor survived the shutdown of its host.");
   all_hosts[1]->turn_on();
 }
@@ -147,7 +147,7 @@ static void test_exec()
     simgrid::s4u::this_actor::execute(500000000);
     global = true;
   });
-  simgrid::s4u::this_actor::sleep_for(10);
+  simgrid::s4u::this_actor::sleep_for(9);
   xbt_assert(global, "The forked actor did not modify the global after executing. Was it killed before?");
 }
 
@@ -226,7 +226,7 @@ static void test_exec_restart_end()
     all_hosts[1]->turn_off();
     all_hosts[1]->turn_on();
   });
-  simgrid::s4u::this_actor::sleep_for(10);
+  simgrid::s4u::this_actor::sleep_for(9);
   xbt_assert(execution_done,
              "Restarted actor was already dead in the scheduling round during which the host_off simcall was issued");
 }
@@ -250,7 +250,7 @@ static void test_comm()
     recv_done = true;
   });
 
-  simgrid::s4u::this_actor::sleep_for(10);
+  simgrid::s4u::this_actor::sleep_for(9);
   xbt_assert(send_done, "Sender killed somehow. It shouldn't");
   xbt_assert(recv_done, "Receiver killed somehow. It shouldn't");
 }
@@ -479,9 +479,7 @@ static void test_link_off_during_transfer()
 
 static void test_link_off_during_wait_any()
 {
-  const double start = simgrid::s4u::Engine::get_clock();
-
-  simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create("receiver", all_hosts[1], [&start]() {
+  simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create("receiver", all_hosts[1], []() {
     assert_exit(false, 2);
     bool receiver_got_network_failure_execution = false;
     bool receiver_got_base_execution = false;
@@ -502,7 +500,7 @@ static void test_link_off_during_wait_any()
     xbt_assert(not receiver_got_base_execution, "The receiver should not have gotten a base Exception");
   });
 
-  simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[2], [&start]() {
+  simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[2], []() {
     assert_exit(false, 2);
     int data = 42;
     bool sender_got_network_failure_execution = false;
@@ -520,9 +518,12 @@ static void test_link_off_during_wait_any()
     xbt_assert(not sender_got_base_execution, "The sender should not have gotten a base Exception");
   });
 
-    simgrid::s4u::this_actor::sleep_for(2.0);
-    XBT_VERB("link off");
-    simgrid::s4u::Link::by_name("link1")->turn_off();
+  simgrid::s4u::this_actor::sleep_for(2.0);
+  XBT_VERB("link off");
+  simgrid::s4u::Link::by_name("link1")->turn_off();
+  simgrid::s4u::this_actor::sleep_for(2.0);
+  XBT_VERB("link on");
+  simgrid::s4u::Link::by_name("link1")->turn_on();
 }