#!/bin/sh
rungrok() {
perl ../grok -f conf/$1
}
try() {
OUTPUT=`mktemp /tmp/logwatcher.test.XXXXX`
rungrok "$@" > $OUTPUT 2> /dev/null
GOODOUTPUT=`echo $* | tr ' ' .`
compare $OUTPUT output/$GOODOUTPUT
EXITCODE=$?
if [ "$EXITCODE" -eq 0 ] ; then
echo "Test ($0) OK: $1"
else
echo "Test ($0) failed: $1"
echo "Output:"
cat /tmp/output
fi
return $EXITCODE
}
try_self() {
# $1 =~ should be test_*.sh
SELF=$1
TESTNAME=`echo "$SELF" | sed -e 's/^test_//; s/\.sh$//;'`
try $TESTNAME
}
compare() {
diff -u $1 $2 > /tmp/output
return $?
}
syntax highlighted by Code2HTML, v. 0.9.1