-
Notifications
You must be signed in to change notification settings - Fork 144
/
test.sh
54 lines (50 loc) · 1.03 KB
/
test.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
51
52
53
54
set -e -x
cd "$(dirname "$0")"
findproc() {
set +x
find "/proc" -mindepth 2 -maxdepth 2 -name "exe" -lname "$PWD/$1" 2>"/dev/null" |
cut -d"/" -f"3"
set -x
}
for NAME in "legacy" "single"
do
cd "example/$NAME"
go build
./$NAME &
PID="$!"
[ "$PID" -a -d "/proc/$PID" ]
for _ in _ _
do
OLDPID="$PID"
sleep 1
kill -USR2 "$PID"
sleep 2
PID="$(findproc "$NAME")"
[ ! -d "/proc/$OLDPID" -a "$PID" -a -d "/proc/$PID" ]
done
[ "$(nc "127.0.0.1" "48879")" = "Hello, world!" ]
kill -TERM "$PID"
sleep 2
[ ! -d "/proc/$PID" ]
[ -z "$(findproc "$NAME")" ]
cd "$OLDPWD"
done
cd "example/double"
go build
./double &
PID="$!"
[ "$PID" -a -d "/proc/$PID" ]
for _ in _ _
do
sleep 1
kill -USR2 "$PID"
sleep 3
NEWPID="$(findproc "double")"
[ "$NEWPID" = "$PID" -a -d "/proc/$PID" ]
done
[ "$(nc "127.0.0.1" "48879")" = "Hello, world!" ]
kill -TERM "$PID"
sleep 3
[ ! -d "/proc/$PID" ]
[ -z "$(findproc "double")" ]
cd "$OLDPWD"