Add -k argument to test_runner to specify running only one test suite

alter --xml of test_runner to just -x
This commit is contained in:
Nils O. Selåsdal
2013-11-26 18:17:07 +01:00
parent 59f6d99419
commit e7d7f4b862
2 changed files with 26 additions and 3 deletions
+25 -2
View File
@@ -2,6 +2,7 @@
#include <getopt.h>
#include <stdio.h>
#include <check.h>
#include <getopt.h>
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);