Make sure fd is always initialized.
[beanstalkd.git] / check-one.sh
blobbcfb7d4b22c28d3f909d13dad54b4caa1284fdbe
1 #!/usr/bin/env 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 '' '-z 10'
39 # Run the test
40 fgrep -v "#" $commands | $nc $server $port > "$tmpf"
42 # Check the output
43 diff $expected "$tmpf"