Fix a memory leak in list-tubes-watched.
[beanstalkd.git] / check-one.sh
blob9502e89e605f4f711444e3ab85e1fcf5ebbb69b6
1 #!/bin/sh
3 server=localhost
4 port=11400
5 tmpdir="$TMPDIR"
6 test -z "$tmpdir" && tmpdir=/tmp
7 tmpf="${tmpdir}/bnch$$"
8 nc='./sh-tests/netcat.py'
10 commands="$1"; shift
11 expected="$1"; shift
13 # Allow generic tests to specify their own behavior completely.
14 test -x $commands && exec $commands
16 cleanup() {
18 test -z "$bpid" || kill -9 $bpid
19 rm -f "$tmpf"
20 } >/dev/null 2>&1
23 catch() {
24 echo '' Interrupted
25 exit 3
28 trap cleanup EXIT
29 trap catch HUP INT QUIT TERM
31 if [ ! -x ./beanstalkd ]; then
32 echo "Executable ./beanstalkd not found; do you need to compile first?"
33 exit 2
36 ./beanstalkd -p $port >/dev/null 2>/dev/null &
37 bpid=$!
39 sleep .1
40 if ! ps -p $bpid >/dev/null; then
41 echo "Could not start beanstalkd for testing, port $port is taken"
42 exit 2
45 # Run the test
46 fgrep -v "#" $commands | $nc $server $port > "$tmpf"
48 # Check the output
49 diff $expected "$tmpf"