Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add test in activity-lifecycle turning off its own host.
[simgrid.git] / teshsuite / s4u / activity-lifecycle / activity-lifecycle.cpp
1 /* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u.hpp"
7
8 #include <cmath>
9
10 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
11
12 std::vector<simgrid::s4u::Host*> all_hosts;
13
14 /* Helper function easing the testing of actor's ending condition */
15 static void assert_exit(bool exp_failed, double duration)
16 {
17   double expected_time = simgrid::s4u::Engine::get_clock() + duration;
18   simgrid::s4u::this_actor::on_exit([exp_failed, expected_time](bool got_failed) {
19     xbt_assert(exp_failed == got_failed, "Exit failure status mismatch. Expected %d, got %d", exp_failed, got_failed);
20     xbt_assert(std::fabs(expected_time - simgrid::s4u::Engine::get_clock()) < 0.001, "Exit time mismatch. Expected %f",
21                expected_time);
22     XBT_VERB("Checks on exit successful");
23   });
24 }
25 /* Helper function in charge of running a test and doing some sanity checks afterward */
26 static void run_test(const char* test_name, const std::function<void()>& test)
27 {
28   simgrid::s4u::Actor::create(test_name, all_hosts[0], test);
29   simgrid::s4u::this_actor::sleep_for(10);
30
31   /* Check that no actor remain (but on host[0], where main_dispatcher lives */
32   for (unsigned int i = 0; i < all_hosts.size(); i++) {
33     std::vector<simgrid::s4u::ActorPtr> all_actors = all_hosts[i]->get_all_actors();
34     unsigned int expected_count = (i == 0) ? 1 : 0; // host[0] contains main_dispatcher, all other are empty
35     if (all_actors.size() != expected_count) {
36       XBT_CRITICAL("Host %s contains %zu actors but %u are expected (i=%u). Existing actors: ",
37                    all_hosts[i]->get_cname(), all_actors.size(), expected_count, i);
38       for (auto act : all_actors)
39         XBT_CRITICAL(" - %s", act->get_cname());
40       xbt_die("This is wrong");
41     }
42   }
43   xbt_assert("TODO: Check that all LMM are empty");
44   XBT_INFO("SUCCESS: %s", test_name);
45   XBT_INFO("#########################################################################################################");
46 }
47
48 /**
49  ** Each tests
50  **/
51
52 static void test_sleep()
53 {
54   XBT_INFO("%s: Launch a sleep(5), and let it proceed", __func__);
55   bool global = false;
56
57   simgrid::s4u::ActorPtr sleeper5 = simgrid::s4u::Actor::create("sleep5", all_hosts[1], [&global]() {
58     assert_exit(false, 5.);
59     simgrid::s4u::this_actor::sleep_for(5);
60     global = true;
61   });
62   simgrid::s4u::this_actor::sleep_for(9);
63   xbt_assert(global, "The forked actor did not modify the global after sleeping. Was it killed before?");
64 }
65
66 static void test_sleep_kill_middle()
67 {
68   XBT_INFO("%s: Launch a sleep(5), and kill it after 2 secs", __func__);
69
70   simgrid::s4u::ActorPtr sleeper5 = simgrid::s4u::Actor::create("sleep5_killed", all_hosts[1], []() {
71     assert_exit(true, 2);
72     simgrid::s4u::this_actor::sleep_for(5);
73     xbt_die("I should be dead now");
74   });
75
76   simgrid::s4u::this_actor::sleep_for(2);
77   sleeper5->kill();
78 }
79
80 static void test_sleep_kill_begin()
81 {
82   XBT_INFO("%s: Launch a sleep(5), and kill it right after start", __func__);
83
84   simgrid::s4u::ActorPtr sleeper5 = simgrid::s4u::Actor::create("sleep5_killed", all_hosts[1], []() {
85     assert_exit(true, 0);
86     simgrid::s4u::this_actor::sleep_for(5);
87     xbt_die("I should be dead now");
88   });
89
90   simgrid::s4u::this_actor::yield();
91   sleeper5->kill();
92 }
93
94 static void test_sleep_restart_begin()
95 {
96   XBT_INFO("%s: Launch a sleep(5), and restart its host right after start", __func__);
97
98   simgrid::s4u::ActorPtr sleeper5 = simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], []() {
99     assert_exit(true, 0);
100     simgrid::s4u::this_actor::sleep_for(5);
101     xbt_die("I should be dead now");
102   });
103
104   simgrid::s4u::this_actor::yield();
105   sleeper5->get_host()->turn_off();
106   sleeper5->get_host()->turn_on();
107   XBT_INFO("Test %s is ending", __func__);
108 }
109
110 static void test_sleep_restart_middle()
111 {
112   XBT_INFO("%s: Launch a sleep(5), and restart its host after 2 secs", __func__);
113
114   simgrid::s4u::ActorPtr sleeper5 = simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], []() {
115     assert_exit(true, 2);
116     simgrid::s4u::this_actor::sleep_for(5);
117     xbt_die("I should be dead now");
118   });
119
120   simgrid::s4u::this_actor::sleep_for(2);
121   sleeper5->get_host()->turn_off();
122   sleeper5->get_host()->turn_on();
123   XBT_INFO("Test %s is ending", __func__);
124 }
125
126 static void test_sleep_restart_end()
127 {
128   XBT_INFO("%s: Launch a sleep(5), and restart its host right when it stops", __func__);
129   bool sleeper_done = false;
130
131   simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], [&sleeper_done]() {
132     assert_exit(false, 5);
133     simgrid::s4u::this_actor::sleep_for(5);
134     sleeper_done = true;
135   });
136   simgrid::s4u::Actor::create("killer", all_hosts[0], []() {
137     simgrid::s4u::this_actor::sleep_for(5);
138     XBT_INFO("Killer!");
139     all_hosts[1]->turn_off();
140     all_hosts[1]->turn_on();
141   });
142   simgrid::s4u::this_actor::sleep_for(9);
143   xbt_assert(sleeper_done,
144              "Restarted actor was already dead in the scheduling round during which the host_off simcall was issued");
145 }
146
147 static void test_exec()
148 {
149   XBT_INFO("%s: Launch a execute(5s), and let it proceed", __func__);
150   bool global = false;
151
152   simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5", all_hosts[1], [&global]() {
153     assert_exit(false, 5.);
154     simgrid::s4u::this_actor::execute(500000000);
155     global = true;
156   });
157   simgrid::s4u::this_actor::sleep_for(9);
158   xbt_assert(global, "The forked actor did not modify the global after executing. Was it killed before?");
159 }
160
161 static void test_exec_kill_middle()
162 {
163   XBT_INFO("%s: Launch a execute(5s), and kill it after 2 secs", __func__);
164
165   simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_killed", all_hosts[1], []() {
166     assert_exit(true, 2);
167     simgrid::s4u::this_actor::execute(500000000);
168     xbt_die("I should be dead now");
169   });
170
171   simgrid::s4u::this_actor::sleep_for(2);
172   exec5->kill();
173 }
174
175 static void test_exec_kill_begin()
176 {
177   XBT_INFO("%s: Launch a execute(5s), and kill it right after start", __func__);
178
179   simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_killed", all_hosts[1], []() {
180     assert_exit(true, 0);
181     simgrid::s4u::this_actor::execute(500000000);
182     xbt_die("I should be dead now");
183   });
184
185   simgrid::s4u::this_actor::yield();
186   exec5->kill();
187 }
188
189 static void test_exec_restart_begin()
190 {
191   XBT_INFO("%s: Launch a execute(5s), and restart its host right after start", __func__);
192
193   simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], []() {
194     assert_exit(1, 0);
195     simgrid::s4u::this_actor::execute(500000000);
196     xbt_die("I should be dead now");
197   });
198
199   simgrid::s4u::this_actor::yield();
200   exec5->get_host()->turn_off();
201   exec5->get_host()->turn_on();
202   XBT_INFO("Test %s is ending", __func__);
203 }
204
205 static void test_exec_restart_middle()
206 {
207   XBT_INFO("%s: Launch a execute(5s), and restart its host after 2 secs", __func__);
208
209   simgrid::s4u::ActorPtr exec5 = simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], []() {
210     assert_exit(true, 2);
211     simgrid::s4u::this_actor::execute(500000000);
212     xbt_die("I should be dead now");
213   });
214
215   simgrid::s4u::this_actor::sleep_for(2);
216   exec5->get_host()->turn_off();
217   exec5->get_host()->turn_on();
218   XBT_INFO("Test %s is ending", __func__);
219 }
220
221 static void test_exec_restart_end()
222 {
223   XBT_INFO("%s: Launch a execute(5s), and restart its host right when it stops", __func__);
224   bool execution_done = false;
225
226   simgrid::s4u::Actor::create("exec5_restarted", all_hosts[1], [&execution_done]() {
227     assert_exit(false, 5);
228     simgrid::s4u::this_actor::execute(500000000);
229     execution_done = true;
230   });
231   simgrid::s4u::Actor::create("killer", all_hosts[0], []() {
232     simgrid::s4u::this_actor::sleep_for(5);
233     XBT_INFO("Killer!");
234     all_hosts[1]->turn_off();
235     all_hosts[1]->turn_on();
236   });
237   simgrid::s4u::this_actor::sleep_for(9);
238   xbt_assert(execution_done,
239              "Restarted actor was already dead in the scheduling round during which the host_off simcall was issued");
240 }
241
242 static void test_turn_off_itself()
243 {
244   XBT_INFO("%s: Launch a sleep(5), then saw off the branch it's sitting on", __func__);
245
246   simgrid::s4u::Actor::create("sleep5_restarted", all_hosts[1], []() {
247     assert_exit(true, 5);
248     simgrid::s4u::this_actor::sleep_for(5);
249     simgrid::s4u::this_actor::get_host()->turn_off();
250     xbt_die("I should be dead now");
251   });
252   simgrid::s4u::this_actor::sleep_for(9);
253   all_hosts[1]->turn_on();
254   XBT_INFO("Test %s is ending", __func__);
255 }
256
257 static void test_comm()
258 {
259   XBT_INFO("%s: Launch a communication", __func__);
260   bool send_done = false;
261   bool recv_done = false;
262
263   simgrid::s4u::Actor::create("sender", all_hosts[1], [&send_done]() {
264     assert_exit(false, 5);
265     char* payload = xbt_strdup("toto");
266     simgrid::s4u::Mailbox::by_name("mb")->put(payload, 5000);
267     send_done = true;
268   });
269   simgrid::s4u::Actor::create("receiver", all_hosts[2], [&recv_done]() {
270     assert_exit(false, 5);
271     void* payload = simgrid::s4u::Mailbox::by_name("mb")->get();
272     xbt_free(payload);
273     recv_done = true;
274   });
275
276   simgrid::s4u::this_actor::sleep_for(9);
277   xbt_assert(send_done, "Sender killed somehow. It shouldn't");
278   xbt_assert(recv_done, "Receiver killed somehow. It shouldn't");
279 }
280
281 static void test_comm_dsend_and_quit_put_before_get()
282 {
283   XBT_INFO("%s: Launch a detached communication and end right after", __func__);
284   bool dsend_done = false;
285   bool recv_done  = false;
286
287   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[1], [&dsend_done]() {
288     assert_exit(false, 0);
289     char* payload = xbt_strdup("toto");
290     simgrid::s4u::Mailbox::by_name("mb")->put_init(payload, 1000)->detach();
291     dsend_done = true;
292   });
293
294   simgrid::s4u::Actor::create("receiver", all_hosts[2], [&recv_done]() {
295     assert_exit(false, 3);
296     simgrid::s4u::this_actor::sleep_for(2);
297     void* payload = simgrid::s4u::Mailbox::by_name("mb")->get();
298     xbt_free(payload);
299     recv_done = true;
300   });
301
302   // Sleep long enough to let the test ends by itself. 3 + surf_precision should be enough.
303   simgrid::s4u::this_actor::sleep_for(4);
304   xbt_assert(dsend_done, "Sender killed somehow. It shouldn't");
305   xbt_assert(recv_done, "Receiver killed somehow. It shouldn't");
306 }
307
308 static void test_comm_dsend_and_quit_get_before_put()
309 {
310   XBT_INFO("%s: Launch a detached communication and end right after", __func__);
311   bool dsend_done = false;
312   bool recv_done  = false;
313
314   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[1], [&dsend_done]() {
315     assert_exit(false, 2);
316     char* payload = xbt_strdup("toto");
317     simgrid::s4u::this_actor::sleep_for(2);
318     simgrid::s4u::Mailbox::by_name("mb")->put_init(payload, 1000)->detach();
319     dsend_done = true;
320   });
321
322   simgrid::s4u::Actor::create("receiver", all_hosts[2], [&recv_done]() {
323     assert_exit(false, 3);
324     void* payload = simgrid::s4u::Mailbox::by_name("mb")->get();
325     xbt_free(payload);
326     recv_done = true;
327   });
328
329   // Sleep long enough to let the test ends by itself. 3 + surf_precision should be enough.
330   simgrid::s4u::this_actor::sleep_for(4);
331   xbt_assert(dsend_done, "Sender killed somehow. It shouldn't");
332   xbt_assert(recv_done, "Receiver killed somehow. It shouldn't");
333 }
334
335
336 static void test_comm_killsend()
337 {
338   XBT_INFO("%s: Launch a communication and kill the sender", __func__);
339   bool send_done = false;
340   bool recv_done = false;
341
342   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[1], [&send_done]() {
343     assert_exit(true, 2);
344     // Encapsulate the payload in a std::unique_ptr so that it is correctly free'd when the sender is killed during its
345     // communication (thanks to RAII).  The pointer is then released when the communication is over.
346     std::unique_ptr<char, decltype(&xbt_free_f)> payload(xbt_strdup("toto"), &xbt_free_f);
347     simgrid::s4u::Mailbox::by_name("mb")->put(payload.get(), 5000);
348     payload.release();
349     send_done = true;
350   });
351   simgrid::s4u::Actor::create("receiver", all_hosts[2], [&recv_done]() {
352     assert_exit(false, 2);
353     bool got_exception = false;
354     try {
355       void* payload = simgrid::s4u::Mailbox::by_name("mb")->get();
356       xbt_free(payload);
357     } catch (simgrid::NetworkFailureException const&) {
358       got_exception = true;
359     }
360     xbt_assert(got_exception);
361     recv_done = true;
362   });
363
364   simgrid::s4u::this_actor::sleep_for(2);
365   sender->kill();
366   // let the test ends by itself. waiting for surf_precision should be enough.
367   simgrid::s4u::this_actor::sleep_for(0.00001);
368
369   xbt_assert(not send_done, "Sender was not killed properly");
370   xbt_assert(recv_done, "Receiver killed somehow. It shouldn't");
371 }
372
373 static void test_host_off_while_receive()
374 {
375   XBT_INFO("%s: Launch an actor that waits on a recv, kill its host", __func__);
376   bool in_on_exit = false;
377   bool returned_from_main = false;
378   bool in_catch_before_on_exit = false;
379   bool in_catch_after_on_exit = false;
380   bool send_done               = false;
381
382   simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create(
383     "receiver", all_hosts[1], 
384     [&in_on_exit, &returned_from_main, &in_catch_before_on_exit, &in_catch_after_on_exit]() {
385        assert_exit(true, 1);
386        try {
387          simgrid::s4u::Mailbox::by_name("mb")->get();
388        } catch (simgrid::NetworkFailureException const&) {
389          // Shouldn't get in here
390          in_catch_before_on_exit = not in_on_exit;
391          in_catch_after_on_exit = in_on_exit;
392        }
393        returned_from_main = true;
394      });
395
396   receiver->on_exit([&in_on_exit](bool) { in_on_exit = true; });
397
398   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[2], [&send_done]() {
399     assert_exit(false, 1);
400     bool got_exception = false;
401     try {
402       int data = 42;
403       simgrid::s4u::Mailbox::by_name("mb")->put(&data, 100000);
404     } catch (simgrid::NetworkFailureException const&) {
405       got_exception = true;
406     }
407     xbt_assert(got_exception);
408     send_done = true;
409   });
410
411   simgrid::s4u::this_actor::sleep_for(1);
412   receiver->get_host()->turn_off();
413   
414   // Note: If we don't sleep here, we don't "see" the bug
415   simgrid::s4u::this_actor::sleep_for(1);
416
417   xbt_assert(in_on_exit, 
418     "Receiver's on_exit function was never called");
419   xbt_assert(not in_catch_before_on_exit, 
420     "Receiver mistakenly went to catch clause (before the on_exit function was called)");
421   xbt_assert(not in_catch_after_on_exit, 
422     "Receiver mistakenly went to catch clause (after the on_exit function was called)");
423   xbt_assert(not returned_from_main, 
424     "Receiver returned from main normally even though its host was killed");
425   xbt_assert(send_done, "Sender killed somehow. It shouldn't");
426   receiver->get_host()->turn_on();
427 }
428
429 static void test_link_off_helper(double delay)
430 {
431   const double start = simgrid::s4u::Engine::get_clock();
432
433   simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create("receiver", all_hosts[1], [&start]() {
434     assert_exit(false, 9);
435     double milestone[5] = {0.5, 3.5, 4.5, 7.5, 9.0};
436     for (int i = 0; i < 5; i++)
437       milestone[i] += start;
438     for (int i = 0; i < 4; i++) {
439       simgrid::s4u::this_actor::sleep_until(milestone[i]);
440       try {
441         XBT_VERB("get(%c)", 'A' + i);
442         simgrid::s4u::Mailbox::by_name("mb")->get();
443         return;
444       } catch (simgrid::NetworkFailureException const&) {
445         XBT_VERB("got expected NetworkFailureException");
446       }
447     }
448     simgrid::s4u::this_actor::sleep_until(milestone[4]);
449   });
450
451   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[2], [&start]() {
452     assert_exit(false, 9);
453     int data            = 42;
454     double milestone[5] = {1.5, 2.5, 5.5, 6.5, 9.0};
455     for (int i = 0; i < 5; i++)
456       milestone[i] += start;
457     for (int i = 0; i < 2; i++) {
458       simgrid::s4u::this_actor::sleep_until(milestone[i]);
459       XBT_VERB("dsend(%c)", 'A' + i);
460       simgrid::s4u::Mailbox::by_name("mb")->put_init(&data, 100000)->detach();
461     }
462     for (int i = 2; i < 4; i++) {
463       simgrid::s4u::this_actor::sleep_until(milestone[i]);
464       try {
465         XBT_VERB("put(%c)", 'A' + i);
466         simgrid::s4u::Mailbox::by_name("mb")->put(&data, 100000);
467         return;
468       } catch (simgrid::NetworkFailureException const&) {
469         XBT_VERB("got expected NetworkFailureException");
470       }
471     }
472     simgrid::s4u::this_actor::sleep_until(milestone[4]);
473   });
474
475   for (int i = 0; i < 4; i++) {
476     XBT_VERB("##### %d / 4 #####", i + 1);
477     simgrid::s4u::this_actor::sleep_for(delay);
478     XBT_VERB("link off");
479     simgrid::s4u::Link::by_name("link1")->turn_off();
480     simgrid::s4u::this_actor::sleep_for(2.0 - delay);
481     XBT_VERB("link on");
482     simgrid::s4u::Link::by_name("link1")->turn_on();
483   }
484   simgrid::s4u::this_actor::sleep_for(1.5);
485 }
486
487 static void test_link_off_before_send_recv()
488 {
489   XBT_INFO("%s: try to communicate with communicating link turned off before start", __func__);
490   test_link_off_helper(0.0);
491 }
492 static void test_link_off_between_send_recv()
493 {
494   XBT_INFO("%s: try to communicate with communicating link turned off between send and receive", __func__);
495   test_link_off_helper(1.0);
496 }
497 static void test_link_off_during_transfer()
498 {
499   XBT_INFO("%s: try to communicate with communicating link turned off during transfer", __func__);
500   test_link_off_helper(2.0);
501 }
502
503 static void test_link_off_during_wait_any()
504 {
505   simgrid::s4u::ActorPtr receiver = simgrid::s4u::Actor::create("receiver", all_hosts[1], []() {
506     assert_exit(false, 2);
507     bool receiver_got_network_failure_execution = false;
508     bool receiver_got_base_execution = false;
509     int *data;
510     std::vector<simgrid::s4u::CommPtr> pending_comms;
511     simgrid::s4u::CommPtr comm = simgrid::s4u::Mailbox::by_name("mb")->get_async((void**)&data);
512     pending_comms.push_back(comm);
513     try {
514       simgrid::s4u::Comm::wait_any(&pending_comms);
515     } catch (simgrid::NetworkFailureException const&) {
516       XBT_VERB("got expected NetworkFailureException");
517       receiver_got_network_failure_execution = true;
518     } catch (simgrid::Exception const&) {
519       XBT_VERB("got unexpected base Exception");
520       receiver_got_base_execution = true;
521     }
522     xbt_assert(receiver_got_network_failure_execution, "The receiver should have gotten a NetworkFailureException");
523     xbt_assert(not receiver_got_base_execution, "The receiver should not have gotten a base Exception");
524   });
525
526   simgrid::s4u::ActorPtr sender = simgrid::s4u::Actor::create("sender", all_hosts[2], []() {
527     assert_exit(false, 2);
528     int data = 42;
529     bool sender_got_network_failure_execution = false;
530     bool sender_got_base_execution = false;
531     try {
532       simgrid::s4u::Mailbox::by_name("mb")->put(&data, 100000);
533     } catch (simgrid::NetworkFailureException const&) {
534       XBT_VERB("got expected NetworkFailureException");
535       sender_got_network_failure_execution = true;
536     } catch (simgrid::Exception const&) {
537       XBT_VERB("got unexpected base Exception");
538       sender_got_base_execution = true;
539     }
540     xbt_assert(sender_got_network_failure_execution, "The sender should have gotten a NetworkFailureException");
541     xbt_assert(not sender_got_base_execution, "The sender should not have gotten a base Exception");
542   });
543
544   simgrid::s4u::this_actor::sleep_for(2.0);
545   XBT_VERB("link off");
546   simgrid::s4u::Link::by_name("link1")->turn_off();
547   simgrid::s4u::this_actor::sleep_for(2.0);
548   XBT_VERB("link on");
549   simgrid::s4u::Link::by_name("link1")->turn_on();
550 }
551
552
553 /* We need an extra actor here, so that it can sleep until the end of each test */
554 static void main_dispatcher()
555 {
556   run_test("sleep", test_sleep);
557   run_test("sleep killed at start", test_sleep_kill_begin);
558   run_test("sleep killed in middle", test_sleep_kill_middle);
559   /* We cannot kill right at the end of the action because killer actors are always rescheduled to the end of the round
560    * to avoid that they exit before their victim dereferences their name */
561   run_test("sleep restarted at start", test_sleep_restart_begin);
562   run_test("sleep restarted in middle", test_sleep_restart_middle);
563   run_test("sleep restarted at end", test_sleep_restart_end);
564
565   run_test("exec", test_exec);
566   run_test("exec killed at start", test_exec_kill_begin);
567   run_test("exec killed in middle", test_exec_kill_middle);
568   run_test("exec restarted at start", test_exec_restart_begin);
569   run_test("exec restarted in middle", test_exec_restart_middle);
570   run_test("exec restarted at end", test_exec_restart_end);
571
572   run_test("turn off its own host", test_turn_off_itself);
573
574   run_test("comm", test_comm);
575   run_test("comm dsend and quit (put before get)", test_comm_dsend_and_quit_put_before_get);
576   run_test("comm dsend and quit (get before put)", test_comm_dsend_and_quit_get_before_put);
577   run_test("comm kill sender", test_comm_killsend);
578
579   run_test("comm recv and kill", test_host_off_while_receive);
580   run_test("comm turn link off before send/recv", test_link_off_before_send_recv);
581   run_test("comm turn link off between send/recv", test_link_off_between_send_recv);
582   run_test("comm turn link off during transfer", test_link_off_during_transfer);
583   run_test("comm turn link off during wait_any", test_link_off_during_wait_any);
584 }
585
586 int main(int argc, char* argv[])
587 {
588   simgrid::s4u::Engine e(&argc, argv);
589
590   const char* platf = argv[1];
591   if (argc <= 1) {
592     XBT_WARN("No platform file provided. Using './testing_platform.xml'");
593     platf = "./testing_platform.xml";
594   }
595   e.load_platform(platf);
596
597   all_hosts = e.get_all_hosts();
598   simgrid::s4u::Actor::create("main_dispatcher", all_hosts[0], main_dispatcher);
599
600   e.run();
601
602   XBT_INFO("Simulation done");
603
604   return 0;
605 }