conserver/test/dotest

101 lines
2.4 KiB
Plaintext
Raw Normal View History

2003-04-09 15:30:48 +00:00
#!/bin/sh
pid=0
testnum=0
exitval=0
cleanup()
{
2003-09-22 20:49:53 +00:00
[ -f test.out ] && rm -f test.out
[ -f c.cf ] && rm -f c.cf
2003-04-09 15:30:48 +00:00
[ $pid -eq 0 ] && return 0
kill $pid
2003-09-22 20:49:53 +00:00
for i in *.log; do
[ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i";
done
[ "$exitval" = 0 ] && rm -f conserver.log
2004-05-26 00:41:29 +00:00
[ -d 127.0.0.1 ] && sleep 1 && rm -rf 127.0.0.1
2003-04-09 15:30:48 +00:00
exit $exitval
}
dotest()
{
testnum=`expr $testnum + 1`
$ECHO "executing test #$testnum...$EE"
if [ "$2" ]; then
eval "$2" > test.out 2>&1
else
2003-09-22 20:49:53 +00:00
echo "$1" | \
2004-05-26 00:41:29 +00:00
../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 shell > test.out 2>&1
2003-04-09 15:30:48 +00:00
fi
if [ "$record" ]; then
echo "recorded"
mv test.out results/test$testnum
else
if [ -f results/test$testnum ]; then
2004-11-09 09:34:27 +00:00
if diff -i results/test$testnum >test$testnum.diff test.out 2>&1; then
2003-11-16 19:33:39 +00:00
echo "succeeded"
2003-09-22 20:49:53 +00:00
rm -f test$testnum.diff
2003-04-09 15:30:48 +00:00
else
echo "failed (diffs in test$testnum.diff)"
exitval=1
fi
else
echo "unknown (not recorded)"
fi
2003-09-22 20:49:53 +00:00
rm -f test.out
2003-04-09 15:30:48 +00:00
fi
}
[ ! -f ../conserver/conserver -o ! -f ../console/console ] && \
echo 'binaries do not exist - did you run make yet?' && exit 1
trap cleanup 15
if [ "`echo -n`" = "-n" ]; then
ECHO="echo"
EE="\c"
else
ECHO="echo -n"
EE=""
fi
$ECHO "starting conserver...$EE"
2003-09-22 20:49:53 +00:00
rm -f c.cf
2003-04-09 15:30:48 +00:00
cp test1.cf c.cf
../conserver/conserver -M 127.0.0.1 -p 7777 -v -C c.cf \
-P test.passwd -m 32 > conserver.log 2>&1 &
pid=$!
echo "pid $pid"
sleep 3
[ ! -d results ] && mkdir results
2004-05-26 00:41:29 +00:00
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
2003-04-09 15:30:48 +00:00
dotest 'c?c.'
dotest 'cl?c.'
dotest 'cdc.'
dotest 'coc.'
echo "moving in second config file"
2003-09-22 20:49:53 +00:00
rm -f c.cf
2003-04-09 15:30:48 +00:00
cp test2.cf c.cf
kill -1 $pid
sleep 3
2004-05-26 00:41:29 +00:00
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
2003-04-09 15:30:48 +00:00
dotest 'c?c.'
dotest 'cl?c.'
dotest 'cdc.'
2004-11-09 09:34:27 +00:00
dotest 'cocacoc.'
2003-04-09 15:30:48 +00:00
2004-05-26 00:41:29 +00:00
dotest EVAL "echo 'tu.' | ../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -e 'tu' shell"
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -R | sed -e 's/ [^ ]*$//'"
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'"
2005-09-05 23:15:33 +00:00
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x sh | sed -e '1s/^[^:]*//'"
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x shell | sed -e 's/ on [^ ]* */ on /'"
2003-09-22 20:49:53 +00:00
2003-04-09 15:30:48 +00:00
cleanup