From: Peter Hutterer Date: Wed, 20 May 2015 00:49:13 +0000 (+1000) Subject: test: add --filter-device argument X-Git-Tag: upstream/0.15.0+92+gec468e8~34^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=538e98d46f796720abe95fff0d636f67828efe88;p=platform%2Fupstream%2Flibinput.git test: add --filter-device argument Similar to the CK_RUN_CASE environment variable, but it does support fnmatch()-style wildcards, e.g. ./test/test-touchpad --filter-device="synaptics*" Signed-off-by: Peter Hutterer --- diff --git a/doc/test-suite.dox b/doc/test-suite.dox index 079018c0..757dc86e 100644 --- a/doc/test-suite.dox +++ b/doc/test-suite.dox @@ -69,6 +69,17 @@ basic shell-style function name matching. For example: $ ./test/test-touchpad --filter-test="*1fg_tap*" @endcode +The `--filter-device` argument enables selective running of tests through +basic shell-style device name matching. The device names matched are the +litest-specific shortnames, see the output of `--list`. For example: + +@code +$ ./test/test-touchpad --filter-device="synaptics*" +@endcode + +The `--filter-device` argument can be combined with `--list` to show +which devices will be affected. + @section test-verbosity Controlling test output Each test supports the `--verbose` commandline option to enable debugging diff --git a/test/litest.c b/test/litest.c index fb0403db..fb4e1b93 100644 --- a/test/litest.c +++ b/test/litest.c @@ -52,6 +52,7 @@ static int in_debugger = -1; static int verbose = 0; const char *filter_test = NULL; +const char *filter_device = NULL; struct test { struct list node; @@ -237,6 +238,10 @@ litest_add_tcase_no_device(struct suite *suite, struct test *t; const char *test_name = "no device"; + if (filter_device && + fnmatch(filter_device, test_name, 0) != 0) + return; + list_for_each(t, &suite->tests, node) { if (strcmp(t->name, test_name) != 0) continue; @@ -305,24 +310,31 @@ litest_add_tcase(const char *suite_name, excluded == LITEST_DISABLE_DEVICE) { litest_add_tcase_no_device(suite, func, range); } else if (required != LITEST_ANY || excluded != LITEST_ANY) { - while (*dev) { - if (((*dev)->features & required) == required && - ((*dev)->features & excluded) == 0) - litest_add_tcase_for_device(suite, - funcname, - func, - *dev, - range); - dev++; + for (; *dev; dev++) { + if (filter_device && + fnmatch(filter_device, (*dev)->shortname, 0) != 0) + continue; + if (((*dev)->features & required) != required || + ((*dev)->features & excluded) != 0) + continue; + + litest_add_tcase_for_device(suite, + funcname, + func, + *dev, + range); } } else { - while (*dev) { + for (; *dev; dev++) { + if (filter_device && + fnmatch(filter_device, (*dev)->shortname, 0) != 0) + continue; + litest_add_tcase_for_device(suite, funcname, func, *dev, range); - dev++; } } } @@ -395,7 +407,11 @@ _litest_add_ranged_for_device(const char *name, assert(type < LITEST_NO_DEVICE); s = get_suite(name); - while (*dev) { + for (; *dev; dev++) { + if (filter_device && + fnmatch(filter_device, (*dev)->shortname, 0) != 0) + continue; + if ((*dev)->type == type) { litest_add_tcase_for_device(s, funcname, @@ -404,7 +420,6 @@ _litest_add_ranged_for_device(const char *name, range); return; } - dev++; } ck_abort_msg("Invalid test device type"); @@ -1900,11 +1915,13 @@ litest_parse_argv(int argc, char **argv) { enum { OPT_FILTER_TEST, + OPT_FILTER_DEVICE, OPT_LIST, OPT_VERBOSE, }; static const struct option opts[] = { { "filter-test", 1, 0, OPT_FILTER_TEST }, + { "filter-device", 1, 0, OPT_FILTER_DEVICE }, { "list", 0, 0, OPT_LIST }, { "verbose", 0, 0, OPT_VERBOSE }, { 0, 0, 0, 0} @@ -1921,6 +1938,9 @@ litest_parse_argv(int argc, char **argv) case OPT_FILTER_TEST: filter_test = optarg; break; + case OPT_FILTER_DEVICE: + filter_device = optarg; + break; case OPT_LIST: litest_list_tests(&all_tests); exit(0);