From e9af0690cc7aeb82b11c0c1cde172d1f03e051db Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 14 Feb 2024 11:15:35 +1000 Subject: [PATCH] test: improve debugging output for test_key_seq Print the op too to make it easier to find which part in a long test_key_seq triggered an assertion and add some whitespace for nicer debugging output. --- test/common.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/common.c b/test/common.c index 24d2ca6a1..949539ff2 100644 --- a/test/common.c +++ b/test/common.c @@ -78,6 +78,7 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap) xkb_keysym_t sym; unsigned int nsyms, i; char ksbuf[XKB_KEYSYM_NAME_MAX_SIZE]; + const char *opstr = NULL; fprintf(stderr, "----\n"); @@ -88,13 +89,22 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap) kc = va_arg(ap, int) + EVDEV_OFFSET; op = va_arg(ap, int); + switch (op) { + case DOWN: opstr = "DOWN"; break; + case REPEAT: opstr = "REPEAT"; break; + case UP: opstr = "UP"; break; + case BOTH: opstr = "BOTH"; break; + case NEXT: opstr = "NEXT"; break; + case FINISH: opstr = "FINISH"; break; + } + nsyms = xkb_state_key_get_syms(state, kc, &syms); if (nsyms == 1) { sym = xkb_state_key_get_one_sym(state, kc); syms = &sym; } - fprintf(stderr, "got %u syms for keycode %u: [", nsyms, kc); + 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); @@ -108,15 +118,15 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap) if (keysym == FINISH || keysym == NEXT) { xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf)); - fprintf(stderr, "Did not expect keysym: %s.\n", ksbuf); + fprintf(stderr, " Did not expect keysym: %s.\n", ksbuf); goto fail; } if (keysym != syms[i]) { xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf)); - fprintf(stderr, "Expected keysym: %s. ", ksbuf);; + fprintf(stderr, " Expected keysym: %s. ", ksbuf);; xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf)); - fprintf(stderr, "Got keysym: %s.\n", ksbuf);; + fprintf(stderr, " Got keysym: %s.\n", ksbuf);; goto fail; } } @@ -125,7 +135,7 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap) keysym = va_arg(ap, int); if (keysym != XKB_KEY_NoSymbol) { xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf)); - fprintf(stderr, "Expected %s, but got no keysyms.\n", ksbuf); + fprintf(stderr, " Expected %s, but got no keysyms.\n", ksbuf); goto fail; } }