diff --git a/test/SConscript b/test/SConscript index fe318d9..074db11 100644 --- a/test/SConscript +++ b/test/SConscript @@ -21,7 +21,7 @@ tests = test_env.Glob('test_*.c') test_executable = 'test_runner' #run test_runner --xml to produce an xml result file if test_xml: - test_executable += ' --xml' + test_executable += ' -x' prog = test_env.Program('test_runner', tests) cmd = test_env.Command(target='test_phony' , diff --git a/test/test_runner.c b/test/test_runner.c index c485f6f..a797d5f 100644 --- a/test/test_runner.c +++ b/test/test_runner.c @@ -2,6 +2,7 @@ #include #include #include +#include typedef Suite *(*suite_func)(void); @@ -53,7 +54,24 @@ static suite_func suites[] = { int main (int argc, char *argv[]) { - int xml_output = argc > 1 && strcmp(argv[1], "--xml") == 0; + int xml_output = 0; + int c; + const char *test_case = NULL; + + while ((c = getopt(argc, argv, "xk:")) != -1) { + switch (c) { + case 'x': + xml_output = 1; + break; + case 'k': + test_case = optarg; + break; + default: + printf("Ignoring unknown option %c\n", c); + break; + } + } + int number_failed = 0; size_t i; @@ -69,7 +87,12 @@ main (int argc, char *argv[]) srunner_add_suite(sr, suites[i]()); } - srunner_run_all (sr, CK_VERBOSE); + if (test_case == NULL) { + srunner_run_all (sr, CK_VERBOSE); + } else { + printf("Running %s only\n", test_case); + srunner_run(sr, NULL, test_case, CK_VERBOSE); + } number_failed = srunner_ntests_failed (sr); srunner_free (sr);