Add test_unit to all tests

Currently it only ensure we do not buffer `stdout`.
master
Pierre Le Marre 2024-02-20 08:13:37 +01:00 committed by Wismill
parent e7570bcb78
commit e325e65eb8
23 changed files with 55 additions and 2 deletions

View File

@ -156,6 +156,8 @@ main(void)
struct atom_table *table;
xkb_atom_t atom1, atom2, atom3;
test_init();
table = atom_table_new();
assert(table);

View File

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

View File

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

View File

@ -942,6 +942,8 @@ main(int argc, char *argv[])
{
struct xkb_context *ctx;
test_init();
ctx = test_get_context(CONTEXT_NO_FLAG);
assert(ctx);

View File

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

View File

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

View File

@ -233,6 +233,8 @@ test_multiple_keysyms_per_level(void)
int
main(void)
{
test_init();
test_garbage_key();
test_keymap();
test_numeric_keysyms();

View File

@ -29,6 +29,8 @@
int
main(void)
{
test_init();
struct xkb_context *ctx = test_get_context(0);
struct xkb_keymap *keymap;

View File

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

View File

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

View File

@ -59,5 +59,7 @@ test_message_get(void)
int
main(void)
{
test_init();
test_message_get();
}

View File

@ -154,6 +154,8 @@ test_modmap_none(void)
int
main(void)
{
test_init();
test_modmap_none();
return 0;

View File

@ -1068,6 +1068,8 @@ test_invalid_include(void)
int
main(void)
{
test_init();
test_no_include_paths();
test_invalid_include();
test_load_basic();

View File

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

View File

@ -91,6 +91,8 @@ main(int argc, char *argv[])
{
struct xkb_context *ctx;
test_init();
ctx = test_get_context(0);
assert(ctx);

View File

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

View File

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

View File

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

View File

@ -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

View File

@ -29,6 +29,7 @@
#include <stddef.h>
#include <string.h>
#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();

View File

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

View File

@ -86,5 +86,7 @@ err_conn:
}
int main(void) {
test_init();
return x11_tests_run();
}

View File

@ -117,5 +117,7 @@ err_conn:
}
int main(void) {
test_init();
return x11_tests_run();
}