/*** 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 */
FILE *FICIN = NULL;
int i;
char *suitename = NULL;
+ struct sigaction newact;
+ xbt_init(&argc, argv);
+ rctx_init();
+ parse_environ();
/* Ignore pipe issues.
They will show up when we try to send data to dead buddies,
but we will stop doing so when we're done with provided input */
- struct sigaction newact;
memset(&newact, 0, sizeof(newact));
newact.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &newact, NULL);
- xbt_init(&argc, argv);
- rctx_init();
- parse_environ();
-
/* Get args */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--cd")) {
exit(1);
}
INFO1("Change directory to %s", argv[i + 1]);
- memmove(argv + i, argv + i + 2, (argc - i - 1)*sizeof(char*));
+ 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);
+ INFO2("setting environment variable '%s' to '%s'", key, eq+1);
+ free(key);
+ 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 {
}
rctx_exit();
+ xbt_dict_free(&env);
+ xbt_free_f(option);
return 0;
}