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:
+1
-1
@@ -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' ,
|
||||
|
||||
+25
-2
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user