Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Now, any surf-based program can take --surf-path arguments to help locating platform...
[simgrid.git] / testsuite / msg / msg_test.c
index e377e44..61d57fe 100644 (file)
@@ -17,7 +17,8 @@
 
 int unix_emitter(int argc, char *argv[]);
 int unix_receiver(int argc, char *argv[]);
-void test_all(const char *platform_file, const char *application_file, double sharing);
+int unix_forwarder(int argc, char *argv[]);
+void test_all(const char *platform_file, const char *application_file);
 
 
 /** The names of the channels we will use in this simulation. There is
@@ -48,7 +49,7 @@ int unix_emitter(int argc, char *argv[])
   m_task_t *todo = NULL;
 
   int i;
-  PRINT_MESSAGE("Hello !");
+
   print_args(argc,argv);
 
   {                  /* Process organisation */
@@ -106,7 +107,6 @@ int unix_receiver(int argc, char *argv[])
   m_task_t *todo = (m_task_t *) calloc(NB_TASK, sizeof(m_task_t));
   int i;
 
-  PRINT_MESSAGE("Hello !");
   print_args(argc,argv);
 
   for (i = 0; i < NB_TASK;) {
@@ -132,17 +132,41 @@ int unix_receiver(int argc, char *argv[])
 }
 
 
-void test_all(const char *platform_file,const char *application_file, double sharing)
+int unix_forwarder(int argc, char *argv[])
 {
-  {                            /*  Simulation setting */
-    MSG_global_init();
-    MSG_set_verbosity(MSG_SILENT);
-    MSG_set_channel_number(MAX_CHANNEL);
-    if(sharing<=0) {
-      MSG_set_sharing_policy(MSG_TCP,.1);
+  int todo_count = 0;
+  m_task_t *todo = (m_task_t *) calloc(NB_TASK, sizeof(m_task_t));
+  int i;
+
+  print_args(argc,argv);
+
+  for (i = 0; i < NB_TASK;) {
+    int a;
+    PRINT_MESSAGE("Awaiting Task %d \n", i);
+    a = MSG_task_get(&(todo[i]), PORT_22);
+    if (a == MSG_OK) {
+      todo_count++;
+      PRINT_MESSAGE("Received \"%s\" \n", todo[i]->name);
+      PRINT_MESSAGE("Processing \"%s\" \n", todo[i]->name);
+      MSG_task_execute(todo[i]);
+      PRINT_MESSAGE("\"%s\" done \n", todo[i]->name);
+      MSG_task_destroy(todo[i]);
+      i++;
     } else {
-      MSG_set_sharing_policy(MSG_STORE_AND_FORWARD,sharing);
+      PRINT_MESSAGE("Hey ?! What's up ? \n");
+      DIE("Unexpected behaviour");
     }
+  }
+  free(todo);
+  PRINT_MESSAGE("I'm done. See you!\n");
+  return 0;
+}
+
+
+void test_all(const char *platform_file,const char *application_file)
+{
+  {                            /*  Simulation setting */
+    MSG_set_channel_number(MAX_CHANNEL);
     MSG_create_environment(platform_file);
   }
   {                            /*   Application deployment */
@@ -152,12 +176,12 @@ void test_all(const char *platform_file,const char *application_file, double sha
   }
   MSG_main();
   printf("Simulation time %Lg\n",MSG_getClock());
-/*   MSG_clean(); */
 }
 
 int main(int argc, char *argv[])
 {
-  test_all("msg_platform.txt","msg_deployment.txt",-.1);
-/*   test_all("msg_platform.txt","msg_deployment.txt",.1); */
+  MSG_global_init_args(&argc,argv);
+  test_all("msg_platform.xml","msg_deployment.xml");
+  MSG_clean();
   return (0);
 }