.dirstamp
cscope.out
+test-suite.log
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = . test
-
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xkbcommon.pc
src/ks_tables.h: $(KEYSYMDEFS) $(top_builddir)/makekeys/makekeys$(EXEEXT)
$(top_builddir)/makekeys/makekeys $(KEYSYMDEFS) > $@
+
+# Tests
+
+TESTS_ENVIRONMENT =
+
+TESTS = \
+ test/xkey \
+ test/filecomp \
+ test/namescomp \
+ test/rulescomp \
+ test/canonicalise \
+ test/state \
+ test/context
+TESTS_LDADD = libxkbcommon.la
+
+test_xkey_LDADD = $(TESTS_LDADD)
+test_filecomp_LDADD = $(TESTS_LDADD)
+test_namescomp_LDADD = $(TESTS_LDADD)
+test_rulescomp_LDADD = $(TESTS_LDADD)
+test_canonicalise_LDADD = $(TESTS_LDADD)
+test_state_LDADD = $(TESTS_LDADD)
+test_context_LDADD = $(TESTS_LDADD)
+
+check_PROGRAMS = $(TESTS)
+
+EXTRA_DIST = test/data
AC_CONFIG_MACRO_DIR([m4])
# Initialize Automake
-AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
+AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects color-tests parallel-tests])
AM_MAINTAINER_MODE
# Get _GNU_SOURCE and friends
[XKBCONFIGROOT="$xkb_base"])
AC_SUBST([XKBCONFIGROOT])
-AC_CONFIG_FILES([
- Makefile
- test/Makefile
- xkbcommon.pc])
+AC_CONFIG_FILES([Makefile xkbcommon.pc])
AC_OUTPUT
+++ /dev/null
-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src
-AM_CFLAGS = $(X11_CFLAGS) $(XORG_COMPILER_FLAGS)
-LDADD = $(top_builddir)/libxkbcommon.la
-
-TESTS_ENVIRONMENT = $(SHELL)
-
-check_PROGRAMS = xkey filecomp namescomp rulescomp canonicalise state context
-TESTS = $(check_PROGRAMS:=.sh)
-
-EXTRA_DIST = \
- $(TESTS) \
- bad.xkb \
- basic.xkb \
- default.xkb \
- comprehensive-plus-geom.xkb
-
-clean-local:
- rm -f *.log
* Author: Daniel Stone <daniel@fooishbar.org>
*/
-#include "xkbcommon/xkbcommon.h"
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-int main(int argc, char *argv[])
+#include "xkbcommon/xkbcommon.h"
+
+struct test_data {
+ struct xkb_component_names new;
+ struct xkb_component_names old;
+ int pass_old;
+ const char *exp_keycodes;
+ const char *exp_compat;
+ const char *exp_symbols;
+ const char *exp_types;
+};
+
+static struct test_data *
+new_data(void)
+{
+ return calloc(1, sizeof(struct test_data));
+}
+
+static void
+free_data(struct test_data *data)
{
- struct xkb_component_names *new, *old = NULL;
-
- if (argc != 5 && argc != 9) {
- fprintf(stderr, "usage: canonicalise (new kccgst) [old kccgst]\n");
- return 1;
- }
-
-
- new = calloc(1, sizeof(*new));
- if (!new) {
- fprintf(stderr, "failed to calloc new\n");
- return 1;
- }
- new->keycodes = strdup(argv[1]);
- new->compat = strdup(argv[2]);
- new->symbols = strdup(argv[3]);
- new->types = strdup(argv[4]);
-
- if (argc == 9) {
- old = calloc(1, sizeof(*old));
- if (!old) {
- fprintf(stderr, "failed to calloc old\n");
- return 1;
- }
- old->keycodes = strdup(argv[5]);
- old->compat = strdup(argv[6]);
- old->symbols = strdup(argv[7]);
- old->types = strdup(argv[8]);
- }
-
- xkb_canonicalise_components(new, old);
-
- printf("%s %s %s %s\n", new->keycodes, new->compat, new->symbols, new->types);
-
- free(new->keycodes);
- free(new->compat);
- free(new->symbols);
- free(new->types);
- free(new);
-
- if (old) {
- free(old->keycodes);
- free(old->compat);
- free(old->symbols);
- free(old->types);
- free(old);
- }
+ free(data->new.keycodes);
+ free(data->new.compat);
+ free(data->new.symbols);
+ free(data->new.types);
+ free(data->old.keycodes);
+ free(data->old.compat);
+ free(data->old.symbols);
+ free(data->old.types);
+ free(data);
+}
+
+static void
+set_new(struct test_data *data, const char *keycodes, const char *compat,
+ const char *symbols, const char *types)
+{
+ data->new.keycodes = strdup(keycodes);
+ data->new.compat = strdup(compat);
+ data->new.symbols = strdup(symbols);
+ data->new.types = strdup(types);
+}
+
+static void
+set_old(struct test_data *data, const char *keycodes, const char *compat,
+ const char *symbols, const char *types)
+{
+ data->old.keycodes = strdup(keycodes);
+ data->old.compat = strdup(compat);
+ data->old.symbols = strdup(symbols);
+ data->old.types = strdup(types);
+ data->pass_old = 1;
+}
+
+static void
+set_exp(struct test_data *data, const char *keycodes, const char *compat,
+ const char *symbols, const char *types)
+{
+ data->exp_keycodes = keycodes;
+ data->exp_compat = compat;
+ data->exp_symbols = symbols;
+ data->exp_types = types;
+}
+
+static int
+test_canonicalise(struct test_data *data)
+{
+ fprintf(stderr, "New: %s %s %s %s\n", data->new.keycodes,
+ data->new.compat, data->new.symbols, data->new.types);
+ if (data->pass_old)
+ fprintf(stderr, "Old: %s %s %s %s\n", data->old.keycodes,
+ data->old.compat, data->old.symbols, data->old.types);
+ fprintf(stderr, "Expected: %s %s %s %s\n", data->exp_keycodes,
+ data->exp_compat, data->exp_symbols, data->exp_types);
+
+ if (data->pass_old)
+ xkb_canonicalise_components(&data->new, &data->old);
+ else
+ xkb_canonicalise_components(&data->new, NULL);
+
+ fprintf(stderr, "Received: %s %s %s %s\n\n", data->new.keycodes,
+ data->new.compat, data->new.symbols, data->new.types);
+
+ return (strcmp(data->new.keycodes, data->exp_keycodes) == 0) &&
+ (strcmp(data->new.compat, data->exp_compat) == 0) &&
+ (strcmp(data->new.symbols, data->exp_symbols) == 0) &&
+ (strcmp(data->new.types, data->exp_types) == 0);
+}
+
+int
+main(void)
+{
+ struct test_data *twopart, *onepart;
+
+ twopart = new_data();
+ set_new(twopart, "+inet(pc104)", "%+complete", "pc(pc104)+%+ctrl(nocaps)", "|complete");
+ set_old(twopart, "xfree86", "basic", "us(dvorak)", "xfree86");
+ set_exp(twopart, "xfree86+inet(pc104)", "basic+complete", "pc(pc104)+us(dvorak)+ctrl(nocaps)", "xfree86|complete");
+ assert(test_canonicalise(twopart));
+ free_data(twopart);
+
+ onepart = new_data();
+ set_new(onepart, "evdev", "complete", "pc(pc104)+us+compose(ralt)", "complete");
+ set_exp(onepart, "evdev", "complete", "pc(pc104)+us+compose(ralt)", "complete");
+ assert(test_canonicalise(onepart));
+ free_data(onepart);
return 0;
}
+++ /dev/null
-#!/bin/sh -x
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=canonicalise
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-log_kccgst()
-{
- echo " keycodes: $1" >>"$log"
- echo " compat: $2" >>"$log"
- echo " symbols: $3" >>"$log"
- echo " types: $4" >>"$log"
-}
-
-rm -f "$log"
-
-test() {
- ret=`$prog $2 $3`
- echo "Input (new):" >>"$log"
- log_kccgst $2
- echo >>"$log"
- echo "Input (old):" >>"$log"
- log_kccgst $3
- echo >>"$log"
- echo "Expecting:" >>"$log"
- log_kccgst $1
- echo >>"$log"
- echo "Received:" >>"$log"
- log_kccgst $ret
- echo >>"$log"
-
- ret=`echo "$ret" | sed -e 's/[ ]*/ /g;'`
- exp=`echo "$1" | sed -e 's/[ ]*/ /g;'`
-
- if ! [ "$ret" = "$exp" ]; then
- echo "Error: Return and expectations different" >>"$log"
- exit 1
- fi
-}
-
-# This is a bit of a horror, but I can't really remember how to properly
-# handle arrays in shell, and I'm offline.
-twopart_new="+inet(pc104) %+complete pc(pc104)+%+ctrl(nocaps) |complete"
-twopart_old="xfree86 basic us(dvorak) xfree86"
-twopart_exp="xfree86+inet(pc104) basic+complete pc(pc104)+us(dvorak)+ctrl(nocaps) xfree86|complete"
-
-onepart_new="evdev complete pc(pc104)+us+compose(ralt) complete"
-onepart_exp="evdev complete pc(pc104)+us+compose(ralt) complete"
-
-test "$twopart_exp" "$twopart_new" "$twopart_old"
-echo >>"$log"
-echo >>"$log"
-test "$onepart_exp" "$onepart_new"
*/
#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <X11/keysym.h>
-#include <linux/input.h>
+
#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
-#include "XKBcommonint.h"
int
-main(int argc, char *argv[])
+main(void)
{
struct xkb_context *context = xkb_context_new();
+++ /dev/null
-#!/bin/sh
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=context
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-rm -f "$log"
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-$builddir/$name$EXEEXT >> $log 2>&1
authorization from the authors.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <errno.h>
#include <fcntl.h>
-#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
-static char buffer[8192];
+#include "xkbcommon/xkbcommon.h"
-int main(int argc, char *argv[])
+static int
+test_file(const char *path)
{
+ int fd;
struct xkb_context *context;
struct xkb_keymap *xkb;
- char *path;
- int fd;
- int i, len, from_string = 0;
-
- /* Require xkb file */
- if (argc < 2) {
- fprintf(stderr, "Not enough arguments\n");
- fprintf(stderr, "Usage: %s [-s] XKBFILE\n",
- argv[0]);
- exit(1);
- }
-
- i = 1;
- if (strcmp(argv[1], "-s") == 0) {
- from_string = 2;
- i++;
- }
-
- path = argv[i];
fd = open(path, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "Failed to open file \"%s\": %s\n", path,
- strerror(errno));
- exit(1);
- }
+ assert(fd >= 0);
context = xkb_context_new();
assert(context);
- if (from_string) {
- len = read(fd, buffer, sizeof(buffer));
- buffer[len] = '\0';
- xkb = xkb_map_new_from_string(context, buffer,
- XKB_KEYMAP_FORMAT_TEXT_V1);
- } else {
- xkb = xkb_map_new_from_fd(context, fd,
- XKB_KEYMAP_FORMAT_TEXT_V1);
- }
+ fprintf(stderr, "\nCompiling path: %s\n", path);
+
+ xkb = xkb_map_new_from_fd(context, fd, XKB_KEYMAP_FORMAT_TEXT_V1);
close(fd);
if (!xkb) {
fprintf(stderr, "Failed to compile keymap\n");
xkb_context_unref(context);
- exit(1);
+ return 0;
}
xkb_map_unref(xkb);
xkb_context_unref(context);
+ return 1;
+}
+
+static int
+test_file_name(const char *file_name)
+{
+ static char path[PATH_MAX];
+ const char *srcdir = getenv("srcdir");
+
+ snprintf(path, PATH_MAX - 1, "%s/test/data/%s", srcdir ? srcdir : ".", file_name);
+ return test_file(path);
+}
+
+static int
+test_string(const char *string)
+{
+ struct xkb_context *context;
+ struct xkb_keymap *xkb;
+
+ context = xkb_context_new();
+ assert(context);
+
+ fprintf(stderr, "\nCompiling string\n");
+
+ xkb = xkb_map_new_from_string(context, string, XKB_KEYMAP_FORMAT_TEXT_V1);
+ if (!xkb) {
+ xkb_context_unref(context);
+ return 0;
+ }
+
+ xkb_map_unref(xkb);
+ xkb_context_unref(context);
+ return 1;
+}
+
+int
+main(void)
+{
+
+ assert(test_file_name("basic.xkb"));
+ /* XXX check we actually get qwertz here ... */
+ assert(test_file_name("default.xkb"));
+ assert(test_file_name("comprehensive-plus-geom.xkb"));
+
+ assert(!test_file_name("bad.xkb"));
+
+ assert(!test_string(""));
return 0;
}
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
+
#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
-int main(int argc, char *argv[])
+static int
+test_names(const char *keycodes, const char *types,
+ const char *compat, const char *symbols)
{
+ int ret = 1;
struct xkb_context *context;
struct xkb_keymap *xkb;
- struct xkb_component_names kccgst;
-
- /* Require Kc + T + C + S */
- if (argc < 5) {
- fprintf(stderr, "Not enough arguments\n");
- fprintf(stderr, "Usage: %s KEYCODES TYPES COMPAT SYMBOLS\n",
- argv[0]);
- exit(1);
- }
-
- kccgst.keymap = NULL;
- kccgst.keycodes = argv[1];
- kccgst.types = argv[2];
- kccgst.compat = argv[3];
- kccgst.symbols = argv[4];
+ struct xkb_component_names kccgst = {
+ .keymap = NULL,
+ .keycodes = strdup(keycodes),
+ .types = strdup(types),
+ .compat = strdup(compat),
+ .symbols = strdup(symbols),
+ };
context = xkb_context_new();
assert(context);
- xkb = xkb_map_new_from_kccgst(context, &kccgst);
+ fprintf(stderr, "\nCompiling %s %s %s %s\n", kccgst.keycodes, kccgst.types,
+ kccgst.compat, kccgst.symbols);
+ xkb = xkb_map_new_from_kccgst(context, &kccgst);
if (!xkb) {
- fprintf(stderr, "Failed to compile keymap\n");
- xkb_context_unref(context);
- exit(1);
+ ret = 0;
+ goto err_ctx;
}
xkb_map_unref(xkb);
+err_ctx:
xkb_context_unref(context);
+ free(kccgst.keycodes);
+ free(kccgst.types);
+ free(kccgst.compat);
+ free(kccgst.symbols);
+ return ret;
+}
+
+int
+main(void)
+{
+ assert(test_names("xfree86+aliases(qwertz)", "complete", "complete", "pc+de"));
+ assert(test_names("xfree86+aliases(qwerty)", "complete", "complete", "pc+us"));
+ assert(test_names("xfree86+aliases(qwertz)", "complete", "complete",
+ "pc+de+level3(ralt_switch_for_alts_toggle)+group(alts_toggle)"));
+
+ assert(!test_names("", "", "", ""));
+ assert(!test_names("xfree86+aliases(qwerty)", "", "", ""));
+ assert(!test_names("xfree86+aliases(qwertz)", "", "", "pc+de"));
+ assert(!test_names("xfree86+aliases(qwertz)", "complete", "", "pc+de"));
+ assert(!test_names("xfree86+aliases(qwertz)", "", "complete", "pc+de"));
+ assert(!test_names("xfree86+aliases(qwertz)", "complete", "complete", ""));
+ assert(!test_names("badnames", "complete", "pc+us", "pc(pc101)"));
return 0;
}
+++ /dev/null
-#!/bin/sh
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=namescomp
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-compile()
-{
- echo "$prog '$1' '$2' '$3' '$4'" >>"$log"
- $prog "$1" "$2" "$3" "$4" >>"$log" 2>&1 || exit $?
-}
-
-failcompile()
-{
- echo "$prog '$1' '$2' '$3' '$4'" >>"$log"
- if $prog "$1" "$2" "$3" "$4" >>"$log" 2>&1; then
- exit 1
- fi
-}
-
-rm -f "$log"
-
-compile "xfree86+aliases(qwertz)" "complete" "complete" "pc+de"
-compile "xfree86+aliases(qwerty)" "complete" "complete" "pc+us"
-compile "xfree86+aliases(qwertz)" "complete" "complete" \
- "pc+de+level3(ralt_switch_for_alts_toggle)+group(alts_toggle)"
-
-failcompile "" "" "" ""
-failcompile "xfree86+aliases(qwerty)" "" "" ""
-failcompile "xfree86+aliases(qwertz)" "" "" "pc+de"
-failcompile "xfree86+aliases(qwertz)" "complete" "" "pc+de"
-failcompile "xfree86+aliases(qwertz)" "" "complete" "pc+de"
-failcompile "xfree86+aliases(qwertz)" "complete" "complete" ""
-failcompile "badnames" "complete" "pc+us" "pc(pc101)"
*/
#include <assert.h>
-#include <stdlib.h>
#include <stdio.h>
-#include <X11/Xdefs.h>
+
#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
-int main(int argc, char *argv[])
+static int
+test_rmlvo(const char *rules, const char *model, const char *layout,
+ const char *variant, const char *options)
{
struct xkb_context *context;
struct xkb_keymap *xkb;
- struct xkb_rule_names rmlvo;
-
- /* 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);
- }
-
- rmlvo.rules = argv[1];
- rmlvo.model = argv[2];
- rmlvo.layout = argv[3];
- rmlvo.variant = argv[4];
- rmlvo.options = argv[5];
+ struct xkb_rule_names rmlvo = {
+ .rules = rules,
+ .model = model,
+ .layout = layout,
+ .variant = variant,
+ .options = options
+ };
context = xkb_context_new();
assert(context);
- xkb = xkb_map_new_from_names(context, &rmlvo);
+ fprintf(stderr, "\nCompiling %s %s %s %s %s\n", rmlvo.rules, rmlvo.model,
+ rmlvo.layout, rmlvo.variant, rmlvo.options);
+ xkb = xkb_map_new_from_names(context, &rmlvo);
if (!xkb) {
- fprintf(stderr, "Failed to compile keymap\n");
xkb_context_unref(context);
- exit(1);
+ return 0;
}
xkb_map_unref(xkb);
xkb_context_unref(context);
+ return 1;
+}
+
+int
+main(void)
+{
+ assert(test_rmlvo("base", "pc105", "us", "", ""));
+ assert(test_rmlvo("base", "", "us", "", ""));
+ assert(test_rmlvo("evdev", "pc105", "us", "intl", ""));
+ assert(test_rmlvo("evdev", "pc105", "us", "intl", "grp:alts_toggle"));
+
+ assert(!test_rmlvo("", "", "", "", ""));
+ assert(!test_rmlvo("base", "", "", "", ""));
+ assert(!test_rmlvo("base", "pc105", "", "", ""));
+ assert(!test_rmlvo("badrules", "", "us", "", ""));
return 0;
}
+++ /dev/null
-#!/bin/sh
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=rulescomp
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-compile()
-{
- echo "$prog '$1' '$2' '$3' '$4' '$5'" >>"$log"
- $prog "$1" "$2" "$3" "$4" "$5" >>"$log" 2>&1 || exit $?
-}
-
-failcompile()
-{
- echo "$prog '$1' '$2' '$3' '$4' '$5'" >>"$log"
- if $prog "$1" "$2" "$3" "$4" "$5" >>"$log" 2>&1; then
- exit 1
- fi
-}
-
-rm -f "$log"
-
-compile base pc105 us "" ""
-compile base "" us "" ""
-compile evdev pc105 us intl ""
-compile evdev pc105 us intl grp:alts_toggle
-
-failcompile "" "" "" "" "" ""
-failcompile base "" "" "" "" ""
-failcompile base pc105 "" "" "" ""
-failcompile badrules "" us "" "" ""
#include <stdlib.h>
#include <X11/keysym.h>
#include <linux/input.h>
+
#include "xkbcommon/xkbcommon.h"
-#include "utils.h"
#include "XKBcommonint.h"
/* Offset between evdev keycodes (where KEY_ESCAPE is 1), and the evdev XKB
test_update_key(struct xkb_keymap *xkb)
{
struct xkb_state *state = xkb_state_new(xkb);
- xkb_keysym_t *syms;
+ const xkb_keysym_t *syms;
int num_syms;
assert(state);
}
int
-main(int argc, char *argv[])
+main(void)
{
struct xkb_context *context;
struct xkb_keymap *xkb;
- struct xkb_rule_names rmlvo;
-
- rmlvo.rules = "evdev";
- rmlvo.model = "pc104";
- rmlvo.layout = "us";
- rmlvo.variant = NULL;
- rmlvo.options = NULL;
+ struct xkb_rule_names rmlvo = {
+ .rules = "evdev",
+ .model = "pc104",
+ .layout = "us",
+ .variant = NULL,
+ .options = NULL,
+ };
context = xkb_context_new();
assert(context);
+++ /dev/null
-#!/bin/sh
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=state
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-rm -f "$log"
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-$builddir/$name$EXEEXT >> $log 2>&1
-#include "xkbmisc.h"
-#include "xkbcommon/xkbcommon.h"
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-static void print_keysym(const char *s)
+#include "xkbcommon/xkbcommon.h"
+
+static int
+test_string(const char *string, xkb_keysym_t expected)
{
- xkb_keysym_t ks = xkb_string_to_keysym(s);
- if (ks == XKB_KEYSYM_NO_SYMBOL)
- printf("NoSymbol\n");
- else
- printf("0x%lX\n", ks);
+ xkb_keysym_t keysym;
+
+ keysym = xkb_string_to_keysym(string);
+
+ fprintf(stderr, "Expected string %s -> %x\n", string, expected);
+ fprintf(stderr, "Received string %s -> %x\n\n", string, keysym);
+
+ return keysym == expected;
}
-static void print_string(xkb_keysym_t ks)
+static int
+test_keysym(xkb_keysym_t keysym, const char *expected)
{
char s[16];
- xkb_keysym_to_string(ks, s, sizeof s);
- printf("%s\n", s);
+ xkb_keysym_to_string(keysym, s, sizeof(s));
+
+ fprintf(stderr, "Expected keysym %#x -> %s\n", keysym, expected);
+ fprintf(stderr, "Received keysym %#x -> %s\n\n", keysym, s);
+
+ return strcmp(s, expected) == 0;
}
-int main(int argc, char *argv[])
+int
+main(void)
{
- int mode;
- xkb_keysym_t sym;
-
- if (argc < 3) {
- fprintf(stderr, "error: not enough arguments\n");
- exit(EXIT_FAILURE);
- }
-
- if (strcmp(argv[1], "-k") == 0) {
- mode = 0;
- sym = strtoul(argv[2], NULL, 16);
- }
- else if (strcmp(argv[1], "-s") == 0)
- mode = 1;
- else {
- fprintf(stderr, "error: unrecognized argument \"%s\"\n", argv[1]);
- exit(EXIT_FAILURE);
- }
-
- if (mode == 0)
- print_string(sym);
- else
- print_keysym(argv[2]);
+ assert(test_string("Undo", 0xFF65));
+ assert(test_string("ThisKeyShouldNotExist", XKB_KEYSYM_NO_SYMBOL));
+ assert(test_string("XF86_Switch_VT_5", 0x1008FE05));
+ assert(test_string("VoidSymbol", 0xFFFFFF));
+ assert(test_string("U4567", 0x1004567));
+ assert(test_string("0x10203040", 0x10203040));
+
+ assert(test_keysym(0x1008FF56, "XF86Close"));
+ assert(test_keysym(0x0, "NoSymbol"));
+ assert(test_keysym(0x1008FE20, "XF86Ungrab"));
+ assert(test_keysym(0x01001234, "U1234"));
return 0;
}
+++ /dev/null
-#!/bin/sh
-
-srcdir=${srcdir-.}
-builddir=${builddir-.}
-
-name=xkey
-prog="$builddir/$name$EXEEXT"
-log="$builddir/$name.log"
-
-check_error()
-{
- if [ "$2" != "$3" ]; then
- echo "error checking $1" >&2
- echo " expected: $2" >&2
- echo " received: $3" >&2
- return 1
- fi
-}
-
-check_string()
-{
- echo "$prog -s '$1'" >>"$log"
- val=`$prog -s "$1"` &&
- echo "$val" >>"$log" &&
- check_error "$1" "$2" "$val" >>"$log" 2>&1 ||
- exit $?
-}
-
-check_key()
-{
- echo "$prog -k '$1'" >>"$log"
- val=`$prog -k "$1"` && \
- echo "$val" >>"$log" &&
- check_error "$1" "$2" "$val" >>"$log" 2>&1 || \
- exit $?
-}
-
-rm -f "$log"
-
-check_string Undo 0xFF65
-check_key 0x1008FF56 XF86Close
-check_string ThisKeyShouldNotExist NoSymbol
-check_key 0x0 NoSymbol
-check_string XF86_Switch_VT_5 0x1008FE05
-check_key 0x1008FE20 XF86Ungrab
-check_string VoidSymbol 0xFFFFFF
-check_key 0x01001234 U1234
-check_string U4567 0x1004567
-check_string 0x10203040 0x10203040