blob: ca300bdaef0babef741383f73acb741cc0a6545c (
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/Shell
echo "Not running Shell-backgrounding as it has a high failure rate"
exit 0
setopt --verbose
fail(msg) {
echo FAIL: $msg
exit 1
}
last_idx=''
block_idx=0
block() {
block_idx=$(expr 1 + $block_idx)
last_idx=$block_idx
mkfifo fifo$block_idx
cat fifo$block_idx&
}
unblock(idx) {
echo unblock $idx > fifo$idx
rm -f fifo$idx
}
assert_job_count(count) {
ecount=$(jobs | wc -l)
shift
if test $ecount -ne $count {
for $* {
unblock $it
}
fail "expected $ecount == $count"
}
}
block
i=$last_idx
assert_job_count 1 $i
unblock $i
wait
block
i=$last_idx
block
j=$last_idx
assert_job_count 2 $i $j
unblock $i
unblock $j
wait
|