Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 269
blob4c9a88fac6334c1dc0fc9afa7fbad26f628bd401
1 #! /bin/sh
2 # PCP QA Test No. 269 (formerly 269, 406)
3 # To test out wrapping for pmval
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 signal=$PCP_BINADM_DIR/pmsignal
17 status=1 # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 rm -f $seq.full
22 _reset()
24 pmstore sample.control -1 > /dev/null
25 $sudo $signal -a -s HUP pmcd
26 _wait_for_pmcd
30 _check_wrap_off()
32 tee -a $seq.full |\
33 $PCP_AWK_PROG -v expected=$tmp.expected -v debug=$debug -v tolerance=$tolerance -v num_samples=$num_samples -v mismatch_limit=$mismatch_limit '
34 BEGIN {
35 if (debug == "true")
36 debug=1;
37 else
38 debug = 0;
40 NF == 1 {
41 i++;
42 sts = getline val < expected;
43 if (debug)
44 print "Read expected value:", val;
45 if (sts < 0)
46 print "Error: error in reading expected value";
47 if (sts == 0)
48 print "Error: eof encountered in reading expected value";
50 if (i == 1) {
51 # ignore the first one
52 next;
55 if (debug)
56 print "Comparing:", val, $1
57 if (val == $1) {
58 if (debug) print "match";
60 else if ((val-tolerance) <= $1 && $1 <= (val+tolerance)) {
61 if (debug) print "match";
63 else if (val < 0) {
64 if ($1 == "?" ){
65 if (debug) print "match";
67 else {
68 print "Missing wrap !";
69 print "Got ", $1, " instead";
70 mismatch++;
73 else {
74 mismatch++;
75 if (debug || mismatch_limit==0)
76 print "mismatch: ", $1, val;
79 END {
80 if (i < num_samples) {
81 print "Did not process enough samples";
82 print "Processed:", i, "expected:", num_samples;
84 if (mismatch > mismatch_limit) {
85 print "Too many mismatches";
86 print "Number of mismatches = ", mismatch;
88 else {
89 print "Enough Matched ok";
97 _check_wrap_on()
99 tee -a $seq.full |\
100 $PCP_AWK_PROG -v expected=$tmp.expected -v debug=$debug -v tolerance=$tolerance -v num_samples=$num_samples -v mismatch_limit=$mismatch_limit '
101 BEGIN {
102 if (debug == "true")
103 debug=1;
104 else
105 debug = 0;
106 # just use 1st value
107 sts = getline val < expected;
108 if (debug)
109 print "Read expected value:", val;
110 if (sts < 0)
111 print "Error: error in reading expected value";
112 if (sts == 0)
113 print "Error: eof encountered in reading expected value";
115 NF == 1 {
116 i++;
117 if (i == 1) {
118 # ignore the first one
119 next;
121 if (debug)
122 print "Comparing:", val, $1
123 if (val == $1) {
124 if (debug) print "match";
126 else if ((val-tolerance) <= $1 && $1 <= (val+tolerance)) {
127 if (debug) print "match";
129 else if ($1 == "?" ){
130 print "Error: no wrapping allowed";
131 mismatch++;
133 else {
134 mismatch++;
135 if (debug || mismatch_limit == 0)
136 print "mismatch: ", $1, val;
139 END {
140 if (i < num_samples) {
141 print "Did not process enough samples";
142 print "Processed:", i, "expected:", num_samples;
144 if (mismatch > mismatch_limit) {
145 print "Too many mismatches";
146 print "Number of mismatches = ", mismatch;
148 else {
149 print "Enough Matched ok";
155 _test_pmval()
157 _metric=$1
158 pmval -s$num_samples sample.wrap.$_metric |
159 sed -e 's/!/?/'
162 _wrap_off()
164 unset PCP_COUNTER_WRAP
165 echo "--- Wrapping OFF ---"
168 _wrap_on()
170 PCP_COUNTER_WRAP=
171 export PCP_COUNTER_WRAP
172 echo "--- Wrapping ON ---"
175 # real QA test starts here
177 debug=false
178 num_samples=10
179 tolerance="0.15e+09" # implies error of about 0.15 second
180 mismatch_limit=1 # allow 1 mismatch
182 # src/wrap_int -n $num_samples >$tmp.expected
183 cat << 'End-of-File' >$tmp.expected
184 1.074e+09
185 -3.221e+09
186 1.074e+09
187 1.074e+09
188 1.074e+09
189 -3.221e+09
190 1.074e+09
191 1.074e+09
192 1.074e+09
193 -3.221e+09
194 End-of-File
196 metric="long"
197 echo "--- Testing pmval ---"
198 echo "--- Testing pmval ---" >> $seq.full
199 _reset
200 _wrap_off
201 _test_pmval $metric | _check_wrap_off
202 _wrap_on
203 echo "-----------------------" >> $seq.full
204 _test_pmval $metric | _check_wrap_on
206 # success, all done
207 status=0
208 exit