Drop unused condition check
[pcp.git] / qa / 234
blobe66072bab3bbaac5254ed8510e0cd85467acf036
1 #! /bin/sh
2 # PCP QA Test No. 234
3 # pmlogsummary exerciser
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
15 status=0
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18 rm -f $seq.full
20 stocave=0
21 noncountstocave=0
22 timeave=0
23 noncounttimeave=0
24 minimum=5000
25 maximum=0
26 limit=0
27 overflow=0
28 debug=false
30 _xtract()
32 # pmdumplog -D1 produces something like ...
34 # pmResult dump from 0x100051d0 timestamp: 882429086.522227 18:11:26.522 ...
35 # 29.0.64 (sample.rapid): numval: 1 valfmt: 0 vlist[]:
36 # value 1810065408
37 # ...
38 # 29.0.7 (sample.drift): numval: 1 valfmt: 0 vlist[]:
39 # value 101
40 # ...
41 # <empty line>
43 # the initial archive processing may cause the same pmResult to
44 # be reported twice, hence the sort at the end
46 # _xtract produces 3 columns: time time_t value
48 # Usage: _xtract metric
50 pmdumplog -D1 $tmp.merge $1 2>&1 \
51 | $PCP_AWK_PROG '
52 $1 == "pmResult" { state=1; time=$7; stamp=$6; next }
53 state == 1 && /\('"$1"'\)/ { state=2; next }
54 state == 2 { state=0; print time,stamp,$2; next }
55 NF==0 { state=0; next }' \
56 | LC_COLLATE=POSIX _POSIX2_VERSION=0 sort -u +1n -2
59 _check()
61 $debug && echo "+ check pmlogsummary=$1 qa=$2"
62 echo "$1 $2" \
63 | $PCP_AWK_PROG '
64 { if ($1 == 0 && $2 == 0)
65 err=0
66 else if ($1 == 0)
67 err=100 # infinity
68 else
69 err=($1-$2)/$1
70 if (-0.05 <= err && err <= 0.05)
71 print "Pass"
72 else
73 print "Fail: pmlogsummary=" $1 " qa=" $2
77 ########
79 _check_counter_stocave()
81 from_summary=`pmlogsummary -x $tmp.merge $1 \
82 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
84 echo "_check_counter_stocave" >>$seq.full
85 from_qa=`_xtract $1 | tee -a $seq.full | $PCP_AWK_PROG '
87 if (count > 0) {
88 avg += ($3 - prevval)/($2 - prevtime)
90 count++
91 prevval = $3
92 prevtime = $2
93 next
95 END { print avg/(count-1) }'`
97 _check $from_summary $from_qa
100 ########
102 _check_noncounter_stocave()
104 from_summary=`pmlogsummary -x $tmp.merge $1 \
105 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
107 from_qa=`pmdumplog -m $tmp.merge $1 | $PCP_AWK_PROG '
108 /\('"$1"'\)/ { sum += $5; count++; next }
109 END { print sum/count }'`
111 _check $from_summary $from_qa
114 ########
116 _check_counter_timeave()
118 from_summary=`pmlogsummary $tmp.merge $1 \
119 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
121 from_qa=`_xtract $1 | $PCP_AWK_PROG '
123 if (count > 0) avg += ($3 - prevval)
124 if (count == 0) firsttime = $2
125 count++
126 prevval = $3
127 lasttime = $2
128 next
130 END { print avg/(lasttime-firsttime) }'`
132 _check $from_summary $from_qa
135 ########
137 _check_noncounter_timeave()
139 from_summary=`pmlogsummary $tmp.merge $1 \
140 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
142 from_qa=`_xtract $1 | $PCP_AWK_PROG '
144 if (count > 0) avg += (prevval * ($2 - prevtime))
145 if (count == 0) firsttime = $2
146 count++
147 prevval = $3
148 prevtime = $2
149 next
151 END { print avg/(prevtime-firsttime) }'`
153 _check $from_summary $from_qa
156 ########
158 _qa_minimum()
160 pmdumplog -m $tmp.merge sample.drift | $PCP_AWK_PROG '
161 /sample.drift/ { if (($5 < min) || (count < 1)) min = $5; count++; next }
162 END { printf "%.3f",min }'
165 _qa_maximum()
167 pmdumplog -m $tmp.merge sample.drift | $PCP_AWK_PROG '
168 /sample.drift/ { if (($5 > max) || (count < 1)) max = $5; count++; next }
169 END { printf "%.3f",max }'
172 _check_minmax()
174 $PCP_AWK_PROG -v min=$minimum -v max=$maximum '
175 /sample.drift/ {
176 if ($3 == min) print "Minimum test passed."
177 else printf "Minimum test failed (pmlogsummary:%.3f != qa:%.3f)\n",$3,min
178 if ($4 == max) print "Maximum test passed."
179 else printf "Maximum test failed (pmlogsummary:%.3f != qa:%.3f)\n",$4,max
184 ########
186 # use stochastic average of counter
188 _check_overflow()
190 from_summary=`pmlogsummary -x $tmp.merge $1 \
191 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
193 from_qa=`_xtract $1 \
194 | $PCP_AWK_PROG '
195 BEGIN { prevval = -1; print "scale=3"; printf "( 0" }
197 if (prevval != -1) {
198 if ($3 >= prevval) {
199 printf " + ((%f-%f)/(%f-%f))",$3,prevval,$2,prevtime
200 count++
203 prevval = $3
204 prevtime = $2
205 next
207 END { printf ") / %d\n",count }' \
208 | bc`
210 _check $from_summary $from_qa
213 # use stochastic average of counter
215 _check_old_overflow()
217 PCP_COUNTER_WRAP=yes
218 export PCP_COUNTER_WRAP
220 from_summary=`pmlogsummary -x $tmp.merge $1 \
221 | $PCP_AWK_PROG '$1 == "'$1'" { print $2 }'`
223 from_qa=`_xtract $1 \
224 | $PCP_AWK_PROG '
225 BEGIN { prevval = -1; print "scale=3"; printf "( 0" }
227 if (prevval != -1) {
228 current = $3
230 # this wrap adjustment only works for 32-bit counters
232 if (current < prevval) current += (4294967295+1)
233 printf " + ((%f-%f)/(%f-%f))",current,prevval,$2,prevtime
234 count++
236 prevval = $3
237 prevtime = $2
238 next
240 END { printf ") / %d\n",count }' \
241 | bc`
243 _check $from_summary $from_qa
246 ########
248 # real QA test starts here
250 cat >$tmp.a.config <<End-of-File
251 log mandatory on 30 msec {
252 sample.control
253 sample.rapid
254 sample.xmit_pdu
255 sample.drift
257 End-of-File
259 cat >$tmp.b.config <<End-of-File
260 log mandatory on 90 msec {
261 sample.control
262 sample.rapid
263 sample.xmit_pdu
264 sample.drift
266 End-of-File
268 echo "Creating log files ..."
269 $sudo rm -f $tmp.a.0 $tmp.a.meta $tmp.a.index
270 $sudo rm -f $tmp.b.0 $tmp.b.meta $tmp.b.index
271 pmlogger -c $tmp.a.config -l $tmp.a.log -s 3 $tmp.a >$tmp.a.err 2>&1
272 pmlogger -c $tmp.b.config -l $tmp.b.log -s 5 $tmp.b >$tmp.b.err 2>&1
274 echo "=== tmp.a ===" >>$seq.full
275 pmdumplog $tmp.a >>$seq.full
276 echo "=== tmp.b ===" >>$seq.full
277 pmdumplog $tmp.b >>$seq.full
279 wait
280 echo "Filtering ..."
281 cat $tmp.a.err $tmp.a.log | _filter_pmlogger_log
282 cat $tmp.b.err $tmp.b.log | _filter_pmlogger_log
284 echo "Merging ..."
285 rm -f $tmp.merge.*
286 pmlogextract $tmp.a $tmp.b $tmp.merge
288 echo "=== tmp.merge ===" >>$seq.full
289 pmdumplog $tmp.merge >>$seq.full
291 # ensure no mark records in archive...
293 mv $tmp.merge.0 $tmp.markedmerge.0
294 src/stripmark $tmp.markedmerge.0 $tmp.merge.0 2>&1 \
295 | sed -e 's/byte [0-9][0-9]*/byte N/'
297 echo
298 echo "Checking non-counter stochastic average (sample.drift) ..."
299 _check_noncounter_stocave sample.drift
301 echo
302 echo "Checking non-counter time average (sample.drift) ..."
303 _check_noncounter_timeave sample.drift
305 echo
306 echo "Checking counter stochastic average (sample.xmit_pdu) ..."
307 _check_counter_stocave sample.xmit_pdu
309 echo
310 echo "Checking counter time averaging (sample.xmit_pdu) ..."
311 _check_counter_timeave sample.xmit_pdu
313 echo
314 echo "Checking minimum & maximum ..."
315 minimum=`_qa_minimum`
316 maximum=`_qa_maximum`
317 pmlogsummary -mM $tmp.merge | _check_minmax
319 echo
320 echo "Checking overflow (sample.rapid) ..."
321 _check_overflow sample.rapid
323 echo
324 echo "Checking PCP 1.x style overflow (sample.rapid) ..."
325 _check_old_overflow sample.rapid
327 # all done
328 exit