]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Allow verbosity level for test programs to be set via environment variables.
authorAndres Mejia <amejia004@gmail.com>
Fri, 16 Mar 2012 20:02:26 +0000 (16:02 -0400)
committerAndres Mejia <amejia004@gmail.com>
Fri, 16 Mar 2012 20:02:26 +0000 (16:02 -0400)
cpio/test/main.c
libarchive/test/main.c
tar/test/main.c

index 77bdabe6c692b688c96ce515f456479fdbb47118..da4c015e6e2f5cc10d0640ba7dcf9cc4490b65f4 100644 (file)
@@ -2387,7 +2387,7 @@ main(int argc, char **argv)
        const char *progname;
        char **saved_argv;
        const char *tmp, *option_arg, *p;
-       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
+       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
        char tmpdir_timestamp[256];
 
        (void)argc; /* UNUSED */
@@ -2473,6 +2473,19 @@ main(int argc, char **argv)
        if (getenv(ENVBASE "_DEBUG") != NULL)
                dump_on_failure = 1;
 
+       /* Allow -v to be controlled through the environment. */
+       if (getenv("_VERBOSITY_LEVEL") != NULL)
+       {
+               vlevel = getenv("_VERBOSITY_LEVEL");
+               verbosity = atoi(vlevel);
+               if (verbosity < VERBOSITY_SUMMARY_ONLY || verbosity > VERBOSITY_FULL)
+               {
+                       /* Unsupported verbosity levels are silently ignored */
+                       vlevel = NULL;
+                       verbosity = VERBOSITY_PASSFAIL;
+               }
+       }
+
        /* Get the directory holding test files from environment. */
        refdir = getenv(ENVBASE "_TEST_FILES");
 
@@ -2520,7 +2533,8 @@ main(int argc, char **argv)
 #endif
                                break;
                        case 'q':
-                               verbosity--;
+                               if (!vlevel)
+                                       verbosity--;
                                break;
                        case 'r':
                                refdir = option_arg;
@@ -2529,7 +2543,8 @@ main(int argc, char **argv)
                                until_failure++;
                                break;
                        case 'v':
-                               verbosity++;
+                               if (!vlevel)
+                                       verbosity++;
                                break;
                        default:
                                fprintf(stderr, "Unrecognized option '%c'\n",
index 11f01d2d6aace6b673e836852e8f6dca9f9d305e..56f7981297acd687e613516688445a2a7ea4d4b2 100644 (file)
@@ -2385,7 +2385,7 @@ main(int argc, char **argv)
        const char *progname;
        char **saved_argv;
        const char *tmp, *option_arg, *p;
-       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
+       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
        char tmpdir_timestamp[256];
 
        (void)argc; /* UNUSED */
@@ -2471,6 +2471,19 @@ main(int argc, char **argv)
        if (getenv(ENVBASE "_DEBUG") != NULL)
                dump_on_failure = 1;
 
+       /* Allow -v to be controlled through the environment. */
+       if (getenv("_VERBOSITY_LEVEL") != NULL)
+       {
+               vlevel = getenv("_VERBOSITY_LEVEL");
+               verbosity = atoi(vlevel);
+               if (verbosity < VERBOSITY_SUMMARY_ONLY || verbosity > VERBOSITY_FULL)
+               {
+                       /* Unsupported verbosity levels are silently ignored */
+                       vlevel = NULL;
+                       verbosity = VERBOSITY_PASSFAIL;
+               }
+       }
+
        /* Get the directory holding test files from environment. */
        refdir = getenv(ENVBASE "_TEST_FILES");
 
@@ -2518,7 +2531,8 @@ main(int argc, char **argv)
 #endif
                                break;
                        case 'q':
-                               verbosity--;
+                               if (!vlevel)
+                                       verbosity--;
                                break;
                        case 'r':
                                refdir = option_arg;
@@ -2527,7 +2541,8 @@ main(int argc, char **argv)
                                until_failure++;
                                break;
                        case 'v':
-                               verbosity++;
+                               if (!vlevel)
+                                       verbosity++;
                                break;
                        default:
                                fprintf(stderr, "Unrecognized option '%c'\n",
index 45cbae0a68042c49a1db445c332e93889f242047..a202334ce7c34c8f1552cccd54653e88ed7c1af8 100644 (file)
@@ -2387,7 +2387,7 @@ main(int argc, char **argv)
        const char *progname;
        char **saved_argv;
        const char *tmp, *option_arg, *p;
-       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL;
+       char tmpdir[256], *pwd, *testprogdir, *tmp2 = NULL, *vlevel = NULL;
        char tmpdir_timestamp[256];
 
        (void)argc; /* UNUSED */
@@ -2473,6 +2473,19 @@ main(int argc, char **argv)
        if (getenv(ENVBASE "_DEBUG") != NULL)
                dump_on_failure = 1;
 
+       /* Allow -v to be controlled through the environment. */
+       if (getenv("_VERBOSITY_LEVEL") != NULL)
+       {
+               vlevel = getenv("_VERBOSITY_LEVEL");
+               verbosity = atoi(vlevel);
+               if (verbosity < VERBOSITY_SUMMARY_ONLY || verbosity > VERBOSITY_FULL)
+               {
+                       /* Unsupported verbosity levels are silently ignored */
+                       vlevel = NULL;
+                       verbosity = VERBOSITY_PASSFAIL;
+               }
+       }
+
        /* Get the directory holding test files from environment. */
        refdir = getenv(ENVBASE "_TEST_FILES");
 
@@ -2520,7 +2533,8 @@ main(int argc, char **argv)
 #endif
                                break;
                        case 'q':
-                               verbosity--;
+                               if (!vlevel)
+                                       verbosity--;
                                break;
                        case 'r':
                                refdir = option_arg;
@@ -2529,7 +2543,8 @@ main(int argc, char **argv)
                                until_failure++;
                                break;
                        case 'v':
-                               verbosity++;
+                               if (!vlevel)
+                                       verbosity++;
                                break;
                        default:
                                fprintf(stderr, "Unrecognized option '%c'\n",