]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
unit-tests: Print a header for each test function/iteration if verbosity is >= 0
authorTobias Brunner <tobias@strongswan.org>
Wed, 1 Jul 2020 11:29:22 +0000 (13:29 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 20 Jul 2020 12:29:28 +0000 (14:29 +0200)
src/libstrongswan/tests/test_runner.c

index c7707e83ef366f0e0632bd6a8058e271940e2ae3..67fe80f7f8dc326f45df086514208e72f783aa8e 100644 (file)
@@ -549,7 +549,8 @@ static double end_timing(struct timespec *start)
 /**
  * Run a single test case with fixtures
  */
-static bool run_case(test_case_t *tcase, test_runner_init_t init, char *cfg)
+static bool run_case(test_case_t *tcase, test_runner_init_t init, char *cfg,
+                                        level_t level)
 {
        enumerator_t *enumerator;
        test_function_t *tfun;
@@ -586,6 +587,12 @@ static bool run_case(test_case_t *tcase, test_runner_init_t init, char *cfg)
                                bool ok = FALSE;
                                int leaks = 0;
 
+                               if (level >= 0)
+                               {
+                                       fprintf(stderr, "\nRunning function '%s' [%d]:\n",
+                                                       tfun->name, i);
+                               }
+
                                test_setup_timeout(tcase->timeout);
                                start_timing(&start);
 
@@ -676,7 +683,8 @@ static bool run_case(test_case_t *tcase, test_runner_init_t init, char *cfg)
 /**
  * Run a single test suite
  */
-static bool run_suite(test_suite_t *suite, test_runner_init_t init, char *cfg)
+static bool run_suite(test_suite_t *suite, test_runner_init_t init, char *cfg,
+                                         level_t level)
 {
        enumerator_t *enumerator;
        test_case_t *tcase;
@@ -687,7 +695,7 @@ static bool run_suite(test_suite_t *suite, test_runner_init_t init, char *cfg)
        enumerator = array_create_enumerator(suite->tcases);
        while (enumerator->enumerate(enumerator, &tcase))
        {
-               if (run_case(tcase, init, cfg))
+               if (run_case(tcase, init, cfg, level))
                {
                        passed++;
                }
@@ -747,7 +755,7 @@ int test_runner_run(const char *name, test_configuration_t configs[],
        enumerator = array_create_enumerator(suites);
        while (enumerator->enumerate(enumerator, &suite))
        {
-               if (run_suite(suite, init, cfg))
+               if (run_suite(suite, init, cfg, level))
                {
                        passed++;
                }