File: dotest

package info (click to toggle)
conserver 8.1.1-2
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 1,512 kB
  • ctags: 1,012
  • sloc: ansic: 18,713; sh: 3,093; makefile: 319
file content (97 lines) | stat: -rwxr-xr-x 2,112 bytes parent folder | download
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
#!/bin/sh

pid=0
testnum=0
exitval=0

cleanup()
{
    [ -f test.out ] && rm -f test.out
    [ -f c.cf ] && rm -f c.cf
    [ $pid -eq 0 ] && return 0
    kill $pid
    for i in *.log; do
	[ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i";
    done
    [ "$exitval" = 0 ] && rm -f conserver.log
    exit $exitval
}

dotest()
{
    testnum=`expr $testnum + 1`
    $ECHO "executing test #$testnum...$EE"
    if [ "$2" ]; then
	eval "$2" > test.out 2>&1
    else
	echo "$1" | \
	    ../console/console -M 127.0.0.1 -p 7777 shell > test.out 2>&1
    fi
    if [ "$record" ]; then
	echo "recorded"
	mv test.out results/test$testnum
    else
	if [ -f results/test$testnum ]; then
	    if diff -i test.out results/test$testnum >test$testnum.diff 2>&1; then
		echo "succeeded"
		rm -f test$testnum.diff
	    else
		echo "failed (diffs in test$testnum.diff)"
		exitval=1
	    fi
	else
	    echo "unknown (not recorded)"
	fi
	rm -f test.out
    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"
rm -f c.cf
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

dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ 	][ 	]*/ /g'"
dotest 'c?c.'
dotest 'cl?c.'
dotest 'cdc.'
dotest 'coc.'

echo "moving in second config file"
rm -f c.cf
cp test2.cf c.cf
kill -1 $pid
sleep 3

dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ 	][ 	]*/ /g'"
dotest 'c?c.'
dotest 'cl?c.'
dotest 'cdc.'
dotest 'coc.'

dotest EVAL "echo 'tu.' | ../console/console -M 127.0.0.1 -p 7777 -e 'tu' shell"
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -P | sed -e 's/:.*//'"
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'"

cleanup