python api: fix syntax error in recent context changes
[pcp.git] / qa / 274
blobcc41f6899fee0aef6f633673e85673723e587811
1 #! /bin/sh
2 # PCP QA Test No. 274
3 # Throw a broken PMDA at libpcp_pmda and dbpmda
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 status=1
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18 $sudo rm -f $here/$seq.full
20 _filter()
22 # "dbpmda> $" filter for Linux
23 sed \
24 -e '/pmResult/s/0x[^ ]*/ADDR/g' \
25 -e '/pmResult/s/amp: 0.000000 .* numpmid:/amp: EPOCH in LOCALTIME numpmid:/' \
26 -e '/Error: .*() failed/s/Broken pipe/[PMDA died]/' \
27 -e '/Error: .*() failed/s/PDU empty, PMDA may have died/[PMDA died]/' \
28 -e 's/\/tmp.*/logfile/g' \
29 -e 's/\(broken_pmda_2_[0-9]\)([0-9][0-9]*)/\1(PID)/' \
30 -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
31 -e 's/ [0-9\.]*e-[0-9]* 0x/ REAL 0x/g' \
32 -e 's/ 0 0x/ REAL 0x/g' \
33 -e '/dbpmda> $/d' \
34 -e '/Error PDU:/s/One-line/Oneline/'
36 # last sed substitution thanks to pv:937345 which changed the wording
37 # ... preserving the old form so QA passes
40 _filter2()
42 sed \
43 -e 's/^\[.*\] broken_pmda_2_.([0-9]*)/broken pmda/g' \
44 -e '/Info: direct map =/d' \
45 -e '/Info: metric map =/d' \
46 -e 's/^Log for.*/Log started/g' \
47 -e 's/^Log finished.*/Log finished/g'
50 _filter_ins()
52 sed \
53 -e 's/.* \(hash table entries\)/ NNN \1/' \
54 -e 's/.* \(non-leaf nodes\)/ NNN \1/' \
55 -e 's/.* \(leaf nodes\)/ NNN \1/' \
56 -e 's/.* \(bytes of symbol table\)/ NNN \1/'
59 _filterStartBrokenPMDA25 () {
60 # This filter came about as a result of a different ordering of
61 # output in both stdout and stderr from dbpmda in PCP 2.1. This
62 # filter makes it appear as it would in PCP 2.2 onwards so that
63 # the test can detect changes to the text itself rather than the
64 # position of the line "Start broken_pmda_2_5 PMDA..." in the
65 # output for the dbpmda "open" command.
66 $PCP_AWK_PROG '
67 BEGIN { found = false }
68 /Start broken_pmda_2_5 PMDA: / {
69 if (found = false) found = $0
70 else found = found $0
71 next
73 /dbpmda> / {
74 if ( found != false ) {
75 print found
76 found = false
78 print $0
79 next
81 { print }
86 # real QA test starts here
87 unset ROOT MAKEFLAGS
89 # Install the PMDA
90 cd $here/pmdas/broken
91 $sudo ./broken_Install -N < /dev/null | _filter_ins
92 # ensure help text built (-N above skips this)
93 $sudo $PCP_MAKE_PROG broken_v2.dir > /dev/null 2>&1
94 cd $here
96 # Remove the PMDA
97 _remove()
99 cd $here/pmdas/broken
100 $sudo ./broken_Remove -N
101 cd $here
104 trap "_remove; exit \$status" 0 1 2 3 15
106 dbpmda -ie 2>&1 <<End-of-File | _filter
107 open pipe pmdas/broken/broken_pmda_2_0 -D47104 -l $tmp.log
108 status
109 # Test the valid metrics
110 fetch broken.valid.one broken.valid.two broken.valid.three
111 text broken.valid.one
112 # Test for metric not defined in table but in the PMNS and fetch callback
113 fetch broken.bogus.one
114 # Test for metric not defined in table and PMNS but in the fetch callback
115 fetch broken.bogus.two
116 # Test for metric defined in table and fetch, but not the pmns
117 fetch broken.no.pmns
118 # Test for multiple fetch with an invalid metric between valid metrics
119 fetch broken.valid.one broken.bogus.one broken.valid.two
120 # Test for illegal data types
121 fetch broken.bad.type
122 # Test for metric with no fetch support
123 fetch broken.no.fetch
124 # Test for metric with no help
125 fetch broken.no.help broken.no.shorthelp broken.no.longhelp
126 text broken.no.help
127 text broken.no.shorthelp
128 text broken.no.longhelp
129 # Test for handling of bad semantics
130 fetch broken.bad.semantics
131 # Test for handling of bad scale
132 fetch broken.bad.scale
133 # Test for handling of empty instance lists
134 fetch broken.no.instances
135 # Test for handling of missing instances in fetch
136 fetch broken.no.instfetch
137 close
138 quit
139 End-of-File
141 sleep 1
142 if [ -f $tmp.log ]
143 then
144 cat $tmp.log | _filter2
145 echo "=== PMDA should survive tests ===" >>$here/$seq.full
146 cat $tmp.log >>$here/$seq.full
147 rm -f $tmp.log
150 dbpmda -ie 2>&1 <<End-of-File | _filter
151 open pipe pmdas/broken/broken_pmda_2_1 -D47104 -l $tmp.log
152 status
153 wait 5
154 fetch broken.bad.indom
155 close
156 quit
157 End-of-File
159 sleep 1
160 if [ -f $tmp.log ]
161 then
162 cat $tmp.log | _filter2
163 echo >>$here/$seq.full
164 echo "=== broken_pmda_2_1 ===" >>$here/$seq.full
165 cat $tmp.log >>$here/$seq.full
166 rm -f $tmp.log
169 dbpmda -ie 2>&1 <<End-of-File | _filter
170 open pipe pmdas/broken/broken_pmda_2_2 -D47104 -l $tmp.log
171 status
172 close
173 quit
174 End-of-File
176 sleep 1
177 if [ -f $tmp.log ]
178 then
179 cat $tmp.log | _filter2
180 echo >>$here/$seq.full
181 echo "=== broken_pmda_2_2 ===" >>$here/$seq.full
182 cat $tmp.log >>$here/$seq.full
183 rm -f $tmp.log
186 dbpmda -ie 2>&1 <<End-of-File | _filter
187 open pipe pmdas/broken/broken_pmda_2_3 -D47104 -l $tmp.log
188 status
189 close
190 quit
191 End-of-File
193 sleep 1
194 if [ -f $tmp.log ]
195 then
196 cat $tmp.log | _filter2
197 echo >>$here/$seq.full
198 echo "=== broken_pmda_2_3 ===" >>$here/$seq.full
199 cat $tmp.log >>$here/$seq.full
200 rm -f $tmp.log
203 dbpmda -ie 2>&1 <<End-of-File | _filter
204 open pipe pmdas/broken/broken_pmda_2_4 -D47104 -l $tmp.log
205 status
206 text broken.valid.one
207 close
208 quit
209 End-of-File
211 sleep 1
212 if [ -f $tmp.log ]
213 then
214 cat $tmp.log | _filter2
215 echo >>$here/$seq.full
216 echo "=== broken_pmda_2_4 ===" >>$here/$seq.full
217 cat $tmp.log >>$here/$seq.full
218 rm -f $tmp.log
221 dbpmda -ie 2>&1 <<End-of-File | _filter | _filterStartBrokenPMDA25
222 open pipe pmdas/broken/broken_pmda_2_5 -D47104 -l $tmp.log
223 status
224 text broken.valid.one
225 close
226 quit
227 End-of-File
229 sleep 1
230 if [ -f $tmp.log ]
231 then
232 cat $tmp.log | _filter2
233 echo >>$here/$seq.full
234 echo "=== broken_pmda_2_5 ===" >>$here/$seq.full
235 cat $tmp.log >>$here/$seq.full
236 rm -f $tmp.log
239 # all done
240 status=0
241 exit