A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Value stored to 'linelen' here is never read.
[simgrid.git]
/
tools
/
tesh
/
tesh.c
diff --git
a/tools/tesh/tesh.c
b/tools/tesh/tesh.c
index
7d5659e
..
7f75229
100644
(file)
--- a/
tools/tesh/tesh.c
+++ b/
tools/tesh/tesh.c
@@
-1,6
+1,6
@@
/* TESH (Test Shell) -- mini shell specialized in running test units */
/* TESH (Test Shell) -- mini shell specialized in running test units */
-/* Copyright (c) 2007
, 2008, 2009, 2010
. The SimGrid Team.
+/* Copyright (c) 2007
-2013
. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-19,8
+19,14
@@
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 */
/*** Options ***/
int timeout_value = 5; /* child timeout value */
int sort_len = 19; /* length of the prefix to sort */
+char *option;
+int coverage = 0; /* whether the code coverage is enable */
+rctx_t rctx;
const char *testsuite_name;
const char *testsuite_name;
+
+xbt_dict_t env;
+
static void handle_line(const char *filepos, char *line)
{
/* Search end */
static void handle_line(const char *filepos, char *line)
{
/* Search end */
@@
-98,7
+104,7
@@
static void handle_suite(const char *filename, FILE * IN)
buff = xbt_strbuff_new();
rctx = rctx_new();
buff = xbt_strbuff_new();
rctx = rctx_new();
- while (getline(&line, &len, IN) != -1) {
+ while (
xbt_
getline(&line, &len, IN) != -1) {
line_num++;
/* Count the line length while checking wheather it's blank */
line_num++;
/* Count the line length while checking wheather it's blank */
@@
-135,7
+141,6
@@
static void handle_suite(const char *filename, FILE * IN)
} else {
to_be_continued = 1;
line[linelen - 2] = '\0';
} else {
to_be_continued = 1;
line[linelen - 2] = '\0';
- linelen -= 2;
if (!buff->used)
buffbegin = line_num;
}
if (!buff->used)
buffbegin = line_num;
}
@@
-164,8
+169,7
@@
static void handle_suite(const char *filename, FILE * IN)
rctx_free(rctx);
/* Clear buffers */
rctx_free(rctx);
/* Clear buffers */
- if (line)
- free(line);
+ free(line);
xbt_strbuff_free(buff);
}
xbt_strbuff_free(buff);
}
@@
-176,12
+180,12
@@
static void parse_environ()
int i;
char *eq = NULL;
char *key = NULL;
int i;
char *eq = NULL;
char *key = NULL;
- env = xbt_dict_new
(
);
+ env = xbt_dict_new
_homogeneous(xbt_free_f
);
for (i = 0; environ[i]; i++) {
p = environ[i];
eq = strchr(p, '=');
key = bprintf("%.*s", (int) (eq - p), p);
for (i = 0; environ[i]; i++) {
p = environ[i];
eq = strchr(p, '=');
key = bprintf("%.*s", (int) (eq - p), p);
- xbt_dict_set(env, key, xbt_strdup(eq + 1),
xbt_free_f
);
+ xbt_dict_set(env, key, xbt_strdup(eq + 1),
NULL
);
free(key);
}
}
free(key);
}
}
@@
-192,6
+196,8
@@
int main(int argc, char *argv[])
int i;
char *suitename = NULL;
struct sigaction newact;
int i;
char *suitename = NULL;
struct sigaction newact;
+
+ XBT_LOG_CONNECT(tesh);
xbt_init(&argc, argv);
rctx_init();
parse_environ();
xbt_init(&argc, argv);
rctx_init();
parse_environ();
@@
-225,9
+231,9
@@
int main(int argc, char *argv[])
exit(1);
}
char *eq = strchr(argv[i+1], '=');
exit(1);
}
char *eq = strchr(argv[i+1], '=');
- xbt_assert
1
(eq,"The argument of --setenv must contain a '=' (got %s instead)",argv[i+1]);
+ xbt_assert(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]);
char *key = bprintf("%.*s", (int) (eq - argv[i+1]), argv[i+1]);
- xbt_dict_set(env, key, xbt_strdup(eq + 1),
xbt_free_f
);
+ xbt_dict_set(env, key, xbt_strdup(eq + 1),
NULL
);
XBT_INFO("setting environment variable '%s' to '%s'", key, eq+1);
free(key);
memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
XBT_INFO("setting environment variable '%s' to '%s'", key, eq+1);
free(key);
memmove(argv + i, argv + i + 2, (argc - i - 1) * sizeof(char *));
@@
-238,16
+244,25
@@
int main(int argc, char *argv[])
XBT_ERROR("--cfg argument requires an argument");
exit(1);
}
XBT_ERROR("--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]);
+ if (!option){ //if option is NULL
+ option = bprintf("--cfg=%s",argv[i+1]);
+ } else {
+ char *newoption = bprintf("%s --cfg=%s", option, argv[i+1]);
+ free(option);
+ option = newoption;
}
XBT_INFO("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;
}
}
XBT_INFO("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;
}
+ else if (!strcmp(argv[i], "--enable-coverage" )){
+ coverage = 1;
+ XBT_INFO("Enable coverage");
+ memmove(argv + i, argv + i + 1, (argc - i - 1) * sizeof(char *));
+ argc -= 1;
+ i -= 1;
+ }
}
/* Find the description file */
}
/* Find the description file */
@@
-286,6
+301,6
@@
int main(int argc, char *argv[])
rctx_exit();
xbt_dict_free(&env);
rctx_exit();
xbt_dict_free(&env);
-
xbt_free_f
(option);
+
free
(option);
return 0;
}
return 0;
}