Merge branch 'master' of https://github.com/kmcdonell/pcp into kenj-merge
[pcp.git] / qa / 189
blob4f058b96f2cd6df4a80180b91054d5241a1f27ff
1 #! /bin/sh
2 # PCP QA Test No. 189
3 # pmie does not wait() for children ... defunct processes accummulate
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
15 trap "rm -f $tmp.*; exit 0" 0 1 2 3 15
17 _numchildren()
19 $PCP_AWK_PROG -v pid=$pmie_pid '
20 $5 == pid { n++ ; pidlist[n] = $4; next}
21 $1 == "----" {
22 # output: <num> <pid> <pid>...
23 printf("%d ", n);
24 for(i=1;i<=n;i++)
25 printf("%d ", pidlist[i]);
26 printf("\n");
27 n = 0
31 # real QA test starts here
32 tolerance=10 # allow only one round of 100msec children to accumulate
34 cat <<End-of-File >$tmp.pmie
35 delta = 100 msec;
36 sample.long.ten >= 10 -> shell "date >>$tmp.log";
37 delta = 1 sec;
38 sample.long.ten >= 10 -> shell "ps -el >>$tmp.ps; echo '----' >>$tmp.ps";
39 End-of-File
41 pmie -T 10 $tmp.pmie >$tmp.out 2>$tmp.err &
42 pmie_pid=$!
43 wait $pmie_pid
44 cat $tmp.out $tmp.err | _show_pmie_errors
46 echo "== stdout ==" >$seq.full
47 cat $tmp.out >>$seq.full
48 echo >>$seq.full
49 echo "== stderr ==" >>$seq.full
50 cat $tmp.err >>$seq.full
52 _numchildren < $tmp.ps > $tmp.num
53 max=`cut -d' ' -f1 < $tmp.num | LC_COLLATE=POSIX sort -nr | head -1 | sed -e 's/ *//g'`
55 # give the kernel a chance to catch its breath
57 sleep 2
59 ps -el > $tmp.ps.final
61 max=`cut -d' ' -f1 < $tmp.num | LC_COLLATE=POSIX sort -nr | head -1 | sed -e 's/ *//g'`
63 if [ "$max" -gt "$tolerance" ]
64 then
65 echo "There were too many child processes of pmie left over"
66 echo "In the worst case there were $max child processes"
67 echo "Running 1 second totals:"
68 cat $tmp.num
69 echo "ps output:"
70 cat $tmp.ps
71 # kernel may need more of a chance to catch up!
73 sleep 5
76 # Look for any of the pmie child processes left after pmie death
77 # They should all be dead
78 cat $tmp.num >>$tmp.psawk
79 echo "----" >>$tmp.psawk
80 cat $tmp.ps.final >>$tmp.psawk
81 $PCP_AWK_PROG < $tmp.psawk '
82 final == 0 {
83 # skip over $1 (num)
84 # chuck all others in pidlist
85 for(i=2;i<=NF;i++)
86 pidlist[$i] = 1;
87 next;
89 $1 == "----" { final = 1; next }
90 final == 1 {
91 # check if process in final ps is in pidlist
92 if ($4 in pidlist) {
93 printf("process %s (pid=%d) is still alive\n",
94 $14, $4);
99 exit 0