test: add --filter-group argument to match test groups (suites)

Same as CK_RUN_SUITE, but supports fnmatch-like globs

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2015-05-20 11:00:37 +10:00
parent 538e98d46f
commit f3947c0eb9
2 changed files with 24 additions and 2 deletions

View file

@ -77,8 +77,16 @@ litest-specific shortnames, see the output of `--list`. For example:
$ ./test/test-touchpad --filter-device="synaptics*"
@endcode
The `--filter-device` argument can be combined with `--list` to show
which devices will be affected.
The `--filter-group` argument enables selective running of test groups
through basic shell-style test group matching. The test groups matched are
litest-specific test groups, see the output of `--list`. For example:
@code
$ ./test/test-touchpad --filter-group="touchpad:*hover*"
@endcode
The `--filter-device` and `--filter-group` arguments can be combined with
`--list` to show which groups and devices will be affected.
@section test-verbosity Controlling test output

View file

@ -53,6 +53,7 @@ static int in_debugger = -1;
static int verbose = 0;
const char *filter_test = NULL;
const char *filter_device = NULL;
const char *filter_group = NULL;
struct test {
struct list node;
@ -304,6 +305,10 @@ litest_add_tcase(const char *suite_name,
fnmatch(filter_test, funcname, 0) != 0)
return;
if (filter_group &&
fnmatch(filter_group, suite_name, 0) != 0)
return;
suite = get_suite(suite_name);
if (required == LITEST_DISABLE_DEVICE &&
@ -406,6 +411,10 @@ _litest_add_ranged_for_device(const char *name,
assert(type < LITEST_NO_DEVICE);
if (filter_group &&
fnmatch(filter_group, name, 0) != 0)
return;
s = get_suite(name);
for (; *dev; dev++) {
if (filter_device &&
@ -1916,12 +1925,14 @@ litest_parse_argv(int argc, char **argv)
enum {
OPT_FILTER_TEST,
OPT_FILTER_DEVICE,
OPT_FILTER_GROUP,
OPT_LIST,
OPT_VERBOSE,
};
static const struct option opts[] = {
{ "filter-test", 1, 0, OPT_FILTER_TEST },
{ "filter-device", 1, 0, OPT_FILTER_DEVICE },
{ "filter-group", 1, 0, OPT_FILTER_GROUP },
{ "list", 0, 0, OPT_LIST },
{ "verbose", 0, 0, OPT_VERBOSE },
{ 0, 0, 0, 0}
@ -1941,6 +1952,9 @@ litest_parse_argv(int argc, char **argv)
case OPT_FILTER_DEVICE:
filter_device = optarg;
break;
case OPT_FILTER_GROUP:
filter_group = optarg;
break;
case OPT_LIST:
litest_list_tests(&all_tests);
exit(0);