From: mquinson Date: Mon, 29 Nov 2010 17:54:28 +0000 (+0000) Subject: Add --setenv command line options to tesh X-Git-Tag: v3_5~103 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3aaab223e4a313f3e8fcaed48b1875592e7c4f41 Add --setenv command line options to tesh git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8728 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/ChangeLog b/ChangeLog index bfb285b8c4..279533f433 100644 --- 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 + * Add --cd and --setenv command line options to tesh Tracing: * Tracing system diff --git a/tools/tesh/README.tesh b/tools/tesh/README.tesh index 95a2374fba..113e780189 100644 --- a/tools/tesh/README.tesh +++ b/tools/tesh/README.tesh @@ -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). +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 --------- diff --git a/tools/tesh/tesh.c b/tools/tesh/tesh.c index 1e2034cd73..0cf2c063c0 100644 --- a/tools/tesh/tesh.c +++ b/tools/tesh/tesh.c @@ -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; + } 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; } }