diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-09-30 08:53:36 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-09-30 09:06:59 +1000 |
commit | 86a5627dbeac8d9d9bc34326a758d6a477e876e4 (patch) | |
tree | 47e29af2de4d44f733ae0d0e77f713daef418262 | |
parent | 13e3b23bbb2bd059440ae6ba592e79f8342f85fa (diff) |
test: replace the hardcoded EV_MAX array with the libevdev one
Kernel 5.8 changed the value of SW_MAX but libevdev has a built-in check for
out-of-range bits (it silently discards those).
So where evemu is built against a new kernel but a libevdev that hasn't been
updated yet, our test expects bit up to the new SW_MAX while libevdev
discards all bits above the old SW_MAX.
Fix this by making sure the test and uses the same value of the
respective type max as evemu itself does.
Fixes #3
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/test-evemu-create.c | 23 |
2 files changed, 12 insertions, 17 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index e6c167b..54a41b1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -11,8 +11,12 @@ test_cxx_compile_SOURCES = test-cxx-compile.cpp test_cxx_compile_LDADD = $(top_builddir)/src/libevemu.la test_evemu_create_SOURCES = test-evemu-create.c -test_evemu_create_LDADD = $(top_builddir)/src/libevemu.la +test_evemu_create_LDADD = \ + $(top_builddir)/src/libevemu.la \ + $(LIBEVDEV_LIBS) \ + $(NULL) test_evemu_create_LDFLAGS = -no-install +test_evemu_create_CFLAGS = $(LIBEVDEV_CFLAGS) endif CLEANFILES = evemu.tmp.* diff --git a/test/test-evemu-create.c b/test/test-evemu-create.c index d5238e5..0432e8b 100644 --- a/test/test-evemu-create.c +++ b/test/test-evemu-create.c @@ -10,6 +10,7 @@ #include <assert.h> #include "evemu.h" #include <linux/input.h> +#include <libevdev/libevdev.h> #define UNUSED __attribute__((unused)) @@ -45,19 +46,6 @@ enum flags { ALLFLAGS = (WITHNAME << 1) - 1 }; -static int max[EV_CNT] = { - 0, /* EV_SYN */ - KEY_MAX, /* EV_KEY */ - REL_MAX, /* EV_REL */ - ABS_MAX, /* EV_ABS */ - MSC_MAX, /* EV_MSC */ - SW_MAX, /* EV_SW */ - LED_MAX, /* EV_LED */ - SND_MAX, /* EV_SND */ - REP_MAX, /* EV_REP */ - FF_MAX /* EV_FF */ -}; - static void println(int fd, int flags, const char *format, ...) { va_list args; @@ -119,8 +107,8 @@ static void check_evemu_read(int fd, const char *file, enum flags flags) if (flags & BITS) { int i; for (i = 0; i < EV_CNT; i++) { - int j; - for (j = 0; j <= max[i]; j += 8) { + int max = libevdev_event_type_get_max(i); + for (int j = 0; j <= max; j += 8) { println(fd, flags, bits, i, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff); if (flags & EMPTYLINE) println(fd, flags, "%s", emptyline); @@ -177,11 +165,14 @@ static void check_evemu_read(int fd, const char *file, enum flags flags) if (flags & BITS) { int i, j; for (i = 1; i < EV_CNT; i++) { + int max = libevdev_event_type_get_max(i); + if (!evemu_has_bit(dev, i)) continue; - for (j = 0; j <= max[i]; j++) + for (j = 0; j <= max; j++) { assert(evemu_has_event(dev, i, j)); + } } } |