Test compiler to simulate xkbcomp usage Added a test program, rulescomp, which takes a RMLVO set and generates a XkbcDescPtr. This is essentially what the xserver will do, except that we still need to access some xkbcomp internal API to make it work.
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/test/.gitignore b/test/.gitignore
index ddf7b39..1f8f4a2 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1 +1,2 @@
+rulescomp
xkey
diff --git a/test/Makefile.am b/test/Makefile.am
index 18ac375..4e35e12 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,9 +1,13 @@
INCLUDES = -I$(top_srcdir)/include
AM_CFLAGS = $(X11_CFLAGS) $(CWARNFLAGS)
-check_PROGRAMS = xkey
+TESTS_ENVIRONMENT = $(SHELL)
+
+check_PROGRAMS = xkey rulescomp
+TESTS = xkey.sh rulescomp.sh
+
xkey_SOURCES = xkey.c
xkey_LDADD = $(top_builddir)/src/libxkbcommon.la
-TESTS = xkey.sh
-TESTS_ENVIRONMENT = $(SHELL)
+rulescomp_SOURCES = rulescomp.c
+rulescomp_LDADD = $(top_builddir)/src/libxkbcommon.la
diff --git a/test/rulescomp.c b/test/rulescomp.c
new file mode 100644
index 0000000..5a54d74
--- /dev/null
+++ b/test/rulescomp.c
@@ -0,0 +1,68 @@
+/*
+Copyright 2009 Dan Nicholson
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or their
+institutions shall not be used in advertising or otherwise to promote the
+sale, use or other dealings in this Software without prior written
+authorization from the authors.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include "X11/extensions/XKBcommon.h"
+#include <X11/extensions/XKBstrcommon.h>
+#include "../src/xkbcomp/utils.h"
+#include "../src/xkbcomp/xkbpath.h"
+
+int main(int argc, char *argv[])
+{
+ int i;
+ char *rules = NULL;
+ XkbRF_VarDefsRec defs;
+ XkbcDescPtr xkb;
+
+ /* Require rmlvo */
+ if (argc < 6) {
+ fprintf(stderr, "Not enough arguments\n");
+ fprintf(stderr, "Usage: %s RULES MODEL LAYOUT VARIANT OPTIONS\n",
+ argv[0]);
+ exit(1);
+ }
+
+ rules = argv[1];
+ defs.model = argv[2];
+ defs.layout = argv[3];
+ defs.variant = argv[4];
+ defs.options = argv[5];
+
+ uSetErrorFile(NULL);
+ XkbInitIncludePath();
+ XkbAddDefaultDirectoriesToPath();
+ XkbcInitAtoms();
+
+ xkb = XkbcCompileKeymapFromRules(rules, &defs);
+
+ if (!xkb) {
+ fprintf(stderr, "Failed to compile keymap\n");
+ exit(1);
+ }
+
+ return 0;
+}
diff --git a/test/rulescomp.sh b/test/rulescomp.sh
new file mode 100755
index 0000000..5a5742e
--- /dev/null
+++ b/test/rulescomp.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+srcdir=${srcdir-.}
+builddir=${builddir-.}
+
+compile()
+{
+ ${builddir}/rulescomp "$1" "$2" "$3" "$4" "$5" || exit $?
+}
+
+compile base pc105 us "" ""
+compile evdev pc105 us intl ""
+compile evdev pc105 us intl grp:alts_toggle