unit-tests: Add option to exclude specific test suites
Listing test suites in TESTS_SUITES_EXCLUDE allows excluding specific test suites from running.
This commit is contained in:
@@ -58,40 +58,57 @@ static void destroy_suite(test_suite_t *suite)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and destroys test suites that are not selected.
|
||||
* Filter loaded test suites, either remove suites listed (exclude=TRUE), or all
|
||||
* that are not listed (exclude=FALSE).
|
||||
*/
|
||||
static void filter_suites(array_t *loaded)
|
||||
static void apply_filter(array_t *loaded, char *filter, bool exclude)
|
||||
{
|
||||
enumerator_t *enumerator, *names;
|
||||
hashtable_t *selected;
|
||||
hashtable_t *listed;
|
||||
test_suite_t *suite;
|
||||
char *suites, *name;
|
||||
char *name;
|
||||
|
||||
suites = getenv("TESTS_SUITES");
|
||||
if (!suites)
|
||||
{
|
||||
return;
|
||||
}
|
||||
selected = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8);
|
||||
names = enumerator_create_token(suites, ",", " ");
|
||||
listed = hashtable_create(hashtable_hash_str, hashtable_equals_str, 8);
|
||||
names = enumerator_create_token(filter, ",", " ");
|
||||
while (names->enumerate(names, &name))
|
||||
{
|
||||
selected->put(selected, name, name);
|
||||
listed->put(listed, name, name);
|
||||
}
|
||||
enumerator = array_create_enumerator(loaded);
|
||||
while (enumerator->enumerate(enumerator, &suite))
|
||||
{
|
||||
if (!selected->get(selected, suite->name))
|
||||
if ((exclude && listed->get(listed, suite->name)) ||
|
||||
(!exclude && !listed->get(listed, suite->name)))
|
||||
{
|
||||
array_remove_at(loaded, enumerator);
|
||||
destroy_suite(suite);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
selected->destroy(selected);
|
||||
listed->destroy(listed);
|
||||
names->destroy(names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes and destroys test suites that are not selected or
|
||||
* explicitly excluded.
|
||||
*/
|
||||
static void filter_suites(array_t *loaded)
|
||||
{
|
||||
char *filter;
|
||||
|
||||
filter = getenv("TESTS_SUITES");
|
||||
if (filter)
|
||||
{
|
||||
apply_filter(loaded, filter, FALSE);
|
||||
}
|
||||
filter = getenv("TESTS_SUITES_EXCLUDE");
|
||||
if (filter)
|
||||
{
|
||||
apply_filter(loaded, filter, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all available test suites, or optionally only selected ones.
|
||||
*/
|
||||
|
||||
@@ -70,6 +70,7 @@ struct test_configuration_t {
|
||||
* - TESTS_VERBOSITY: Numerical loglevel for debug log
|
||||
* - TESTS_STRONGSWAN_CONF: Specify a path to a custom strongswan.conf
|
||||
* - TESTS_SUITES: Run specific test suites only
|
||||
* - TESTS_SUITES_EXCLUDE: Don't run specific test suites
|
||||
* - TESTS_REDUCED_KEYLENGTHS: Test minimal keylengths for public key tests only
|
||||
*
|
||||
* @param name name of test runner
|
||||
|
||||
Reference in New Issue
Block a user