[PATCH libinput 5/6] test: add --filter-group argument to match test groups (suites)

Peter Hutterer peter.hutterer at who-t.net
Tue May 19 20:25:01 PDT 2015


Same as CK_RUN_SUITE, but supports fnmatch-like globs

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 doc/test-suite.dox | 12 ++++++++++--
 test/litest.c      | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/doc/test-suite.dox b/doc/test-suite.dox
index 757dc86..83cae24 100644
--- a/doc/test-suite.dox
+++ b/doc/test-suite.dox
@@ -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:
+
+ at code
+$ ./test/test-touchpad --filter-group="touchpad:*hover*"
+ at 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
 
diff --git a/test/litest.c b/test/litest.c
index fb4e1b9..2b1e183 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -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);
-- 
2.3.5



More information about the wayland-devel mailing list