qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 096
blobee2e9f994b7bc99c6959ffa58def046436fa40ab
1 #! /bin/sh
2 # PCP QA Test No. 096
3 # proc.psinfo.ttyname
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 environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 if [ $PCP_PLATFORM = darwin -o $PCP_PLATFORM = solaris ]
17 then
18 _notrun "No proc metrics for $PCP_PLATFORM"
19 else
20 # proc metrics may not be available
22 if pminfo proc.nprocs >/dev/null 2>&1
23 then
25 else
26 _notrun proc PMDA not installed
30 trap "rm -f $tmp.*; exit" 0 1 2 3 15
32 # real QA test starts here
34 if [ $# -eq 1 ]
35 then
36 if [ $1 = "-v" ]
37 then
38 verbose=1
42 # make sure we have latest ttymap
43 $sudo rm -f $seq.full
44 $sudo rm -f /tmp/pcp.ttymap
45 # make sure proc agent reloads it
46 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
47 _wait_for_pmcd
48 _wait_for_pmlogger
51 # tty filtering per host
53 if [ $PCP_PLATFORM = irix ]
54 then
55 # handle stupid /dev/tablet as controlling tty!
56 ls -lr /dev | grep '^c.* 0, 1' \
57 | $PCP_AWK_PROG '
58 NR == 1 { good=$NF; next }
59 { print "s/" $NF "/" good "/" }' >$tmp.sed
60 ps -e | tee -a $seq.full |\
61 sed -e 's#pts/#ttyq#' |
62 sed -f $tmp.sed > $tmp.ps
63 elif [ $PCP_PLATFORM = linux ]
64 then
65 ps -e | tee -a $seq.full | sed \
66 -e 's#ttyS#tts/#' \
67 | $PCP_AWK_PROG '
68 /<defunct>/ { print $1, "?" }
69 {print}' >$tmp.ps
70 else
71 echo "Arrgh ... Need to know how to do tty filtering for $PCP_PLATFORM"
72 exit 1
75 echo "=====================" >>$seq.full
77 pminfo -F proc.psinfo.ttyname |\
78 sed > $tmp.pminfo \
79 -e '/DISAPPEARED/d' \
80 -e 's#"ttyS#"tts/#' \
81 -e 's#vc/#tty#'
82 echo "----" > $tmp.sep
84 maxfailures=0
86 cat $tmp.ps $tmp.sep $tmp.pminfo | tee -a $seq.full |\
87 $PCP_AWK_PROG -v verbose=$verbose -v maxfailures=$maxfailures -v failfile=$tmp.fail '
88 $0 == "----" { pminfo = 1; next; }
89 pminfo == 0 {
90 # handle defunct processes which have "-" as tty
91 if ($2 == "-")
92 $2 = "?"
93 ps[$1] = $2
94 ps_cmd[$1] = $4
95 next
97 / inst \[/ {
98 sub(/.* inst \[/, "") # delete up to [
99 pid = $1
100 # fall-through, expect value on same line, but not
101 # not necessarily so
103 /] value "/ {
104 sub(/.*] value "/, "") # delete up to value "
105 sub(/"/,"") # delete the final "
106 value = $1;
108 # do the comparison
109 if (pid in ps) {
110 if (ps[pid] != value && value != "?") {
111 printf("mismatch: pid = %s, ps = %s, proc = %s, cmd = %s\n", pid, ps[pid], value, ps_cmd[pid]) > failfile;
112 failures++;
114 else if (verbose == 1) {
115 printf("match for pid = %d, value = %s, ps[pid] = %s, cmd = %s\n", pid, value, ps[pid], ps_cmd[pid]);
119 END {
120 if (failures > maxfailures) {
121 printf("Number of failures = %d\n", failures)
122 system("cat " failfile)
124 else
125 printf("proc.psinfo.ttyname matches with ps\n")
128 echo
129 echo "If failure, check $seq.full"
131 exit 0