unit-tests: Defining TESTS_RUNNERS allows to only run specific test runners
This commit is contained in:
@@ -89,6 +89,28 @@ static void apply_filter(array_t *loaded, char *filter, bool exclude)
|
|||||||
names->destroy(names);
|
names->destroy(names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given string is contained in the filter string.
|
||||||
|
*/
|
||||||
|
static bool is_in_filter(const char *find, char *filter)
|
||||||
|
{
|
||||||
|
enumerator_t *names;
|
||||||
|
bool found = FALSE;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
names = enumerator_create_token(filter, ",", " ");
|
||||||
|
while (names->enumerate(names, &name))
|
||||||
|
{
|
||||||
|
if (streq(name, find))
|
||||||
|
{
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names->destroy(names);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes and destroys test suites that are not selected or
|
* Removes and destroys test suites that are not selected or
|
||||||
* explicitly excluded.
|
* explicitly excluded.
|
||||||
@@ -524,11 +546,17 @@ int test_runner_run(const char *name, test_configuration_t configs[],
|
|||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
int passed = 0, result;
|
int passed = 0, result;
|
||||||
level_t level = LEVEL_SILENT;
|
level_t level = LEVEL_SILENT;
|
||||||
char *cfg, *verbosity;
|
char *cfg, *runners, *verbosity;
|
||||||
|
|
||||||
/* redirect all output to stderr (to redirect make's stdout to /dev/null) */
|
/* redirect all output to stderr (to redirect make's stdout to /dev/null) */
|
||||||
dup2(2, 1);
|
dup2(2, 1);
|
||||||
|
|
||||||
|
runners = getenv("TESTS_RUNNERS");
|
||||||
|
if (runners && !is_in_filter(name, runners))
|
||||||
|
{
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
cfg = getenv("TESTS_STRONGSWAN_CONF");
|
cfg = getenv("TESTS_STRONGSWAN_CONF");
|
||||||
|
|
||||||
suites = load_suites(configs, init, cfg);
|
suites = load_suites(configs, init, cfg);
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ struct test_configuration_t {
|
|||||||
* - TESTS_VERBOSITY: Numerical loglevel for debug log
|
* - TESTS_VERBOSITY: Numerical loglevel for debug log
|
||||||
* - TESTS_STRONGSWAN_CONF: Specify a path to a custom strongswan.conf
|
* - TESTS_STRONGSWAN_CONF: Specify a path to a custom strongswan.conf
|
||||||
* - TESTS_PLUGINS: Specify an explicit list of plugins to load
|
* - TESTS_PLUGINS: Specify an explicit list of plugins to load
|
||||||
|
* - TESTS_RUNNERS: Run specific test runners only
|
||||||
* - TESTS_SUITES: Run specific test suites only
|
* - TESTS_SUITES: Run specific test suites only
|
||||||
* - TESTS_SUITES_EXCLUDE: Don't run specific test suites
|
* - TESTS_SUITES_EXCLUDE: Don't run specific test suites
|
||||||
* - TESTS_REDUCED_KEYLENGTHS: Test minimal keylengths for public key tests only
|
* - TESTS_REDUCED_KEYLENGTHS: Test minimal keylengths for public key tests only
|
||||||
@@ -77,6 +78,9 @@ struct test_configuration_t {
|
|||||||
* Please note that TESTS_PLUGINS actually must be implemented by the init
|
* Please note that TESTS_PLUGINS actually must be implemented by the init
|
||||||
* callback function, as plugin loading is delegated.
|
* callback function, as plugin loading is delegated.
|
||||||
*
|
*
|
||||||
|
* EXIT_SUCCESS is returned right away if TESTS_RUNNERS is defined but the name
|
||||||
|
* passed to this function is not contained in it.
|
||||||
|
*
|
||||||
* @param name name of test runner
|
* @param name name of test runner
|
||||||
* @param config test suite constructors with dependencies
|
* @param config test suite constructors with dependencies
|
||||||
* @param init_cb init/deinit callback
|
* @param init_cb init/deinit callback
|
||||||
|
|||||||
Reference in New Issue
Block a user