zsh completions: minor tweaks
[pcp.git] / qa / 603
blob144c6d3c1fcdf77e47e41d2f5b3033c852becbe4
1 #! /bin/sh
2 # PCP QA Test No. 603
3 # PCP 2.2 duplicate of 349 (pmdatrace, pmtrace, and libpcp_trace tests)
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 [ -d $PCP_PMDAS_DIR/trace ] || _notrun "trace PMDA directory is not installed"
18 signal=$PCP_BINADM_DIR/pmsignal
19 status=1 # failure is the default!
21 _cleanup()
23 cd $here
24 if [ -n "$savedtracehost" ]
25 then
26 PCP_TRACE_HOST=$savedtracehost; export PCP_TRACE_HOST
28 if $_needclean
29 then
30 if $install_on_cleanup
31 then
32 ( cd $PCP_PMDAS_DIR/trace; $sudo ./Install </dev/null >/dev/null 2>&1 )
33 else
34 ( cd $PCP_PMDAS_DIR/trace; $sudo ./Remove </dev/null >/dev/null 2>&1 )
36 _needclean=false
38 rm -f $tmp.*
39 exit $status
42 _filter_trace_install()
44 # some warnings are *expected* - no trace values yet
45 tee -a $here/$seq.full | \
46 _filter_pmda_install | sed \
47 -e 's/ *[0-9]+ warnings,//g' \
48 -e "s/$qahost/HOSTNAME/g"
51 install_on_cleanup=false
52 pminfo trace >/dev/null 2>&1 && install_on_cleanup=true
54 _needclean=true
55 trap "_cleanup" 0 1 2 3 15
57 if [ -n "$PCP_TRACE_HOST" ]
58 then
59 savedtracehost=$PCP_TRACE_HOST; unset PCP_TRACE_HOST
62 qahost=`_get_fqdn`
63 otherhost=`./getpmcdhosts -L -n 1 2>$tmp.out`
64 [ -z "$otherhost" ] && _notrun `cat $tmp.out`
65 qanet=`_host_to_ipaddr $otherhost | sed -e 's/[0-9][0-9]*$/*/'`
67 rm -f $seq.full
68 echo "qahost=$qahost" >$seq.full
69 echo "qanet=$qanet" >>$seq.full
70 echo "otherhost=$otherhost" >>$seq.full
72 cat > $tmp.conf1 << EOF
76 4323
80 $qahost
82 EOF
84 cat > $tmp.conf2 << EOF
88 4323
92 $qanet
94 $qahost
97 EOF
99 # real QA test starts here
100 cd $PCP_PMDAS_DIR/trace
102 echo >>$here/$seq.full
103 echo "=== first local trace PMDA config ===" >>$here/$seq.full
104 cat $tmp.conf1 >>$here/$seq.full
105 echo "===" >>$here/$seq.full
107 $sudo ./Install -R / < $tmp.conf1 2>&1 \
108 | _filter_trace_install
109 _wait_for_pmcd
110 grep trace $PCP_PMCDCONF_PATH >>$here/$seq.full
112 echo '=== Attempting bad local access ==='
113 echo "=== Attempting bad local access ===" >>$here/$seq.full
114 # Error message mapping is for Linux
116 pmtrace -h $qahost $qahost 2>&1 \
117 | tee -a $here/$seq.full \
118 | sed \
119 -e "s/Connection reset by peer/Cannot connect to PMDA - permission denied/" \
120 -e "s/Connection refused/Cannot connect to PMDA - permission denied/"
121 if [ -f $PCP_LOG_DIR/pmcd/trace.log ]
122 then
123 cat $PCP_LOG_DIR/pmcd/trace.log >>$here/$seq.full
124 elif [ -f $PCP_LOG_DIR/trace.log ]
125 then
126 cat $PCP_LOG_DIR/trace.log >>$here/$seq.full
127 else
128 echo "Arrggh! Cannot find log for trace PMDA!" >>$here/$seq.full
131 echo
133 echo >>$here/$seq.full
134 echo "=== second local trace PMDA config ===" >>$here/$seq.full
135 cat $tmp.conf2 >>$here/$seq.full
136 echo "===" >>$here/$seq.full
138 $sudo ./Install -R / < $tmp.conf2 2>&1 \
139 | _filter_trace_install
140 _wait_for_pmcd
141 grep trace $PCP_PMCDCONF_PATH >>$here/$seq.full
143 echo '=== Building demo program (app2) ==='
144 cd $PCP_DEMOS_DIR/trace
145 $sudo $PCP_MAKE_PROG app2 >$tmp.make 2>&1
146 if [ $? -ne 0 ]
147 then
148 echo "trace app2 make failed. Here is the make output ..."
149 cat $tmp.make
150 exit 1
153 export PCP_TRACE_HOST=$qahost
155 echo '=== Running demo program (app2) ==='
156 # use app2 process to bump the number of connections.
157 ( ( $PCP_DEMOS_DIR/trace/app2 2>&1 >$tmp.out & ) )
158 sleep 3
160 echo '=== Check access limits ==='
161 echo "=== Check access limits ===" >>$here/$seq.full
162 # Error message mapping is for Linux
164 pmtrace -h $qahost 'limit exceeded' 2>&1 \
165 | tee -a $here/$seq.full \
166 | sed \
167 -e "s/Connection reset by peer/Cannot connect to PMDA - connection limit reached/"
169 $signal -a -s KILL app2
170 wait
171 echo "=== app2 ===" >>$here/$seq.full
172 cat $tmp.out >>$here/$seq.full
174 unset PCP_TRACE_HOST
176 echo '=== Attempting bad remote access ==='
177 echo "=== Attempting bad remote access ===" >>$here/$seq.full
178 # Error message mapping is for Linux
180 ssh -q pcpqa@$otherhost "sh -c 'PCP_TRACE_HOST=$qahost pmtrace -v 1 eek'" 2>&1 \
181 | tee -a $here/$seq.full \
182 | sed \
183 -e "s/Interrupted function call/Cannot connect to PMDA - permission denied/" \
184 -e "s/Connection refused/Cannot connect to PMDA - permission denied/"
185 if [ -f $PCP_LOG_DIR/pmcd/trace.log ]
186 then
187 cat $PCP_LOG_DIR/pmcd/trace.log >>$here/$seq.full
188 elif [ -f $PCP_LOG_DIR/trace.log ]
189 then
190 cat $PCP_LOG_DIR/trace.log >>$here/$seq.full
191 else
192 echo "Arrggh! Cannot find log for trace PMDA!" >>$here/$seq.full
195 echo
197 # Reinstall defaults
198 echo >>$here/$seq.full
199 echo "=== Reinstall default config ===" >>$here/$seq.full
200 cd $PCP_PMDAS_DIR/trace
201 $sudo ./Install -R / < /dev/null 2>&1 \
202 | _filter_trace_install
203 _wait_for_pmcd
204 cd $here
206 # success, all done
207 status=0
208 exit