qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 301
blobec2ff09d44f79a6f26250b89e8f440d3c396563b
1 #!/bin/sh
2 # PCP QA Test No. 301
3 # Stop pmcd and check no pmdas are still running.
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
14 . ./common.check
16 signal=$PCP_BINADM_DIR/pmsignal
17 status=1 # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 # real QA test starts here
23 # Useful definitions...
24 DEADLIMIT=120 # seconds
25 BREATHER=30 # seconds
27 # Debugging controls...
28 CMND=$seq # already done for us
29 DBUG=${DBUG:-FALSE} # normally, the name of this script, $0
30 DBUGLVL=${DBUGLVL:-1} # normally set to 1
32 # Requires common.product:
33 case $PCP_PLATFORM
35 linux|darwin|solaris)
36 AMTIME1970PROG="date +%s"
39 if [ -x /usr/etc/amtime1970 ]
40 then
41 AMTIME1970PROG=/usr/etc/amtime1970
42 else
43 echo "Unknown platfrom $PCP_PLATFORM"
44 exit 1
47 esac
49 dbugEcho () {
50 if [ $# -gt 1 -a "$DBUG" != FALSE -a "$DBUG" = "$CMND" -a "$DBUGLVL" -ge "$1" ]
51 then
52 shift
53 printf " ?: " 1>&2
54 for P
56 printf "%s" "$P" 1>&2
57 done
58 printf "\n" 1>&2
63 waitTilDead () {
64 NUMPROC=1
65 DEADSTART=`$AMTIME1970PROG`
66 DEADTIME=0
67 while [ "$NUMPROC" -gt 0 -a $DEADTIME -lt $DEADLIMIT ]
69 sleep 1
70 NUMPROC=`ps -eo "args pid" | $PCP_AWK_PROG '
71 /^\/var\/pcp\/pmdas\/.*pmda.*/ { print $NF," ",$1 }
72 ' | wc -l`
73 DEADTIME=`$AMTIME1970PROG`
74 DEADTIME=`expr $DEADTIME - $DEADSTART`
75 done
77 echo $DEADTIME
78 return 0
82 dbugEcho 1 "Shutting down PCP"
83 $sudo sh $PCP_RC_DIR/pcp stop >/dev/null &
85 # Wait for PMDAs with sprocs to exit.
86 dbugEcho 1 "Waiting until PCP is dead"
87 SDTIME=`waitTilDead`
88 if [ $? != 0 ]
89 then
90 echo 1>&2 "$seq: unable to determine current time of day"
91 status=2
92 else
93 if [ "$SDTIME" -ge $DEADLIMIT ]
94 then
95 echo 1>&2 "$seq: PCP could not be shut down after $DEADLIMIT seconds"
96 status=2
97 else
98 dbugEcho 1 "PMDAs took $SDTIME second(s) to shut down"
102 # really make sure the "$PCP_RC_DIR/pcp stop" is complete, so it does
103 # not terminate the pmcd we're going to start
105 $sudo $signal -a pmcd >/dev/null 2>&1
106 wait
108 if [ $status -gt 1 ]
109 then
110 dbugEcho 1 "Recovering after $BREATHER seconds"
111 sleep $BREATHER
113 dbugEcho 1 "Starting up PCP"
114 $sudo sh $PCP_RC_DIR/pcp restart >/dev/null
115 _wait_for_pmcd
116 _wait_for_pmlogger
118 # success or failure, we've finished
119 status=`expr $status - 1`
120 exit