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.
master
Peter Hutterer 2024-02-14 11:15:35 +10:00
parent 883bac60d8
commit be1c2f27ce
1 changed files with 15 additions and 5 deletions

View File

@ -78,6 +78,7 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap)
xkb_keysym_t sym; xkb_keysym_t sym;
unsigned int nsyms, i; unsigned int nsyms, i;
char ksbuf[XKB_KEYSYM_NAME_MAX_SIZE]; char ksbuf[XKB_KEYSYM_NAME_MAX_SIZE];
const char *opstr = NULL;
fprintf(stderr, "----\n"); 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; kc = va_arg(ap, int) + EVDEV_OFFSET;
op = va_arg(ap, int); 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); nsyms = xkb_state_key_get_syms(state, kc, &syms);
if (nsyms == 1) { if (nsyms == 1) {
sym = xkb_state_key_get_one_sym(state, kc); sym = xkb_state_key_get_one_sym(state, kc);
syms = &sym; 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) if (op == DOWN || op == BOTH)
xkb_state_update_key(state, kc, XKB_KEY_DOWN); 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) { if (keysym == FINISH || keysym == NEXT) {
xkb_keysym_get_name(syms[i], ksbuf, sizeof(ksbuf)); 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; goto fail;
} }
if (keysym != syms[i]) { if (keysym != syms[i]) {
xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf)); 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)); 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; goto fail;
} }
} }
@ -125,7 +135,7 @@ test_key_seq_va(struct xkb_keymap *keymap, va_list ap)
keysym = va_arg(ap, int); keysym = va_arg(ap, int);
if (keysym != XKB_KEY_NoSymbol) { if (keysym != XKB_KEY_NoSymbol) {
xkb_keysym_get_name(keysym, ksbuf, sizeof(ksbuf)); 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; goto fail;
} }
} }