aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2014-01-21 17:48:08 +0100
committerMartin Willi <martin@revosec.ch>2014-01-22 15:34:53 +0100
commitb0341315556c7a75026a074b7d6eafa7b312396e (patch)
treeda81efc0bf15c34830c44883a159398c47154295
parent589fab22608a9969a5f9ce924d62f6fcf2c1424d (diff)
downloadstrongswan-b0341315556c7a75026a074b7d6eafa7b312396e.tar.bz2
strongswan-b0341315556c7a75026a074b7d6eafa7b312396e.tar.xz
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.
-rw-r--r--src/charon-tkm/tests/tests.c2
-rw-r--r--src/libstrongswan/tests/test_runner.c13
-rw-r--r--src/libstrongswan/tests/test_runner.h4
-rw-r--r--src/libstrongswan/tests/tests.c2
4 files changed, 12 insertions, 9 deletions
diff --git a/src/charon-tkm/tests/tests.c b/src/charon-tkm/tests/tests.c
index 633e3ed16..5bbacacf3 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 bf18f16fb..1e46cfe8e 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 c895c130e..e2b1c7eac 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 c3f43e71c..9f2adfd15 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);
}