blob: e92e09ebde0cf4350ce588aacf7da17bb8406b5b (
plain) (
blame)
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
|
#!/bin/sh
: ${ARG_MAX:=524288}
base=$(dirname $(realpath "$0"))
echo "1..2"
waitfor() {
flagfile=$1
iter=0
while [ ! -f ${flagfile} ] && [ ${iter} -lt 50 ]; do
sleep 0.10
iter=$((iter + 1))
done
if [ ! -f ${flagfile} ]; then
return 1
fi
}
sentinel="findme=test-$$"
sentinelsz=$(printf "${sentinel}" | wc -c | tr -d '[[:space:]]')
name="pgrep -f"
spin="${base}/spin_helper"
flagfile="pgrep_f_short.flag"
${spin} --short ${flagfile} ${sentinel} &
chpid=$!
if ! waitfor ${flagfile}; then
echo "not ok - $name"
else
pid=$(pgrep -f ${sentinel})
if [ "$pid" = "$chpid" ]; then
echo "ok - $name"
else
echo "not ok - $name"
fi
fi
kill $chpid
name="pgrep -f long args"
flagfile="pgrep_f_long.flag"
${spin} --long ${flagfile} ${sentinel} &
chpid=$!
if ! waitfor ${flagfile}; then
echo "not ok - $name"
else
pid=$(pgrep -f ${sentinel})
if [ "$pid" = "$chpid" ]; then
echo "ok - $name"
else
echo "not ok - $name"
fi
fi
kill $chpid
|