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.
master
Dan Nicholson 2009-04-04 10:52:23 -07:00
parent 8269cbce81
commit 8f9a612990
4 changed files with 34 additions and 3 deletions

1
test/.gitignore vendored
View File

@ -1,2 +1,3 @@
*.log
rulescomp
xkey

View File

@ -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

View File

@ -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 "" "" ""

View File

@ -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