Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add --setenv command line options to tesh
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 29 Nov 2010 17:54:28 +0000 (17:54 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Mon, 29 Nov 2010 17:54:28 +0000 (17:54 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8728 48e7efb5-ca39-0410-a469-dd3cf9ba447f

ChangeLog
tools/tesh/README.tesh
tools/tesh/tesh.c

index bfb285b..279533f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -103,6 +103,7 @@ SimGrid (3.5) unstable; urgency=low
  * Introduce a 'make dist' target compiling a *source* archive
    'make package' compiles a binary archive (not well tested)
  * Compile java files only on need
  * Introduce a 'make dist' target compiling a *source* archive
    'make package' compiles a binary archive (not well tested)
  * Compile java files only on need
+ * Add --cd and --setenv command line options to tesh
 
  Tracing:
  * Tracing system
 
  Tracing:
  * Tracing system
index 95a2374..113e780 100644 (file)
@@ -25,6 +25,13 @@ blank and is ignored):
 If the expected output do not match what the command spits, TESH will produce
 an error showing the diff (see OUTPUT below).
 
 If the expected output do not match what the command spits, TESH will produce
 an error showing the diff (see OUTPUT below).
 
+Command line arguments
+----------------------
+Tesh accepts several command line arguments:
+  --cd some/directory: ask tesh to switch the working directory before
+                       lauching the tests
+  --setenv var=value: set a specific environment variable                     
+
 IO orders
 ---------
 
 IO orders
 ---------
 
index 1e2034c..0cf2c06 100644 (file)
@@ -221,6 +221,20 @@ int main(int argc, char *argv[])
       memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
       argc -= 2;
       i -= 2;
       memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
       argc -= 2;
       i -= 2;
+    } else if (!strcmp(argv[i], "--setenv" )) {
+      if (i == argc - 1) {
+        ERROR0("--setenv argument requires an argument");
+        exit(1);
+      }
+      char *eq = strchr(argv[i+1], '=');
+      xbt_assert1(eq,"The argument of --setenv must contain a '=' (got %s instead)",argv[i+1]);
+      char *key = bprintf("%.*s", (int) (eq - argv[i+1]), argv[i+1]);
+      xbt_dict_set(env, key, xbt_strdup(eq + 1), xbt_free_f);
+      free(key);
+      VERB1("setenv %s", argv[i+1]);
+      memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
+      argc -= 2;
+      i -= 2;
     }
   }
 
     }
   }