From 49956f65bb53ea2a2c1b394e5e59ffdfcdcc490f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= Date: Wed, 25 Apr 2018 11:55:03 -0500 Subject: [PATCH 6/7] main.c: Add option (-e) to exclude certain tests for execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit You can specify a set of ptests to be excluded, it will not fail if some ptest excluded isn't found in the list of execution. $ ./ptest-runner -e "hang glibc" -d tests/data Signed-off-by: Aníbal Limón --- main.c | 38 +++++++++++++++++++++++++++++++++++--- utils.h | 1 + 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 593aff1a1956..83600b7d1b31 100644 --- a/main.c +++ b/main.c @@ -19,6 +19,7 @@ * Aníbal Limón */ +#include #include #include #include @@ -42,8 +43,8 @@ static inline void print_usage(FILE *stream, char *progname) { - fprintf(stream, "Usage: %s [-d directory] [-l list] [-t timeout] [-x xml-filename]" - " [-h] [ptest1 ptest2 ...]\n", progname); + fprintf(stream, "Usage: %s [-d directory] [-e exclude] [-l list] [-t timeout]" + " [-x xml-filename] [-h] [ptest1 ptest2 ...]\n", progname); } int @@ -53,6 +54,8 @@ main(int argc, char *argv[]) int ptest_num = 0; int i; int rc; + int ptest_exclude_num = 0; + char *c, *tok; #ifdef MEMCHECK mtrace(); @@ -62,18 +65,44 @@ main(int argc, char *argv[]) struct ptest_options opts; opts.directory = strdup(DEFAULT_DIRECTORY); + opts.exclude = NULL; opts.list = 0; opts.timeout = DEFAULT_TIMEOUT; opts.ptests = NULL; opts.xml_filename = NULL; - while ((opt = getopt(argc, argv, "d:lt:x:h")) != -1) { + while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) { switch (opt) { case 'd': free(opts.directory); opts.directory = realpath(optarg, NULL); CHECK_ALLOCATION(opts.directory, 1, 1); break; + case 'e': + c = optarg; + ptest_exclude_num = 1; + + while (*c) { + if (isspace(*c)) + ptest_exclude_num++; + c++; + } + + + opts.exclude = malloc(ptest_exclude_num * sizeof(char)); + CHECK_ALLOCATION(opts.exclude, 1, 1); + + i = 0; + tok = strtok_r(optarg, " ", &c); + opts.exclude[i] = strdup(tok); + CHECK_ALLOCATION(opts.exclude[i], 1, 1); + i++; + while ((tok = strtok_r(NULL, " ", &c)) != NULL) { + opts.exclude[i] = strdup(tok); + CHECK_ALLOCATION(opts.exclude[i], 1, 1); + i++; + } + break; case 'l': opts.list = 1; break; @@ -134,6 +163,9 @@ main(int argc, char *argv[]) ptest_list_free_all(head); } + for (i = 0; i < ptest_exclude_num; i++) + ptest_list_remove(run, opts.exclude[i], 1); + rc = run_ptests(run, opts, argv[0], stdout, stderr); ptest_list_free_all(run); diff --git a/utils.h b/utils.h index 8fa20a8bf621..ee85163ddfff 100644 --- a/utils.h +++ b/utils.h @@ -32,6 +32,7 @@ struct ptest_options { char *directory; + char **exclude; int list; int timeout; char **ptests; -- 2.11.0