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.
This commit is contained in:
Martin Willi
2014-01-22 15:34:53 +01:00
parent 589fab2260
commit b034131555
4 changed files with 12 additions and 9 deletions
+1 -1
View File
@@ -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;
+7 -6
View File
@@ -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;
}
+3 -1
View File
@@ -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_ @}*/
+1 -1
View File
@@ -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);
}