summaryrefslogtreecommitdiffstats
path: root/iptables/tests/shell/testcases/iptables/0010-wait_0
blob: 4481f966ce4358fbd57b4cafbe6c7b20e2db899b (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
#!/bin/bash

case "$XT_MULTI" in
*xtables-legacy-multi)
	;;
*)
	echo skip $XT_MULTI
	exit 0
	;;
esac

coproc RESTORE { $XT_MULTI iptables-restore; }
echo "*filter" >&${RESTORE[1]}


$XT_MULTI iptables -A FORWARD -j ACCEPT &
ipt_pid=$!

waitpid -t 1 $ipt_pid
[[ $? -eq 3 ]] && {
	echo "process waits when it should not"
	exit 1
}
wait $ipt_pid
[[ $? -eq 0 ]] && {
	echo "process exited 0 despite busy lock"
	exit 1
}

t0=$(date +%s)
$XT_MULTI iptables -w 3 -A FORWARD -j ACCEPT
t1=$(date +%s)
[[ $((t1 - t0)) -ge 3 ]] || {
	echo "wait time not expired"
	exit 1
}

$XT_MULTI iptables -w -A FORWARD -j ACCEPT &
ipt_pid=$!

waitpid -t 3 $ipt_pid
[[ $? -eq 3 ]] || {
	echo "no indefinite wait"
	exit 1
}
kill $ipt_pid
waitpid -t 3 $ipt_pid
[[ $? -eq 3 ]] && {
	echo "killed waiting iptables call did not exit in time"
	exit 1
}

kill $RESTORE_PID
wait
exit 0