Fix compiler warnings.
[beanstalkd.git] / check-one.sh
blobba46c3f4eda66c448a312dff4cf75bcb803f83d8
1 #!/bin/sh
3 server=localhost
4 port=11400
5 tmpdir="$TMPDIR"
6 test -z "$tmpdir" && tmpdir=/tmp
7 tmpf="${tmpdir}/bnch$$"
8 nc='nc -q 1'
10 commands="$1"; shift
11 expected="$1"; shift
13 cleanup() {
15 test -z "$bpid" || kill -9 $bpid
16 rm -f "$tmpf"
17 } >/dev/null 2>&1
20 catch() {
21 echo '' Interrupted
22 exit 3
25 trap cleanup EXIT
26 trap catch HUP INT QUIT TERM
28 if [ ! -x ./beanstalkd ]; then
29 echo "Executable ./beanstalkd not found; do you need to compile first?"
30 exit 2
33 ./beanstalkd -p $port >/dev/null 2>/dev/null &
34 bpid=$!
36 sleep .1
37 if ! ps $bpid >/dev/null; then
38 echo "Could not start beanstalkd for testing, port $port is taken"
39 exit 2
42 # Run the test
43 fgrep -v "#" $commands | $nc $server $port > "$tmpf"
45 # Check the output
46 diff $expected "$tmpf"