test: move the deviceless check into ltest_add_tcase
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 16 Oct 2024 01:21:29 +0000 (11:21 +1000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 30 Oct 2024 23:20:42 +0000 (23:20 +0000)
This is out of place here, check this when we are about
to add the test, not later when the tests are about to be run.

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>

test/litest.c

index 1706c2fb1cce9bc42d28c853b430d3b853208b1c..02a4252c4572bfc08c2c6afcd2e9897b9a6a227f 100644 (file)
@@ -398,6 +398,9 @@ litest_add_tcase_for_device(struct suite *suite,
 {
        struct test *t;
 
+       if (run_deviceless)
+               return;
+
        t = zalloc(sizeof(*t));
        t->name = safe_strdup(funcname);
        t->devname = safe_strdup(dev->shortname);
@@ -424,6 +427,9 @@ litest_add_tcase_no_device(struct suite *suite,
            fnmatch(filter_device, test_name, 0) != 0)
                return;
 
+       if (run_deviceless)
+               return;
+
        t = zalloc(sizeof(*t));
        t->name = safe_strdup(test_name);
        t->devname = safe_strdup("no device");
@@ -1024,14 +1030,6 @@ litest_run_suite(struct list *suites, int which, int max, int error_fd)
                        TCase *tc;
                        char *sname, *tname;
 
-                       /* We run deviceless tests as part of the normal
-                        * test suite runner, just in case. Filtering
-                        * all the other ones out just for the case where
-                        * we can't run the full runner.
-                        */
-                       if (run_deviceless && !t->deviceless)
-                               continue;
-
                        count = (count + 1) % max;
                        if (max != 1 && (count % max) != which)
                                continue;