forked from JalfResi/beanstalkd-ww
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-one.sh
44 lines (33 loc) · 801 Bytes
/
check-one.sh
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
#!/usr/bin/env bash
SRCDIR=`pwd`
. "$SRCDIR/sh-tests/common.functions"
server=localhost
tmpdir="$TMPDIR"
test -z "$tmpdir" && tmpdir=/tmp
tmpf="${tmpdir}/bnch$$"
nc="$SRCDIR/sh-tests/netcat.py"
commands="$1"; shift
expected="$1"; shift
# Allow generic tests to specify their own behavior completely.
test -x $commands && exec $commands
cleanup() {
{
test -z "$bpid" || kill -9 $bpid
rm -f "$tmpf"
} >/dev/null 2>&1
}
catch() {
echo '' Interrupted
exit 3
}
trap cleanup EXIT
trap catch HUP INT QUIT TERM
if [ ! -x ./beanstalkd ]; then
echo "Executable ./beanstalkd not found; do you need to compile first?"
exit 2
fi
start_beanstalkd '' '-z 10'
# Run the test
fgrep -v "#" $commands | $nc $server $port > "$tmpf"
# Check the output
diff $expected "$tmpf"