From 27188228fdef10707c61f822db57bf0d3d568682 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 5 Mar 2019 15:14:12 +1000 Subject: [PATCH] test: install the test device udev rule from a string It's a one-liner, we don't need this as a separate file. Plus, this makes the test suite runner less dependent on the build directory. Signed-off-by: Peter Hutterer --- meson.build | 5 ----- test/litest.c | 40 +++++++++++++++++++++++++------------- udev/80-libinput-test-device.rules | 1 - 3 files changed, 26 insertions(+), 20 deletions(-) delete mode 100644 udev/80-libinput-test-device.rules diff --git a/meson.build b/meson.build index 57c4ceb..1063dfc 100644 --- a/meson.build +++ b/meson.build @@ -773,11 +773,6 @@ if get_option('tests') dep_libquirks, ] - configure_file(input : 'udev/80-libinput-test-device.rules', - output : '80-libinput-test-device.rules', - install : false, - configuration : udev_rules_config) - litest_config_h = configuration_data() litest_config_h.set_quoted('LIBINPUT_TEST_DEVICE_RULES_FILE', join_paths(meson.build_root(), '80-libinput-test-device.rules')) diff --git a/test/litest.c b/test/litest.c index 2c41b22..68da4fa 100644 --- a/test/litest.c +++ b/test/litest.c @@ -1070,7 +1070,7 @@ merge_events(const int *orig, const int *override) } static inline struct created_file * -litest_copy_file(const char *dest, const char *src, const char *header) +litest_copy_file(const char *dest, const char *src, const char *header, bool is_file) { int in, out, length; struct created_file *file; @@ -1099,15 +1099,21 @@ litest_copy_file(const char *dest, const char *src, const char *header) litest_assert_int_eq(write(out, header, length), length); } - in = open(src, O_RDONLY); - if (in == -1) - litest_abort_msg("Failed to open file %s (%s)\n", - src, - strerror(errno)); - /* lazy, just check for error and empty file copy */ - litest_assert_int_gt(litest_send_file(out, in), 0); + if (is_file) { + in = open(src, O_RDONLY); + if (in == -1) + litest_abort_msg("Failed to open file %s (%s)\n", + src, + strerror(errno)); + /* lazy, just check for error and empty file copy */ + litest_assert_int_gt(litest_send_file(out, in), 0); + close(in); + } else { + size_t written = write(out, src, strlen(src)); + litest_assert_int_eq(written, strlen(src)); + + } close(out); - close(in); return file; } @@ -1123,20 +1129,26 @@ litest_install_model_quirks(struct list *created_files_list) "# running, remove this file\n" "#################################################################\n\n"; struct created_file *file; + const char *test_device_udev_rule = "KERNELS==\"*input*\", " + "ATTRS{name}==\"litest *\", " + "ENV{LIBINPUT_TEST_DEVICE}=\"1\""; file = litest_copy_file(UDEV_TEST_DEVICE_RULE_FILE, - LIBINPUT_TEST_DEVICE_RULES_FILE, - warning); + test_device_udev_rule, + warning, + false); list_insert(created_files_list, &file->link); file = litest_copy_file(UDEV_DEVICE_GROUPS_FILE, LIBINPUT_DEVICE_GROUPS_RULES_FILE, - warning); + warning, + true); list_insert(created_files_list, &file->link); file = litest_copy_file(UDEV_MODEL_QUIRKS_RULE_FILE, LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE, - warning); + warning, + true); list_insert(created_files_list, &file->link); } @@ -1195,7 +1207,7 @@ litest_install_quirks(struct list *created_files_list) snprintf(src, sizeof(src), "%s/%s", LIBINPUT_QUIRKS_SRCDIR, filename); snprintf(dest, sizeof(dest), "%s/%s", dirname, filename); - file = litest_copy_file(dest, src, NULL); + file = litest_copy_file(dest, src, NULL, true); list_append(created_files_list, &file->link); q++; } diff --git a/udev/80-libinput-test-device.rules b/udev/80-libinput-test-device.rules deleted file mode 100644 index d37b2ab..0000000 --- a/udev/80-libinput-test-device.rules +++ /dev/null @@ -1 +0,0 @@ -KERNELS=="*input*", ATTRS{name}=="litest *", ENV{LIBINPUT_TEST_DEVICE}="1" -- 2.7.4