More descriptive error message.
[beanstalkd.git] / check-one.sh
blob67fcd4aa925630d046647764bed4b1cffa3d6dc2
1 #!/bin/bash
3 . "$SRCDIR/sh-tests/common.functions"
5 server=localhost
6 tmpdir="$TMPDIR"
7 test -z "$tmpdir" && tmpdir=/tmp
8 tmpf="${tmpdir}/bnch$$"
9 nc="$SRCDIR/sh-tests/netcat.py"
11 commands="$1"; shift
12 expected="$1"; shift
14 # Allow generic tests to specify their own behavior completely.
15 test -x $commands && exec $commands
17 cleanup() {
19 test -z "$bpid" || kill -9 $bpid
20 rm -f "$tmpf"
21 } >/dev/null 2>&1
24 catch() {
25 echo '' Interrupted
26 exit 3
29 trap cleanup EXIT
30 trap catch HUP INT QUIT TERM
32 if [ ! -x ./beanstalkd ]; then
33 echo "Executable ./beanstalkd not found; do you need to compile first?"
34 exit 2
37 start_beanstalkd
39 # Run the test
40 fgrep -v "#" $commands | $nc $server $port > "$tmpf"
42 # Check the output
43 diff $expected "$tmpf"