summaryrefslogtreecommitdiff
path: root/qa/051
blob: 6c1de2e73af830fb377a39bbaa4c57c6a07dd37f (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#! /bin/sh
# PCP QA Test No. 051
# Check pmcd access control parsing
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

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

# get standard filters
. ./common.product
. ./common.filter
. ./common.check

_get_libpcp_config
rm -f $seq.out
if $ipv6 ; then
    ln $seq.out.ipv6 $seq.out || exit 1
else
    ln $seq.out.nonipv6 $seq.out || exit 1
fi

# get valid hostnames: $remote_1, $remote_2, etc.
#
. ./051.hosts

# Remember that we cd into 051.work
#
signal=$PCP_BINADM_DIR/pmsignal
config=$PCP_PMCDCONF_PATH
oconfig=$config.O
log=./pmcd.log
me=`hostname`

rm -f $here/$seq.full

_filter_hostnames()
{
    sed \
	-e "s/$remote_1/remote-host-1/" \
	-e "s/$remote_2/remote-host-2/" \
	-e "s/$remote_3/remote-host-3/" \
	-e "s/$remote_4/remote-host-4/" \
	-e "s/$remote_5/remote-host-5/"
}

_filter_die_log()
{
    _filter_pmcd_log <$log \
    | _filter_hostnames \
    | sed \
	-e 's/^$//' \
	-e 's/__pmGetAddrInfo/gethostbyname/g' \
	-e 's/__pmGetHostByName/gethostbyname/g' \
	-e '/Permission clash/s/for .*/for .../' \
	-e '/gethostbyname(/s/name([0-9.]*)/name(IPADDR)/' \
	-e '/gethostbyname(/s/).*/) ERROR.../' \
	-e "/host '.*':/s/host '.*'/host 'HOST'/" \
	-e '/UNIX_DOMAIN_SOCKET/d'
}

_filter_kill_log()
{
    sleep 3
    _filter_pmcd_log <$log \
    | _filter_hostnames \
    | sed \
	-e 's/Cannot open 000000660066: No such file or directory//' \
	-e 's/^$//' \
	-e '/^00[08]:/d' \
	-e '/UNIX_DOMAIN_SOCKET/d' \
    | $PCP_AWK_PROG '
$3 ~ /^[0-9][0-9]*$/	{ $3 = "A_PID" }
			{ print }'

}

interrupt()
{
    echo "Interrupted"
    rm -f $tmp.*
    exit
}

cleanup()
{
    if [ -f $oconfig ]
    then
	$sudo mv $oconfig $config
    fi
    echo "Restarting pmcd"
    unset PMCD_SOCKET
    $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
    _wait_for_pmcd
    _wait_for_pmlogger
    rm -f $tmp.*
}

trap interrupt 1 2 3 15
trap cleanup 0

# real QA test starts here

echo "Make sure all the config files are there"
/bin/sh setup.051 > $tmp.err 2>&1
if [ $? -ne 0 ]
then
    echo "setup.051 failed:"
    cat $tmp.err
    exit 1
fi

ls 051.work/die.*
ls 051.work/kill*
cd 051.work

echo "terminating pmcd..."
$sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
if [ -f $config ]
then
    $sudo mv $config $oconfig
else
    echo "Warning: $config not found"
fi

echo
echo "Running the scanner/parser tests (die.\*)"

export PMCD_SOCKET=$tmp.pmcd.socket
for t in die.*
do
    rm -f pmcd.log
    $sudo cp $t $config
    rm -f pmcd.log
    echo
    $PCP_ECHO_PROG $PCP_ECHO_N "$t================""$PCP_ECHO_C"
    $PCP_ECHO_PROG "$t================" >>$here/$seq.full
    cat $t >>$here/$seq.full
    case $t
    in
	die.029|die.035|die.036|die.043)
	    echo " may dump core for IRIX 6.1 ... bug in gethostbyname()"
	    ;;
	*)
	    echo
    esac
    if [ "X$t" = "Xdie.029" -o "X$t" = "Xdie.043" ]
    then
	echo "(config for $t is host-specific)"
    else
	_filter_hostnames <$config \
	| sed -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;g"
    fi
    $PCP_PMCD_PROG -f -x /no/such/file
    echo "$t logfile----------------"
    echo "$t logfile----------------" >>$here/$seq.full
    cat $log >>$here/$seq.full
    if [ -x filter.$t ]
    then
	./filter.$t <$log
    else
	_filter_die_log
    fi
    echo "$t endlog ----------------"
done

echo
echo
echo "Running the scanner/parser tests (kill.\*)"
echo

for t in kill.*
do
    rm -f pmcd.log
    $sudo cp $t $config
    rm -f pmcd.log
    echo "$t================"
    echo "$t================" >>$here/$seq.full
    cat $t >>$here/$seq.full
    _filter_hostnames <$config \
    | sed -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;g"
    # Give pmcd 3 seconds to run
    ((sleep 3; $signal -a -s TERM pmcd)&) >/dev/null 2>&1
    $PCP_PMCD_PROG -f
    echo "$t logfile----------------"
    echo "$t logfile----------------" >>$here/$seq.full
    cat $log >>$here/$seq.full
    if [ -x filter.$t ]
    then
	./filter.$t <$log
    else
	_filter_kill_log
    fi
    echo "$t endlog ----------------"
done