From 5270a5532470564168affb04d5749de65efc3d05 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 14 Feb 2024 11:41:12 +1000 Subject: [PATCH] test: print the keyboard state as part of test_key_seq_va Makes it easier to debug modifier bugs. --- meson.build | 4 ++++ test/common.c | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 5f31f6a..1ea2bf3 100644 --- a/meson.build +++ b/meson.build @@ -434,6 +434,7 @@ if build_tools link_with: libxkbcommon_tools_internal, dependencies: dep_libxkbcommon, ) + configh_data.set10('HAVE_TOOLS', true) # Tool: xkbcli executable('xkbcli', 'tools/xkbcli.c', @@ -586,6 +587,8 @@ You can disable the Wayland xkbcli programs with -Denable-wayland=false.''') dependencies: [tools_dep], include_directories: [include_directories('src', 'include', 'tools')], install: false) +else + tools_dep = declare_dependency() endif @@ -628,6 +631,7 @@ libxkbcommon_test_internal = static_library( test_dep = declare_dependency( include_directories: include_directories('src', 'include'), link_with: libxkbcommon_test_internal, + dependencies: [tools_dep], ) if get_option('enable-x11') libxkbcommon_x11_test_internal = static_library( diff --git a/test/common.c b/test/common.c index 949539f..9529c74 100644 --- a/test/common.c +++ b/test/common.c @@ -49,6 +49,8 @@ #include "utils.h" #include "src/keysym.h" +#include "tools/tools-common.h" + /* * Test a sequence of keysyms, resulting from a sequence of key presses, * against the keysyms they're supposed to generate. @@ -104,13 +106,16 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap) syms = &sym; } - fprintf(stderr, "op %-6s got %u syms for keycode %3u: [", opstr, nsyms, kc); - if (op == DOWN || op == BOTH) xkb_state_update_key(state, kc, XKB_KEY_DOWN); if (op == UP || op == BOTH) xkb_state_update_key(state, kc, XKB_KEY_UP); +#if HAVE_TOOLS + tools_print_keycode_state("", state, NULL, kc, XKB_CONSUMED_MODE_XKB, PRINT_ALL_FIELDS); +#endif + fprintf(stderr, "op %-6s got %u syms for keycode %3u: [", opstr, nsyms, kc); + for (i = 0; i < nsyms; i++) { keysym = va_arg(ap, int); xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf));