test: Add va_list variant of test_key_seq For use when chaining tests. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/test/common.c b/test/common.c
index 2ea2e5b..6d6f25e 100644
--- a/test/common.c
+++ b/test/common.c
@@ -55,11 +55,10 @@
* See below for examples.
*/
int
-test_key_seq(struct xkb_keymap *keymap, ...)
+test_key_seq_va(struct xkb_keymap *keymap, va_list ap)
{
struct xkb_state *state;
- va_list ap;
xkb_keycode_t kc;
int op;
xkb_keysym_t keysym;
@@ -73,8 +72,6 @@ test_key_seq(struct xkb_keymap *keymap, ...)
state = xkb_state_new(keymap);
assert(state);
- va_start(ap, keymap);
-
for (;;) {
kc = va_arg(ap, int) + EVDEV_OFFSET;
op = va_arg(ap, int);
@@ -120,16 +117,27 @@ test_key_seq(struct xkb_keymap *keymap, ...)
goto fail;
}
- va_end(ap);
xkb_state_unref(state);
return 1;
fail:
- va_end(ap);
xkb_state_unref(state);
return 0;
}
+int
+test_key_seq(struct xkb_keymap *keymap, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, keymap);
+ ret = test_key_seq_va(keymap, ap);
+ va_end(ap);
+
+ return ret;
+}
+
const char *
test_get_path(const char *path_rel)
{
diff --git a/test/test.h b/test/test.h
index d3e3f62..c39ef8d 100644
--- a/test/test.h
+++ b/test/test.h
@@ -46,6 +46,9 @@ enum key_seq_state {
int
test_key_seq(struct xkb_keymap *keymap, ...);
+int
+test_key_seq_va(struct xkb_keymap *keymap, va_list args);
+
const char *
test_get_path(const char *path_rel);