test: remove the deviceless test runner, make it a commandline arg instead
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 10 Aug 2018 01:39:04 +0000 (11:39 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 13 Aug 2018 01:08:32 +0000 (11:08 +1000)
No need to rebuild everything with an ifdef, we can just use meson to pass an
argument to the test itself and filter based on that. This drops about 100
ninja targets.

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

index ac631312ef19a27975a6ad26b1502bfcb48c5376..b560918e6543083ac302feb047b2731db0a54090 100644 (file)
@@ -820,13 +820,9 @@ if get_option('tests')
             libinput_test_runner,
             timeout : 1200)
 
-       libinput_test_deviceless = executable('libinput-test-deviceless',
-                                             libinput_test_runner_sources,
-                                             include_directories : [includes_src, includes_include],
-                                             dependencies : deps_litest,
-                                             c_args : [ def_LT_VERSION, '-DDISABLE_DEVICE_TESTS=1' ],
-                                             install : false)
-       test('libinput-test-deviceless', libinput_test_deviceless)
+       test('libinput-test-deviceless',
+            libinput_test_runner,
+            args: ['--filter-deviceless'])
 
        valgrind_env = environment()
        valgrind_env.set('CK_FORK', 'no')
index 0536cf7a853786f6a304c3eba3920b1c75421de6..b684ea5bf8e8b8e6d2cc0f206397f310b6693829 100644 (file)
@@ -76,6 +76,7 @@
 static int jobs = 8;
 static bool in_debugger = false;
 static bool verbose = false;
+static bool run_deviceless = false;
 const char *filter_test = NULL;
 const char *filter_device = NULL;
 const char *filter_group = NULL;
@@ -887,15 +888,13 @@ litest_run_suite(struct list *tests, int which, int max, int error_fd)
                        TCase *tc;
                        char *sname, *tname;
 
-#if DISABLE_DEVICE_TESTS
                        /* 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 (!t->deviceless)
+                       if (run_deviceless && !t->deviceless)
                                continue;
-#endif
 
                        count = (count + 1) % max;
                        if (max != 1 && (count % max) != which)
@@ -1030,13 +1029,15 @@ static inline int
 inhibit(void)
 {
        int lock_fd = -1;
-#if !DISABLE_DEVICE_TESTS
 #if HAVE_LIBSYSTEMD
        sd_bus_error error = SD_BUS_ERROR_NULL;
        sd_bus_message *m = NULL;
        sd_bus *bus = NULL;
        int rc;
 
+       if (run_deviceless)
+               return -1;
+
        rc = sd_bus_open_system(&bus);
        if (rc != 0) {
                fprintf(stderr, "Warning: inhibit failed: %s\n", strerror(-rc));
@@ -1072,7 +1073,6 @@ out:
        sd_bus_message_unref(m);
        sd_bus_close(bus);
        sd_bus_unref(bus);
-#endif
 #endif
        return lock_fd;
 }
@@ -1095,12 +1095,12 @@ litest_run(int argc, char **argv)
        if (getenv("LITEST_VERBOSE"))
                verbose = true;
 
-#if DISABLE_DEVICE_TESTS
-       quirks_dir = safe_strdup(LIBINPUT_QUIRKS_SRCDIR);
-#else
-       litest_init_udev_rules(&created_files_list);
-       quirks_dir = litest_install_quirks(&created_files_list);
-#endif
+       if (run_deviceless) {
+               quirks_dir = safe_strdup(LIBINPUT_QUIRKS_SRCDIR);
+       } else {
+               litest_init_udev_rules(&created_files_list);
+               quirks_dir = litest_install_quirks(&created_files_list);
+       }
        setenv("LIBINPUT_QUIRKS_DIR", quirks_dir, 1);
        free(quirks_dir);
 
@@ -3873,6 +3873,7 @@ litest_parse_argv(int argc, char **argv)
                OPT_FILTER_TEST,
                OPT_FILTER_DEVICE,
                OPT_FILTER_GROUP,
+               OPT_FILTER_DEVICELESS,
                OPT_JOBS,
                OPT_LIST,
                OPT_VERBOSE,
@@ -3881,6 +3882,7 @@ litest_parse_argv(int argc, char **argv)
                { "filter-test", 1, 0, OPT_FILTER_TEST },
                { "filter-device", 1, 0, OPT_FILTER_DEVICE },
                { "filter-group", 1, 0, OPT_FILTER_GROUP },
+               { "filter-deviceless", 0, 0, OPT_FILTER_DEVICELESS },
                { "jobs", 1, 0, OPT_JOBS },
                { "list", 0, 0, OPT_LIST },
                { "verbose", 0, 0, OPT_VERBOSE },
@@ -3929,6 +3931,9 @@ litest_parse_argv(int argc, char **argv)
                case OPT_VERBOSE:
                        verbose = true;
                        break;
+               case OPT_FILTER_DEVICELESS:
+                       run_deviceless = true;
+                       break;
                default:
                        fprintf(stderr, "usage: %s [--list]\n", argv[0]);
                        return LITEST_MODE_ERROR;
@@ -4023,11 +4028,6 @@ setup_tests(void)
 static int
 check_device_access(void)
 {
-#if !DISABLE_DEVICE_TESTS
-       /* You don't get to skip the deviceless tests */
-       if (getenv("SKIP_LIBINPUT_TEST_SUITE_RUNNER"))
-               return 77;
-
        if (getuid() != 0) {
                fprintf(stderr,
                        "%s must be run as root.\n",
@@ -4041,7 +4041,6 @@ check_device_access(void)
                        "uinput device is missing, skipping tests.\n");
                return 77;
        }
-#endif /* DISABLE_DEVICE_TESTS */
 
        return 0;
 }
@@ -4051,12 +4050,12 @@ disable_tty(void)
 {
        int tty_mode = -1;
 
-#if !DISABLE_DEVICE_TESTS
        /* If we're running 'normally' on the VT, disable the keyboard to
         * avoid messing up our host. But if we're inside gdb or running
         * without forking, leave it as-is.
         */
-       if (jobs > 1 &&
+       if (!run_deviceless &&
+           jobs > 1 &&
            !in_debugger &&
            getenv("CK_FORK") == NULL &&
            isatty(STDIN_FILENO) &&
@@ -4075,7 +4074,6 @@ disable_tty(void)
                                fprintf(stderr, "Failed to set terminal attribute: %d - %s\n", errno, strerror(errno));
 #endif
        }
-#endif /* DISABLE_DEVICE_TESTS */
 
        return tty_mode;
 }
@@ -4097,9 +4095,14 @@ main(int argc, char **argv)
        if (mode == LITEST_MODE_ERROR)
                return EXIT_FAILURE;
 
-       rc = check_device_access();
-       if (rc != 0)
-               return rc;
+       /* You don't get to skip the deviceless tests */
+       if (!run_deviceless) {
+               if (getenv("SKIP_LIBINPUT_TEST_SUITE_RUNNER"))
+                       return 77;
+
+               if ((rc = check_device_access()) != 0)
+                       return rc;
+       }
 
        litest_init_test_devices();