Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
We need cmake 2.8 to compile simgrid
[simgrid.git] / tools / tesh / tesh.c
index 628f856..0a6bbf3 100644 (file)
@@ -20,8 +20,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(tesh, "TEst SHell utility");
 
 /*** Options ***/
 int timeout_value = 5;          /* child timeout value */
+int sort_len = 19;              /* length of the prefix to sort */
 
-char *testsuite_name;
+const char *testsuite_name;
 static void handle_line(const char *filepos, char *line)
 {
   /* Search end */
@@ -193,7 +194,6 @@ int main(int argc, char *argv[])
   int i;
   char *suitename = NULL;
   struct sigaction newact;
-
   xbt_init(&argc, argv);
   rctx_init();
   parse_environ();
@@ -235,14 +235,29 @@ int main(int argc, char *argv[])
       memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
       argc -= 2;
       i -= 2;
+    } else if (!strcmp(argv[i], "--cfg" )) {
+      if (i == argc - 1) {
+            ERROR0("--cfg argument requires an argument");
+            exit(1);
+      }
+      if(!option){ //if option is NULL
+       option = bprintf("--cfg=%s",argv[i+1]);
+      }else{
+       option = bprintf("%s --cfg=%s",option,argv[i+1]);
+      }
+      INFO1("Add option \'--cfg=%s\' to command line",argv[i+1]);
+      memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
+      argc -= 2;
+      i -= 2;
     }
   }
 
   /* Find the description file */
   if (argc == 1) {
     INFO0("Test suite from stdin");
-    testsuite_name = xbt_strdup("(stdin)");
-    handle_suite("stdin", stdin);
+    testsuite_name = "(stdin)";
+    handle_suite(testsuite_name, stdin);
+    rctx_wait_bg();
     INFO0("Test suite from stdin OK");
 
   } else {
@@ -273,5 +288,6 @@ int main(int argc, char *argv[])
 
   rctx_exit();
   xbt_dict_free(&env);
+  xbt_free_f(option);
   return 0;
 }