+ simgrid::s4u::this_actor::sleep_for(10);
+ all_hosts[1]->turn_on();
+ xbt_assert(sleeper_done, "Not sure of how the actor survived the shutdown of its host.");
+}
+static void test_exec()
+{
+ XBT_INFO("%s: Launch a execute(5s), and let it proceed", __func__);
+ bool global = false;
+
+ simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5", all_hosts[1], [&global]() {
+ assert_exit(false, 5.);
+ simgrid::s4u::this_actor::execute(500000000);
+ global = true;
+ });
+ simgrid::s4u::this_actor::sleep_for(10);
+ xbt_assert(global, "The forked actor did not modify the global after executing. Was it killed before?");
+}
+
+static void test_exec_kill_middle()
+{
+ XBT_INFO("%s: Launch a execute(5s), and kill it after 2 secs", __func__);
+
+ simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_killed", all_hosts[1], []() {
+ assert_exit(true, 2);
+ simgrid::s4u::this_actor::execute(500000000);
+ xbt_die("I should be dead now");
+ });
+
+ simgrid::s4u::this_actor::sleep_for(2);
+ exec5->kill();
+}
+
+static void test_exec_kill_begin()
+{
+ XBT_INFO("%s: Launch a execute(5s), and kill it right after start", __func__);
+
+ simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_killed", all_hosts[1], []() {
+ assert_exit(true, 0);
+ simgrid::s4u::this_actor::execute(500000000);
+ xbt_die("I should be dead now");
+ });
+
+ simgrid::s4u::this_actor::yield();
+ exec5->kill();
+}
+
+static void test_exec_restart_begin()
+{
+ XBT_INFO("%s: Launch a execute(5s), and restart its host right after start", __func__);
+
+ simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], []() {
+ assert_exit(1, 0);
+ simgrid::s4u::this_actor::execute(500000000);
+ xbt_die("I should be dead now");
+ });
+
+ simgrid::s4u::this_actor::yield();
+ exec5->get_host()->turn_off();
+ exec5->get_host()->turn_on();
+ XBT_INFO("Test %s is ending", __func__);
+}
+
+static void test_exec_restart_middle()
+{
+ XBT_INFO("%s: Launch a execute(5s), and restart its host after 2 secs", __func__);
+
+ simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], []() {
+ assert_exit(true, 2);
+ simgrid::s4u::this_actor::execute(500000000);
+ xbt_die("I should be dead now");
+ });
+
+ simgrid::s4u::this_actor::sleep_for(2);
+ exec5->get_host()->turn_off();
+ exec5->get_host()->turn_on();
+ XBT_INFO("Test %s is ending", __func__);
+}
+static void test_exec_restart_end()
+{
+ XBT_INFO("%s: Launch a execute(5s), and restart its host right when it stops", __func__);
+ bool execution_done = false;
+
+ simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], [&execution_done]() {
+ assert_exit(false, 5);
+ simgrid::s4u::this_actor::execute(500000000);
+ execution_done = true;
+ });