[PATCH libinput 4/6] test: add --filter-device argument
Peter Hutterer
peter.hutterer at who-t.net
Tue May 19 20:25:00 PDT 2015
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 <peter.hutterer at who-t.net>
---
doc/test-suite.dox | 11 +++++++++++
test/litest.c | 46 +++++++++++++++++++++++++++++++++-------------
2 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/doc/test-suite.dox b/doc/test-suite.dox
index 079018c..757dc86 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:
+
+ at code
+$ ./test/test-touchpad --filter-device="synaptics*"
+ at 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 fb0403d..fb4e1b9 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);
--
2.3.5
More information about the wayland-devel
mailing list