From: Martin Willi Date: Tue, 21 Jan 2014 16:48:08 +0000 (+0100) Subject: unit-tests: Pass a test suite collection name to print during test execution X-Git-Tag: 5.1.2rc1~59 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b0341315556c7a75026a074b7d6eafa7b312396e;p=thirdparty%2Fstrongswan.git unit-tests: Pass a test suite collection name to print during test execution As we except to get more and more test runners for the different components, we add a name to easily identify them on the test output. --- diff --git a/src/charon-tkm/tests/tests.c b/src/charon-tkm/tests/tests.c index 633e3ed16f..5bbacacf33 100644 --- a/src/charon-tkm/tests/tests.c +++ b/src/charon-tkm/tests/tests.c @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) * does not work otherwise due to limitations of the external libraries */ setenv("LEAK_DETECTIVE_DISABLE", "1", 1); - result = test_runner_run(tests, test_runner_init); + result = test_runner_run("tkm", tests, test_runner_init); tkm_deinit(); return result; diff --git a/src/libstrongswan/tests/test_runner.c b/src/libstrongswan/tests/test_runner.c index bf18f16fb3..1e46cfe8e4 100644 --- a/src/libstrongswan/tests/test_runner.c +++ b/src/libstrongswan/tests/test_runner.c @@ -442,7 +442,8 @@ static bool run_suite(test_suite_t *suite, test_runner_init_t init) /** * See header. */ -int test_runner_run(test_configuration_t configs[], test_runner_init_t init) +int test_runner_run(const char *name, test_configuration_t configs[], + test_runner_init_t init) { array_t *suites; test_suite_t *suite; @@ -458,7 +459,7 @@ int test_runner_run(test_configuration_t configs[], test_runner_init_t init) return EXIT_FAILURE; } - fprintf(stderr, "Running %u test suites:\n", array_count(suites)); + fprintf(stderr, "Running %u '%s' test suites:\n", array_count(suites), name); enumerator = array_create_enumerator(suites); while (enumerator->enumerate(enumerator, &suite)) @@ -472,14 +473,14 @@ int test_runner_run(test_configuration_t configs[], test_runner_init_t init) if (passed == array_count(suites)) { - fprintf(stderr, "%sPassed all %u suites%s\n", - TTY(GREEN), array_count(suites), TTY(DEF)); + fprintf(stderr, "%sPassed all %u '%s' suites%s\n", + TTY(GREEN), array_count(suites), name, TTY(DEF)); result = EXIT_SUCCESS; } else { - fprintf(stderr, "%sPassed %u of %u suites%s\n", - TTY(RED), passed, array_count(suites), TTY(DEF)); + fprintf(stderr, "%sPassed %u of %u '%s' suites%s\n", + TTY(RED), passed, array_count(suites), name, TTY(DEF)); result = EXIT_FAILURE; } diff --git a/src/libstrongswan/tests/test_runner.h b/src/libstrongswan/tests/test_runner.h index c895c130eb..e2b1c7eac1 100644 --- a/src/libstrongswan/tests/test_runner.h +++ b/src/libstrongswan/tests/test_runner.h @@ -66,10 +66,12 @@ struct test_configuration_t { * * The configs array must be terminated with a NULL element. * + * @oaran name name of test runner * @param config test suite constructors with dependencies * @param init_cb init/deinit callback * @return test result, EXIT_SUCCESS if all tests passed */ -int test_runner_run(test_configuration_t config[], test_runner_init_t init_cb); +int test_runner_run(const char *name, test_configuration_t config[], + test_runner_init_t init_cb); #endif /** TEST_RUNNER_H_ @}*/ diff --git a/src/libstrongswan/tests/tests.c b/src/libstrongswan/tests/tests.c index c3f43e71c3..9f2adfd157 100644 --- a/src/libstrongswan/tests/tests.c +++ b/src/libstrongswan/tests/tests.c @@ -52,5 +52,5 @@ static bool test_runner_init(bool init) int main(int argc, char *argv[]) { - return test_runner_run(tests, test_runner_init); + return test_runner_run("libstrongswan", tests, test_runner_init); }