diff --git a/test/atom.c b/test/atom.c index a2f7541d..b181a222 100644 --- a/test/atom.c +++ b/test/atom.c @@ -156,6 +156,8 @@ main(void) struct atom_table *table; xkb_atom_t atom1, atom2, atom3; + test_init(); + table = atom_table_new(); assert(table); diff --git a/test/buffercomp.c b/test/buffercomp.c index f1117639..fe6037b4 100644 --- a/test/buffercomp.c +++ b/test/buffercomp.c @@ -169,6 +169,8 @@ test_recursive(void) int main(int argc, char *argv[]) { + test_init(); + struct xkb_context *ctx = test_get_context(0); struct xkb_keymap *keymap; char *original, *dump; diff --git a/test/common.c b/test/common.c index 16e96efd..392aacd4 100644 --- a/test/common.c +++ b/test/common.c @@ -51,6 +51,15 @@ #include "tools/tools-common.h" + +/* Setup test */ +void +test_init(void) +{ + /* Make stdout always unbuffered, to ensure we always get it entirely */ + setbuf(stdout, NULL); +} + /* * Test a sequence of keysyms, resulting from a sequence of key presses, * against the keysyms they're supposed to generate. @@ -298,8 +307,6 @@ test_get_context(enum test_context_flags test_flags) struct xkb_context *ctx; char *path; - setbuf(stdout, NULL); - ctx_flags = XKB_CONTEXT_NO_DEFAULT_INCLUDES; if (test_flags & CONTEXT_ALLOW_ENVIRONMENT_NAMES) { unsetenv("XKB_DEFAULT_RULES"); diff --git a/test/compose.c b/test/compose.c index d6c88e09..3a017f1b 100644 --- a/test/compose.c +++ b/test/compose.c @@ -942,6 +942,8 @@ main(int argc, char *argv[]) { struct xkb_context *ctx; + test_init(); + ctx = test_get_context(CONTEXT_NO_FLAG); assert(ctx); diff --git a/test/context.c b/test/context.c index bb619b00..cf6168ff 100644 --- a/test/context.c +++ b/test/context.c @@ -290,6 +290,8 @@ test_include_order(void) int main(void) { + test_init(); + struct xkb_context *context = test_get_context(0); xkb_atom_t atom; diff --git a/test/filecomp.c b/test/filecomp.c index 116ffe80..b21dc897 100644 --- a/test/filecomp.c +++ b/test/filecomp.c @@ -40,6 +40,8 @@ test_file(struct xkb_context *ctx, const char *path_rel) int main(void) { + test_init(); + struct xkb_context *ctx = test_get_context(0); assert(test_file(ctx, "keymaps/basic.xkb")); diff --git a/test/keymap.c b/test/keymap.c index 73d2a618..7b02bd94 100644 --- a/test/keymap.c +++ b/test/keymap.c @@ -233,6 +233,8 @@ test_multiple_keysyms_per_level(void) int main(void) { + test_init(); + test_garbage_key(); test_keymap(); test_numeric_keysyms(); diff --git a/test/keyseq.c b/test/keyseq.c index d245d50b..53de4232 100644 --- a/test/keyseq.c +++ b/test/keyseq.c @@ -29,6 +29,8 @@ int main(void) { + test_init(); + struct xkb_context *ctx = test_get_context(0); struct xkb_keymap *keymap; diff --git a/test/keysym.c b/test/keysym.c index 5e3115a2..70611469 100644 --- a/test/keysym.c +++ b/test/keysym.c @@ -298,6 +298,8 @@ test_utf32_to_keysym(uint32_t ucs, xkb_keysym_t expected) int main(void) { + test_init(); + /* Bounds */ assert(XKB_KEYSYM_MIN == 0); assert(XKB_KEYSYM_MIN < XKB_KEYSYM_MAX); diff --git a/test/log.c b/test/log.c index 0bdb6927..e23ec34d 100644 --- a/test/log.c +++ b/test/log.c @@ -75,6 +75,8 @@ main(void) struct xkb_context *ctx; int ret; + test_init(); + ret = setenv("XKB_LOG_LEVEL", "warn", 1); assert(ret == 0); ret = setenv("XKB_LOG_VERBOSITY", "5", 1); diff --git a/test/messages.c b/test/messages.c index b272a093..a80aa3c5 100644 --- a/test/messages.c +++ b/test/messages.c @@ -59,5 +59,7 @@ test_message_get(void) int main(void) { + test_init(); + test_message_get(); } diff --git a/test/modifiers.c b/test/modifiers.c index 807c0153..e44d20c8 100644 --- a/test/modifiers.c +++ b/test/modifiers.c @@ -154,6 +154,8 @@ test_modmap_none(void) int main(void) { + test_init(); + test_modmap_none(); return 0; diff --git a/test/registry.c b/test/registry.c index a3993e8d..75efa834 100644 --- a/test/registry.c +++ b/test/registry.c @@ -1068,6 +1068,8 @@ test_invalid_include(void) int main(void) { + test_init(); + test_no_include_paths(); test_invalid_include(); test_load_basic(); diff --git a/test/rules-file-includes.c b/test/rules-file-includes.c index 17438fd9..86750aeb 100644 --- a/test/rules-file-includes.c +++ b/test/rules-file-includes.c @@ -93,6 +93,8 @@ main(int argc, char *argv[]) { struct xkb_context *ctx; + test_init(); + setenv("XKB_CONFIG_ROOT", TEST_XKB_CONFIG_ROOT, 1); ctx = test_get_context(0); diff --git a/test/rules-file.c b/test/rules-file.c index 726ec89b..bd2f9bdd 100644 --- a/test/rules-file.c +++ b/test/rules-file.c @@ -91,6 +91,8 @@ main(int argc, char *argv[]) { struct xkb_context *ctx; + test_init(); + ctx = test_get_context(0); assert(ctx); diff --git a/test/rulescomp.c b/test/rulescomp.c index eddf3066..4933dd88 100644 --- a/test/rulescomp.c +++ b/test/rulescomp.c @@ -110,6 +110,8 @@ test_rmlvo_env(struct xkb_context *ctx, const char *rules, const char *model, int main(int argc, char *argv[]) { + test_init(); + struct xkb_context *ctx = test_get_context(CONTEXT_ALLOW_ENVIRONMENT_NAMES); assert(ctx); diff --git a/test/state.c b/test/state.c index 89dfa7e5..283c4716 100644 --- a/test/state.c +++ b/test/state.c @@ -712,6 +712,8 @@ test_ctrl_string_transformation(struct xkb_keymap *keymap) int main(void) { + test_init(); + struct xkb_context *context = test_get_context(0); struct xkb_keymap *keymap; diff --git a/test/stringcomp.c b/test/stringcomp.c index 03884045..470a56cc 100644 --- a/test/stringcomp.c +++ b/test/stringcomp.c @@ -34,6 +34,8 @@ int main(int argc, char *argv[]) { + test_init(); + struct xkb_context *ctx = test_get_context(0); struct xkb_keymap *keymap; char *original, *dump, *dump2; diff --git a/test/test.h b/test/test.h index 39686063..00043d13 100644 --- a/test/test.h +++ b/test/test.h @@ -44,6 +44,9 @@ assert_printf(streq_not_null(expected, got), \ test_name ". Expected \"%s\", got: \"%s\"\n", expected, got) +void +test_init(void); + /* The offset between KEY_* numbering, and keycodes in the XKB evdev * dataset. */ #define EVDEV_OFFSET 8 diff --git a/test/utf8.c b/test/utf8.c index aa3c0d51..3a224e72 100644 --- a/test/utf8.c +++ b/test/utf8.c @@ -29,6 +29,7 @@ #include #include +#include "test.h" #include "utf8.h" #include "utils.h" @@ -180,6 +181,8 @@ test_utf32_to_utf8(void) int main(void) { + test_init(); + test_is_valid_utf8(); test_utf32_to_utf8(); diff --git a/test/utils.c b/test/utils.c index 052289e6..44442200 100644 --- a/test/utils.c +++ b/test/utils.c @@ -36,6 +36,8 @@ main(void) { char buffer[10]; + test_init(); + assert(!snprintf_safe(buffer, 0, "foo")); assert(!snprintf_safe(buffer, 1, "foo")); assert(!snprintf_safe(buffer, 3, "foo")); diff --git a/test/x11.c b/test/x11.c index 3742a0bd..4ff211e8 100644 --- a/test/x11.c +++ b/test/x11.c @@ -86,5 +86,7 @@ X11_TEST(test_basic) } int main(void) { + test_init(); + return x11_tests_run(); } diff --git a/test/x11comp.c b/test/x11comp.c index d2cc4477..dc70fd15 100644 --- a/test/x11comp.c +++ b/test/x11comp.c @@ -117,5 +117,7 @@ X11_TEST(test_basic) } int main(void) { + test_init(); + return x11_tests_run(); }