blob: 90a62f7bef5a514bd9f6abb25f179b4c193718ef (
plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/bin/sh
. $PWD/test/script/functions.sh
function tk_init
{
arg=$1
if [ x$arg == xnopipe ]; then
cat > /tmp/tk_latrace.conf <<EOF
OPTIONS {
PIPE=NO
}
EOF
else
echo > /tmp/tk_latrace.conf
fi
}
function tk_cleanup
{
rm -f /tmp/tk_latrace.conf
rm -f test-kill.expect
rm -f test-kill.out
}
function tk_wait_start
{
name=$1
while [ -z `pgrep $name` ];
do
usleep 100
done
}
function tk_wait_stop
{
pid=$1
while [ `kill -0 $pid 2> /dev/null; echo $?` == "0" ];
do
usleep 100
done
}
function test_kill_handlers
{
tk_init $1
./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 1 > test-kill.out &
tk_wait_start test-kill
pid_latrace=$!
pid_test=`pgrep test-kill`
kill -2 $pid_latrace
tk_wait_stop $pid_latrace
tk_wait_stop $pid_test
echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect
echo -e "\n$PWD/test-kill finished - exited, status=0" >> test-kill.expect
diff test-kill.out test-kill.expect
CHECK_RET
}
function test_kill_nohandlers
{
tk_init $1
./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 2 > test-kill.out &
tk_wait_start test-kill
pid_latrace=$!
pid_test=`pgrep test-kill`
kill -2 $pid_latrace
tk_wait_stop $pid_latrace
tk_wait_stop $pid_test
echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect
echo -e "\n$PWD/test-kill finished - killed by signal 15" >> test-kill.expect
diff test-kill.out test-kill.expect
if [ $? -ne 0 ]; then
echo "FAILED test_kill"
read
exit
fi
echo -n .
}
function test_kill_blocked
{
tk_init $1
./latrace -N /tmp/tk_latrace.conf -q $PWD/test-kill 3 > test-kill.out &
tk_wait_start test-kill
pid_latrace=$!
pid_test=`pgrep test-kill`
kill -2 $pid_latrace
tk_wait_stop $pid_latrace
tk_wait_stop $pid_test
echo -e "\nlatrace interrupted, killing child (pid $pid_test)" > test-kill.expect
echo -e "\n$PWD/test-kill finished - killed by signal 9" >> test-kill.expect
diff test-kill.out test-kill.expect
CHECK_RET
}
function test_kill
{
test_kill_handlers
test_kill_handlers nopipe
test_kill_nohandlers
test_kill_nohandlers nopipe
test_kill_blocked
test_kill_blocked nopipe
tk_cleanup
}
|