unit-tests: Allow configuring log levels for individual groups

This commit is contained in:
Tobias Brunner
2022-06-29 10:28:50 +02:00
parent 35edbc4048
commit 23b0220b1c
2 changed files with 47 additions and 5 deletions
+26
View File
@@ -735,6 +735,30 @@ static bool run_suite(test_suite_t *suite, test_runner_init_t init, char *cfg,
return FALSE;
}
/**
* Configure log levels for specific groups
*/
static void setup_log_levels(level_t *base)
{
char buf[BUF_LEN], *verbosity;
debug_t group;
level_t level;
for (group = 0; group < DBG_MAX; group++)
{
snprintf(buf, sizeof(buf), "TESTS_VERBOSITY_%s",
enum_to_name(debug_names, group));
verbosity = getenv(buf);
if (verbosity)
{
level = atoi(verbosity);
dbg_default_set_level_group(group, level);
*base = max(*base, level);
}
}
}
/**
* See header.
*/
@@ -772,6 +796,8 @@ int test_runner_run(const char *name, test_configuration_t configs[],
}
dbg_default_set_level(level);
setup_log_levels(&level);
fprintf(stderr, "Running %u '%s' test suites:\n", array_count(suites), name);
enumerator = array_create_enumerator(suites);