Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
adapt MSG test to test for #248
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 29 Nov 2017 15:25:38 +0000 (16:25 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 29 Nov 2017 15:49:04 +0000 (16:49 +0100)
examples/msg/process-kill/process-kill.c
examples/msg/process-kill/process-kill.tesh

index fe02ef8..657c5cc 100644 (file)
@@ -7,7 +7,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_kill, "Messages specific for this msg example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_process_kill, "Messages specific for this msg example");
 
-static int victim(int argc, char *argv[])
+static int victimA_fun(int argc, char* argv[])
 {
   XBT_INFO("Hello!");
   XBT_INFO("Suspending myself");
 {
   XBT_INFO("Hello!");
   XBT_INFO("Suspending myself");
@@ -18,17 +18,27 @@ static int victim(int argc, char *argv[])
   return 0;
 }
 
   return 0;
 }
 
+static int victimB_fun(int argc, char* argv[])
+{
+  XBT_INFO("Terminates before being killed");
+  return 0;
+}
+
 static int killer(int argc, char *argv[])
 {
   XBT_INFO("Hello!");         /* - First start a victim process */
 static int killer(int argc, char *argv[])
 {
   XBT_INFO("Hello!");         /* - First start a victim process */
-  msg_process_t poor_victim = MSG_process_create("victim", victim, NULL, MSG_host_by_name("Fafard"));
+  msg_process_t victimA = MSG_process_create("victim A", victimA_fun, NULL, MSG_host_by_name("Fafard"));
+  msg_process_t victimB = MSG_process_create("victim B", victimB_fun, NULL, MSG_host_by_name("Bourassa"));
   MSG_process_sleep(10.0);
 
   MSG_process_sleep(10.0);
 
-  XBT_INFO("Resume process"); /* - Resume it from its suspended state */
-  MSG_process_resume(poor_victim);
+  XBT_INFO("Resume victimA"); /* - Resume it from its suspended state */
+  MSG_process_resume(victimA);
+
+  XBT_INFO("Kill victimA"); /* - and then kill it */
+  MSG_process_kill(victimA);
 
 
-  XBT_INFO("Kill process");   /* - and then kill it */
-  MSG_process_kill(poor_victim);
+  XBT_INFO("Kill victimB, even if it's already dead"); /* that's a no-op, there is no zombies in SimGrid */
+  MSG_process_kill(victimB);
 
   XBT_INFO("OK, goodbye now. I commit a suicide.");
   MSG_process_kill(MSG_process_self());
 
   XBT_INFO("OK, goodbye now. I commit a suicide.");
   MSG_process_kill(MSG_process_self());
index abe9ae6..c0aa6d8 100644 (file)
@@ -4,9 +4,11 @@ p Testing a MSG_process_kill function
 
 $ $SG_TEST_EXENV ${bindir:=.}/process-kill ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:killer@Tremblay) Hello!
 
 $ $SG_TEST_EXENV ${bindir:=.}/process-kill ${srcdir:=.}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
 > [  0.000000] (1:killer@Tremblay) Hello!
-> [  0.000000] (2:victim@Fafard) Hello!
-> [  0.000000] (2:victim@Fafard) Suspending myself
-> [ 10.000000] (1:killer@Tremblay) Resume process
-> [ 10.000000] (1:killer@Tremblay) Kill process
+> [  0.000000] (2:victim A@Fafard) Hello!
+> [  0.000000] (2:victim A@Fafard) Suspending myself
+> [  0.000000] (3:victim B@Bourassa) Terminates before being killed
+> [ 10.000000] (1:killer@Tremblay) Resume victimA
+> [ 10.000000] (1:killer@Tremblay) Kill victimA
+> [ 10.000000] (1:killer@Tremblay) Kill victimB, even if it's already dead
 > [ 10.000000] (1:killer@Tremblay) OK, goodbye now. I commit a suicide.
 > [ 10.000000] (0:maestro@) Simulation time 10
 > [ 10.000000] (1:killer@Tremblay) OK, goodbye now. I commit a suicide.
 > [ 10.000000] (0:maestro@) Simulation time 10