From 1fdad19bc731f6e45fc220547c3f94496bca565a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 19 Apr 2012 11:08:53 +0200 Subject: [PATCH] Add a --verbose option for testall. --- include/xbt/cunit.h | 2 +- src/xbt/cunit.c | 9 +++++---- tools/sg_unit_extractor.pl | 11 ++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/xbt/cunit.h b/include/xbt/cunit.h index 9ed28ae71f..0cd635880c 100644 --- a/include/xbt/cunit.h +++ b/include/xbt/cunit.h @@ -51,7 +51,7 @@ XBT_PUBLIC(void) xbt_test_suite_push(xbt_test_suite_t suite, * * testname: if given, the test on which the directive acts. If not, acts on any tests. */ -XBT_PUBLIC(int) xbt_test_run(char *selection); +XBT_PUBLIC(int) xbt_test_run(char *selection, int verbosity); /* Show information about the selection of tests */ XBT_PUBLIC(void) xbt_test_dump(char *selection); /* Cleanup the mess */ diff --git a/src/xbt/cunit.c b/src/xbt/cunit.c index 4436ae5649..a3798ee350 100644 --- a/src/xbt/cunit.c +++ b/src/xbt/cunit.c @@ -245,7 +245,7 @@ void xbt_test_suite_push(xbt_test_suite_t suite, const char *name, } /* run test one suite */ -static int xbt_test_suite_run(xbt_test_suite_t suite) +static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity) { xbt_test_unit_t unit; xbt_test_test_t test; @@ -324,7 +324,8 @@ static int xbt_test_suite_run(xbt_test_suite_t suite) /* Display whether this unit went well */ - if (unit->test_failed > 0 || unit->test_expect) { + if (unit->test_failed > 0 || unit->test_expect || + (verbosity && unit->nb_tests > 0)) { /* some tests failed (or were supposed to), so do detailed reporting of test case */ if (unit->test_failed > 0) { fprintf(stderr, ".. failed\n"); @@ -612,7 +613,7 @@ void xbt_test_dump(char *selection) } } -int xbt_test_run(char *selection) +int xbt_test_run(char *selection, int verbosity) { apply_selection(selection); @@ -623,7 +624,7 @@ int xbt_test_run(char *selection) /* Run all the suites */ xbt_dynar_foreach(_xbt_test_suites, it_suite, suite) - xbt_test_suite_run(suite); + xbt_test_suite_run(suite, verbosity); /* Display some more statistics */ fprintf(stderr, "\n\n TOTAL: Suites: %.0f%% ok (%d suites: ", diff --git a/tools/sg_unit_extractor.pl b/tools/sg_unit_extractor.pl index 031329acaa..66ef7d7dcd 100755 --- a/tools/sg_unit_extractor.pl +++ b/tools/sg_unit_extractor.pl @@ -130,8 +130,10 @@ sub process_one($) { int main(int argc, char *argv[]) { xbt_test_suite_t suite; char selection[1024]; - int i;\n - int res;\n + int verbosity = 0; + int i; + int res; + /* SGU: BEGIN SUITES DECLARATION */ /* SGU: END SUITES DECLARATION */ @@ -148,6 +150,8 @@ int main(int argc, char *argv[]) { strcat(selection, \",\"); strcat(selection, p); } + } else if (!strcmp(argv[i], \"--verbose\")) { + verbosity++; } else if (!strcmp(argv[i], \"--dump-only\")|| !strcmp(argv[i], \"--dump\")) { xbt_test_dump(selection); @@ -156,6 +160,7 @@ int main(int argc, char *argv[]) { printf( "Usage: testall [--help] [--tests=selection] [--dump-only]\\n\\n" "--help: display this help\\n" + "--verbose: print the name for each running test\\n" "--dump-only: don't run the tests, but display some debuging info about the tests\\n" "--tests=selection: Use argument to select which suites/units/tests to run\\n" " --tests can be used more than once, and selection may be a comma\\n" @@ -180,7 +185,7 @@ int main(int argc, char *argv[]) { } /* Got all my tests to do */ - res = xbt_test_run(selection); + res = xbt_test_run(selection, verbosity); xbt_test_exit(); return res; } -- 2.20.1