test: Add logging and some intentionally failing cases We want to log the output of the tests rather than letting them go to stderr. This allows tests we expect to fail to be run.
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
diff --git a/test/.gitignore b/test/.gitignore
index 1f8f4a2..fd63fc1 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -1,2 +1,3 @@
+*.log
rulescomp
xkey
diff --git a/test/Makefile.am b/test/Makefile.am
index 4e35e12..871cbd5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,6 +6,9 @@ TESTS_ENVIRONMENT = $(SHELL)
check_PROGRAMS = xkey rulescomp
TESTS = xkey.sh rulescomp.sh
+clean-local:
+ rm -f *.log
+
xkey_SOURCES = xkey.c
xkey_LDADD = $(top_builddir)/src/libxkbcommon.la
diff --git a/test/rulescomp.sh b/test/rulescomp.sh
index 5a5742e..948d7dc 100755
--- a/test/rulescomp.sh
+++ b/test/rulescomp.sh
@@ -3,11 +3,30 @@
srcdir=${srcdir-.}
builddir=${builddir-.}
+log="$builddir/rulescomp.log"
+
compile()
{
- ${builddir}/rulescomp "$1" "$2" "$3" "$4" "$5" || exit $?
+ echo "${builddir}/rulescomp '$1' '$2' '$3' '$4' '$5'" >>"$log"
+ ${builddir}/rulescomp "$1" "$2" "$3" "$4" "$5" >>"$log" 2>&1 || exit $?
+}
+
+failcompile()
+{
+ echo "${builddir}/rulescomp '$1' '$2' '$3' '$4' '$5'" >>"$log"
+ if ${builddir}/rulescomp "$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 "" "" ""
diff --git a/test/xkey.sh b/test/xkey.sh
index 0e1961d..6aa3dd6 100755
--- a/test/xkey.sh
+++ b/test/xkey.sh
@@ -3,6 +3,8 @@
srcdir=${srcdir-.}
builddir=${builddir-.}
+log="$builddir/xkey.log"
+
check_error()
{
if [ "$2" != "$3" ]; then
@@ -15,18 +17,24 @@ check_error()
check_string()
{
+ echo "${builddir}/xkey -s '$1'" >>"$log"
val=`${builddir}/xkey -s "$1"` &&
- check_error "$1" "$2" "$val" ||
+ echo "$val" >>"$log" &&
+ check_error "$1" "$2" "$val" >>"$log" 2>&1 ||
exit $?
}
check_key()
{
+ echo "${builddir}/xkey -k '$1'" >>"$log"
val=`${builddir}/xkey -k "$1"` && \
- check_error "$1" "$2" "$val" || \
+ 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