Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a --verbose option for testall.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 19 Apr 2012 09:08:53 +0000 (11:08 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Fri, 20 Apr 2012 07:25:19 +0000 (09:25 +0200)
include/xbt/cunit.h
src/xbt/cunit.c
tools/sg_unit_extractor.pl

index 9ed28ae..0cd6358 100644 (file)
@@ -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.
  */
 
  * * 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 */
 /* Show information about the selection of tests */
 XBT_PUBLIC(void) xbt_test_dump(char *selection);
 /* Cleanup the mess */
index 4436ae5..a3798ee 100644 (file)
@@ -245,7 +245,7 @@ void xbt_test_suite_push(xbt_test_suite_t suite, const char *name,
 }
 
 /* run test one suite */
 }
 
 /* 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;
 {
   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 */
 
 
       /* 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");
         /* 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);
 
 {
   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)
 
     /* 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: ",
 
     /* Display some more statistics */
     fprintf(stderr, "\n\n TOTAL: Suites: %.0f%% ok (%d suites: ",
index 031329a..66ef7d7 100755 (executable)
@@ -130,8 +130,10 @@ sub process_one($) {
 int main(int argc, char *argv[]) {
   xbt_test_suite_t suite; 
   char selection[1024];
 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 */
       
   /* SGU: BEGIN SUITES DECLARATION */
   /* SGU: END SUITES DECLARATION */
       
@@ -148,6 +150,8 @@ int main(int argc, char *argv[]) {
           strcat(selection, \",\");
           strcat(selection, p);
         }
           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);
       } 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"
          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"
              "--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 */
       
     }
   /* Got all my tests to do */
       
-  res = xbt_test_run(selection);
+  res = xbt_test_run(selection, verbosity);
   xbt_test_exit();
   return res;
 }
   xbt_test_exit();
   return res;
 }