File: 096

package info (click to toggle)
pcp 7.0.5-1
  • links: PTS
  • area: main
  • in suites: forky
  • size: 252,916 kB
  • sloc: ansic: 1,478,844; sh: 177,285; xml: 160,462; cpp: 83,809; python: 24,349; perl: 18,303; yacc: 6,877; lex: 2,864; makefile: 2,694; awk: 165; fortran: 60; java: 52
file content (141 lines) | stat: -rwxr-xr-x 3,115 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#! /bin/sh
# PCP QA Test No. 096
# proc.psinfo.ttyname
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

if [ $PCP_PLATFORM = darwin -o $PCP_PLATFORM = solaris ]
then
    _notrun "No proc metrics for $PCP_PLATFORM"
else
    # proc metrics may not be available
    #
    if pminfo proc.nprocs >/dev/null 2>&1
    then
	:
    else
	_notrun proc PMDA not installed
    fi
fi

done_clean=false
_cleanup()
{
    if $done_clean
    then
	:
    else
	_service pmcd restart 2>&1 | _filter_pcp_restart
	_wait_for_pmcd
	_restore_auto_restart pmcd
	_service pmlogger restart 2>&1 | _filter_pcp_restart
	_wait_for_pmlogger
	_restore_auto_restart pmlogger
	done_clean=true
    fi
    rm -f $tmp.*
}

trap "_cleanup; exit" 0 1 2 3 15

# real QA test starts here

if [ $# -eq 1 ]
then
   if [ $1 = "-v" ]
   then
     verbose=1
   fi
fi

# make sure we have latest ttymap
$sudo rm -f /tmp/pcp.ttymap
# make sure proc agent reloads it
_stop_auto_restart pmcd
_stop_auto_restart pmlogger
if ! _service pmcd restart 2>&1; then _exit 1; fi | _filter_pcp_restart
if ! _service pmlogger restart 2>&1; then _exit 1; fi | _filter_pcp_restart
_wait_for_pmcd || _exit 1
_wait_for_pmlogger || _exit 1

#
# tty filtering per PCP_PLATFORM
#
if [ $PCP_PLATFORM = linux ]
then
	ps -e | tee -a $seq_full | sed \
		-e 's#ttyS#tts/#' \
        | $PCP_AWK_PROG '
	/<defunct>/ { print $1, "?" }
        {print}' >$tmp.ps
else
    echo "Arrgh ... Need to know how to do tty filtering for PCP_PLATFORM $PCP_PLATFORM"
    exit 1
fi

echo "=====================" >>$seq_full

pminfo -F proc.psinfo.ttyname |\
  sed > $tmp.pminfo \
	-e '/DISAPPEARED/d' \
	-e 's#"ttyS#"tts/#' \
	-e 's#vc/#tty#'
echo "----" > $tmp.sep

maxfailures=0

cat $tmp.ps $tmp.sep $tmp.pminfo | tee -a $seq_full |\
$PCP_AWK_PROG -v verbose=$verbose -v maxfailures=$maxfailures -v failfile=$tmp.fail '
	$0 == "----" { pminfo = 1; next; }
        pminfo == 0  {
			# handle defunct processes which have "-" as tty
			if ($2 == "-")
			    $2 = "?"
			ps[$1] = $2
			ps_cmd[$1] = $4
			next
		     }
/ inst \[/	{
		  sub(/.* inst \[/, "")	# delete up to [
		  pid = $1
		  # fall-through, expect value on same line, but not
		  # not necessarily so
		}
/] value "/	{
		  sub(/.*] value "/, "") # delete up to value "
		  sub(/"/,"") 		# delete the final "
		  value = $1;

		# do the comparison
		if (pid in ps) {
		    if (ps[pid] != value && value != "?") {
			printf("mismatch: pid = %s, ps = %s, proc = %s, cmd = %s\n", pid, ps[pid], value, ps_cmd[pid]) > failfile;
			failures++;
		    }
		    else if (verbose == 1) {
			printf("match for pid = %d, value = %s, ps[pid] = %s, cmd = %s\n", pid, value, ps[pid], ps_cmd[pid]);
		    }
		}
	}
	END          {
			if (failures > maxfailures) {
			    printf("Number of failures = %d\n", failures)
			    system("cat " failfile)
			}
			else
			    printf("proc.psinfo.ttyname matches with ps\n")
		     }
'
echo
echo "If failure, check $seq.full"

exit 0