Testing harness for keysym functions
A test program and script have been added for checking the XkbCommon keysym functions. This has already highlighted an error in handling of keysyms from XF86keysym.h.master
parent
732bade234
commit
b2737e9bfb
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = include src
|
||||
SUBDIRS = include src test
|
||||
|
||||
EXTRA_DIST = ChangeLog
|
||||
|
||||
|
|
|
@ -77,4 +77,5 @@ AC_OUTPUT([
|
|||
Makefile
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
test/Makefile
|
||||
])
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
xkey
|
|
@ -0,0 +1,9 @@
|
|||
INCLUDES = -I$(top_srcdir)/include
|
||||
AM_CFLAGS = $(X11_CFLAGS)
|
||||
|
||||
check_PROGRAMS = xkey
|
||||
xkey_SOURCES = xkey.c
|
||||
xkey_LDADD = $(top_builddir)/src/libxkbcommon.la
|
||||
|
||||
TESTS = xkey.sh
|
||||
TESTS_ENVIRONMENT = $(SHELL)
|
|
@ -0,0 +1,48 @@
|
|||
#include <X11/XkbCommon.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static void print_keysym(const char *s)
|
||||
{
|
||||
KeySym ks = XkbcStringToKeysym(s);
|
||||
if (ks == NoSymbol)
|
||||
printf("NoSymbol\n");
|
||||
else
|
||||
printf("0x%lx\n", ks);
|
||||
}
|
||||
|
||||
static void print_string(KeySym ks)
|
||||
{
|
||||
char *s = XkbcKeysymToString(ks);
|
||||
printf("%s\n", s ? s : "NULL");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int mode;
|
||||
KeySym 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]);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
|
||||
srcdir=${srcdir-.}
|
||||
builddir=${builddir-.}
|
||||
|
||||
check_error()
|
||||
{
|
||||
if [ "$2" != "$3" ]; then
|
||||
echo "error checking $1" >&2
|
||||
echo " expected: $2" >&2
|
||||
echo " received: $3" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
val=`${builddir}/xkey -s Undo` && \
|
||||
check_error Undo 0xff65 $val || \
|
||||
exit $?
|
||||
|
||||
val=`${builddir}/xkey -k 0x1008ff56` && \
|
||||
check_error 0x1008FF56 XF86Close $val || \
|
||||
exit $?
|
||||
|
||||
val=`${builddir}/xkey -s ThisKeyShouldNotExist` && \
|
||||
check_error ThisKeyShouldNotExist NoSymbol $val || \
|
||||
exit $?
|
||||
|
||||
val=`${builddir}/xkey -k 0x0` && \
|
||||
check_error 0x0 NULL $val || \
|
||||
exit $?
|
Loading…
Reference in New Issue