test: add --filter-group argument to match test groups (suites)
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 20 May 2015 01:00:37 +0000 (11:00 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 21 May 2015 22:45:35 +0000 (08:45 +1000)
Same as CK_RUN_SUITE, but supports fnmatch-like globs

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
doc/test-suite.dox
test/litest.c

index 757dc86e26a1e7f7b4d3a7a1888592784b42ec38..83cae24bfd3acbf2badabd506a212dc45cc9de65 100644 (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
 
index fb4e1b938261a06ca696867c3679f60656dfd1f4..2b1e183c49affc8fba232e79b68918288c4cb3f9 100644 (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);