Commit 4d7600bd0c85e9265be406e27f937fc37114f50f

Daniel Stone 2013-03-19T10:59:38

test: Add va_list variant of test_key_seq For use when chaining tests. Signed-off-by: Daniel Stone <daniel@fooishbar.org>

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);