forked from beanstalkd/beanstalkd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check-one.sh
executable file
·51 lines (39 loc) · 973 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
44
45
46
47
48
49
50
#!/bin/sh
server=localhost
port=11400
tmpdir="$TMPDIR"
test -z "$tmpdir" && tmpdir=/tmp
tmpf="${tmpdir}/bnch$$"
nc='nc -q 10'
nc -q 10 2>&1 | grep -q "illegal option" && nc='nc -w 10' # workaround for older netcat
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
./beanstalkd -p $port >/dev/null 2>/dev/null &
bpid=$!
sleep .1
if ! ps -p $bpid >/dev/null; then
echo "Could not start beanstalkd for testing, port $port is taken"
exit 2
fi
# Run the test
fgrep -v "#" $commands | $nc $server $port > "$tmpf"
# Check the output
diff $expected "$tmpf"