]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
unit-tests: Set test verbosity just after test suite loading
authorMartin Willi <martin@revosec.ch>
Tue, 14 Apr 2015 07:26:17 +0000 (09:26 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 12:38:43 +0000 (14:38 +0200)
We see any plugin startup messages during suite configuration, where
initialization is called once to query plugin features. No need to be verbose
and show these messages once again in the first test.

src/libstrongswan/tests/test_runner.c

index 83f4e8faffe6c3ef2702de720a495283d9dff836..0bae9c8cd448c2b4596caed4c2e9e0734f2adee1 100644 (file)
@@ -235,9 +235,6 @@ static bool call_fixture(test_case_t *tcase, bool up)
  */
 static bool pre_test(test_runner_init_t init, char *cfg)
 {
-       level_t level = LEVEL_SILENT;
-       char *verbosity;
-
        library_init(cfg, "test-runner");
 
        /* use non-blocking RNG to generate keys fast */
@@ -260,12 +257,6 @@ static bool pre_test(test_runner_init_t init, char *cfg)
                library_deinit();
                return FALSE;
        }
-       verbosity = getenv("TESTS_VERBOSITY");
-       if (verbosity)
-       {
-               level = atoi(verbosity);
-       }
-       dbg_default_set_level(level);
        return TRUE;
 }
 
@@ -532,7 +523,8 @@ int test_runner_run(const char *name, test_configuration_t configs[],
        test_suite_t *suite;
        enumerator_t *enumerator;
        int passed = 0, result;
-       char *cfg;
+       level_t level = LEVEL_SILENT;
+       char *cfg, *verbosity;
 
        /* redirect all output to stderr (to redirect make's stdout to /dev/null) */
        dup2(2, 1);
@@ -545,6 +537,13 @@ int test_runner_run(const char *name, test_configuration_t configs[],
                return EXIT_FAILURE;
        }
 
+       verbosity = getenv("TESTS_VERBOSITY");
+       if (verbosity)
+       {
+               level = atoi(verbosity);
+       }
+       dbg_default_set_level(level);
+
        fprintf(stderr, "Running %u '%s' test suites:\n", array_count(suites), name);
 
        enumerator = array_create_enumerator(suites);