Commit 8f9a6129904660cb3a83086887b87e27d1f75169

Dan Nicholson 2009-04-04T10:52:23

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.

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