MSVC: Provide implementations of [un]setenv()
[platform/upstream/libxkbcommon.git] / test / log.c
index cf59045..384fabc 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include "config.h"
+
 #include "test.h"
 #include "context.h"
 
+#ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wmissing-format-attribute"
+#endif
 
 static const char *
 log_level_to_string(enum xkb_log_level level)
@@ -51,7 +55,7 @@ log_fn(struct xkb_context *ctx, enum xkb_log_level level,
 {
     char *s;
     int size;
-    darray_char *ls = xkb_get_user_data(ctx);
+    darray_char *ls = xkb_context_get_user_data(ctx);
     assert(ls);
 
     size = vasprintf(&s, fmt, args);
@@ -70,16 +74,16 @@ main(void)
     struct xkb_context *ctx;
     int ret;
 
-    ret = setenv("XKB_LOG", "warn", 1);
+    ret = setenv("XKB_LOG_LEVEL", "warn", 1);
     assert(ret == 0);
-    ret = setenv("XKB_VERBOSITY", "5", 1);
+    ret = setenv("XKB_LOG_VERBOSITY", "5", 1);
     assert(ret == 0);
-    ctx = xkb_context_new(0);
+    ctx = test_get_context(0);
     assert(ctx);
 
     darray_init(log_string);
-    xkb_set_user_data(ctx, &log_string);
-    xkb_set_log_fn(ctx, log_fn);
+    xkb_context_set_user_data(ctx, &log_string);
+    xkb_context_set_log_fn(ctx, log_fn);
 
     log_warn(ctx, "first warning: %d\n", 87);
     log_info(ctx, "first info\n");
@@ -87,15 +91,15 @@ main(void)
     log_err(ctx, "first error: %lu\n", 115415UL);
     log_vrb(ctx, 5, "first verbose 5\n");
 
-    xkb_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
+    xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
     log_warn(ctx, "second warning: %d\n", 87);
     log_dbg(ctx, "second debug: %s %s\n", "hello", "world");
     log_info(ctx, "second info\n");
     log_err(ctx, "second error: %lu\n", 115415UL);
     log_vrb(ctx, 6, "second verbose 6\n");
 
-    xkb_set_log_verbosity(ctx, 0);
-    xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
+    xkb_context_set_log_verbosity(ctx, 0);
+    xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
     log_warn(ctx, "third warning: %d\n", 87);
     log_dbg(ctx, "third debug: %s %s\n", "hello", "world");
     log_info(ctx, "third info\n");