test: untangle print-compiled-keymap from the test headers Commit 16c84cdd819db516fff089c76b99248fb7dd4e8c removed the getopt handling for RMLVO arguments, so now this tool only takes a keymap file and compiles it. Using test helpers to init the context gives it fairly specific behavior; unless the user sets the right environment variables and/or calls it from the right PWD, it may or may not include the test data. Let's drop this behavior, make it a default tool to compile a keymap. If there is a specific need to modify the include paths, we can add this later. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
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
diff --git a/test/print-compiled-keymap.c b/test/print-compiled-keymap.c
index bda33fd..e595ab1 100644
--- a/test/print-compiled-keymap.c
+++ b/test/print-compiled-keymap.c
@@ -23,9 +23,11 @@
#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
-#include "test.h"
+#include "xkbcommon/xkbcommon.h"
int
main(int argc, char *argv[])
@@ -35,6 +37,7 @@ main(int argc, char *argv[])
struct xkb_context *ctx = NULL;
struct xkb_keymap *keymap = NULL;
const char *keymap_path = NULL;
+ FILE *file = NULL;
char *dump;
while ((opt = getopt(argc, argv, "h")) != -1) {
@@ -53,13 +56,20 @@ main(int argc, char *argv[])
keymap_path = argv[optind];
- ctx = test_get_context(0);
+ ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!ctx) {
fprintf(stderr, "Couldn't create xkb context\n");
goto out;
}
- keymap = test_compile_file(ctx, keymap_path);
+ file = fopen(keymap_path, "rb");
+ if (!file) {
+ fprintf(stderr, "Failed to open path: %s\n", keymap_path);
+ goto out;
+ }
+
+ keymap = xkb_keymap_new_from_file(ctx, file,
+ XKB_KEYMAP_FORMAT_TEXT_V1, 0);
if (!keymap) {
fprintf(stderr, "Couldn't create xkb keymap\n");
goto out;
@@ -76,6 +86,8 @@ main(int argc, char *argv[])
ret = EXIT_SUCCESS;
free(dump);
out:
+ if (file)
+ fclose(file);
xkb_keymap_unref(keymap);
xkb_context_unref(ctx);
return ret;