about summary refs log tree commit diff
path: root/support
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-12-31 11:01:40 +0100
committerFlorian Weimer <fweimer@redhat.com>2016-12-31 18:51:15 +0100
commitf47ae5186624e5bb3a2d2b25be742b90a1eee3cd (patch)
treeb479133044166a9bd6dfd0f225376218c1c22222 /support
parent039c5a05cc905e3d48392e7ea9f85e339b7c068b (diff)
downloadglibc-f47ae5186624e5bb3a2d2b25be742b90a1eee3cd.tar.gz
glibc-f47ae5186624e5bb3a2d2b25be742b90a1eee3cd.tar.xz
glibc-f47ae5186624e5bb3a2d2b25be742b90a1eee3cd.zip
support: Implement --verbose option for test programs
Some tests can produce rather verbose tracing information,
and the --verbose option provides a standardized way to enable
such logging output.
Diffstat (limited to 'support')
-rw-r--r--support/support_test_main.c11
-rw-r--r--support/test-driver.c4
-rw-r--r--support/test-driver.h6
-rw-r--r--support/tst-support_record_failure-2.sh7
-rw-r--r--support/tst-support_record_failure.c2
5 files changed, 22 insertions, 8 deletions
diff --git a/support/support_test_main.c b/support/support_test_main.c
index 8d31e2f138..1c90986506 100644
--- a/support/support_test_main.c
+++ b/support/support_test_main.c
@@ -37,8 +37,7 @@
 
 static const struct option default_options[] =
 {
-  { "direct", no_argument, NULL, OPT_DIRECT },
-  { "test-dir", required_argument, NULL, OPT_TESTDIR },
+  TEST_DEFAULT_OPTIONS
   { NULL, 0, NULL, 0 }
 };
 
@@ -67,6 +66,9 @@ usage (const struct option *options)
       printf ("%*s", 25 - indent, "");
       switch (options[i].val)
         {
+        case 'v':
+          printf ("Increase the output verbosity");
+          break;
         case OPT_DIRECT:
           printf ("Run the test directly (instead of forking & monitoring)");
           break;
@@ -164,7 +166,7 @@ run_test_function (int argc, char **argv, const struct test_config *config)
 static bool test_main_called;
 
 const char *test_dir = NULL;
-
+unsigned int test_verbose = 0;
 
 /* If test failure reporting has been linked in, it may contribute
    additional test failures.  */
@@ -215,6 +217,9 @@ support_test_main (int argc, char **argv, const struct test_config *config)
       case '?':
         usage (options);
         exit (1);
+      case 'v':
+        ++test_verbose;
+        break;
       case OPT_DIRECT:
         direct = 1;
         break;
diff --git a/support/test-driver.c b/support/test-driver.c
index 3a61b7bf3f..a847c9647a 100644
--- a/support/test-driver.c
+++ b/support/test-driver.c
@@ -144,9 +144,7 @@ main (int argc, char **argv)
   struct option options[] =
     {
       CMDLINE_OPTIONS
-      { "direct", no_argument, NULL, OPT_DIRECT },
-      { "test-dir", required_argument, NULL, OPT_TESTDIR },
-      { NULL, 0, NULL, 0 }
+      TEST_DEFAULT_OPTIONS
     };
   test_config.options = &options;
 #endif
diff --git a/support/test-driver.h b/support/test-driver.h
index 7787e9c4ff..f3f5c176dc 100644
--- a/support/test-driver.h
+++ b/support/test-driver.h
@@ -55,12 +55,18 @@ enum
 
 /* Options provided by the test driver.  */
 #define TEST_DEFAULT_OPTIONS                            \
+  { "verbose", no_argument, NULL, 'v' },                \
   { "direct", no_argument, NULL, OPT_DIRECT },          \
   { "test-dir", required_argument, NULL, OPT_TESTDIR }, \
 
 /* The directory the test should use for temporary files.  */
 extern const char *test_dir;
 
+/* The number of --verbose arguments specified during program
+   invocation.  This variable can be used to control the verbosity of
+   tests.  */
+extern unsigned int test_verbose;
+
 int support_test_main (int argc, char **argv, const struct test_config *);
 
 __END_DECLS
diff --git a/support/tst-support_record_failure-2.sh b/support/tst-support_record_failure-2.sh
index a96a60d310..6fffd8a9d5 100644
--- a/support/tst-support_record_failure-2.sh
+++ b/support/tst-support_record_failure-2.sh
@@ -54,13 +54,16 @@ different_status () {
     run_test 1 "error: 1 test failures" $direct --status=77
     run_test 2 "error: tst-support_record_failure.c:108: not true: false
 error: 1 test failures" $direct --test-verify
+    run_test 2 "error: tst-support_record_failure.c:108: not true: false
+info: execution passed failed TEST_VERIFY
+error: 1 test failures" $direct --test-verify --verbose
 }
 
 different_status
 different_status --direct
 
-run_test 1 "error: tst-support_record_failure.c:113: not true: false
+run_test 1 "error: tst-support_record_failure.c:115: not true: false
 error: 1 test failures" --test-verify-exit
 # --direct does not print the summary error message if exit is called.
-run_test 1 "error: tst-support_record_failure.c:113: not true: false" \
+run_test 1 "error: tst-support_record_failure.c:115: not true: false" \
 	 --direct --test-verify-exit
diff --git a/support/tst-support_record_failure.c b/support/tst-support_record_failure.c
index a999f7075c..75dd10f1c5 100644
--- a/support/tst-support_record_failure.c
+++ b/support/tst-support_record_failure.c
@@ -106,6 +106,8 @@ do_test (void)
   if (test_verify)
     {
       TEST_VERIFY (false);
+      if (test_verbose)
+        printf ("info: execution passed failed TEST_VERIFY\n");
       return 2; /* Expected exit status.  */
     }
   if (test_verify_exit)