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
197
198
199
200
201
202
203
204
205
206
207
208
|
#! /bin/sh
# PCP QA Test No. 269 (formerly 269, 406)
# To test out wrapping for pmval
#
# 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
signal=$PCP_BINADM_DIR/pmsignal
status=1 # failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
rm -f $seq.full
_reset()
{
pmstore sample.control -1 > /dev/null
$sudo $signal -a -s HUP pmcd
_wait_for_pmcd
}
_check_wrap_off()
{
tee -a $seq.full |\
$PCP_AWK_PROG -v expected=$tmp.expected -v debug=$debug -v tolerance=$tolerance -v num_samples=$num_samples -v mismatch_limit=$mismatch_limit '
BEGIN {
if (debug == "true")
debug=1;
else
debug = 0;
}
NF == 1 {
i++;
sts = getline val < expected;
if (debug)
print "Read expected value:", val;
if (sts < 0)
print "Error: error in reading expected value";
if (sts == 0)
print "Error: eof encountered in reading expected value";
if (i == 1) {
# ignore the first one
next;
}
if (debug)
print "Comparing:", val, $1
if (val == $1) {
if (debug) print "match";
}
else if ((val-tolerance) <= $1 && $1 <= (val+tolerance)) {
if (debug) print "match";
}
else if (val < 0) {
if ($1 == "?" ){
if (debug) print "match";
}
else {
print "Missing wrap !";
print "Got ", $1, " instead";
mismatch++;
}
}
else {
mismatch++;
if (debug || mismatch_limit==0)
print "mismatch: ", $1, val;
}
}
END {
if (i < num_samples) {
print "Did not process enough samples";
print "Processed:", i, "expected:", num_samples;
}
if (mismatch > mismatch_limit) {
print "Too many mismatches";
print "Number of mismatches = ", mismatch;
}
else {
print "Enough Matched ok";
}
}
'
}
_check_wrap_on()
{
tee -a $seq.full |\
$PCP_AWK_PROG -v expected=$tmp.expected -v debug=$debug -v tolerance=$tolerance -v num_samples=$num_samples -v mismatch_limit=$mismatch_limit '
BEGIN {
if (debug == "true")
debug=1;
else
debug = 0;
# just use 1st value
sts = getline val < expected;
if (debug)
print "Read expected value:", val;
if (sts < 0)
print "Error: error in reading expected value";
if (sts == 0)
print "Error: eof encountered in reading expected value";
}
NF == 1 {
i++;
if (i == 1) {
# ignore the first one
next;
}
if (debug)
print "Comparing:", val, $1
if (val == $1) {
if (debug) print "match";
}
else if ((val-tolerance) <= $1 && $1 <= (val+tolerance)) {
if (debug) print "match";
}
else if ($1 == "?" ){
print "Error: no wrapping allowed";
mismatch++;
}
else {
mismatch++;
if (debug || mismatch_limit == 0)
print "mismatch: ", $1, val;
}
}
END {
if (i < num_samples) {
print "Did not process enough samples";
print "Processed:", i, "expected:", num_samples;
}
if (mismatch > mismatch_limit) {
print "Too many mismatches";
print "Number of mismatches = ", mismatch;
}
else {
print "Enough Matched ok";
}
}
'
}
_test_pmval()
{
_metric=$1
pmval -s$num_samples sample.wrap.$_metric |
sed -e 's/!/?/'
}
_wrap_off()
{
unset PCP_COUNTER_WRAP
echo "--- Wrapping OFF ---"
}
_wrap_on()
{
PCP_COUNTER_WRAP=
export PCP_COUNTER_WRAP
echo "--- Wrapping ON ---"
}
# real QA test starts here
debug=false
num_samples=10
tolerance="0.15e+09" # implies error of about 0.15 second
mismatch_limit=1 # allow 1 mismatch
# src/wrap_int -n $num_samples >$tmp.expected
cat << 'End-of-File' >$tmp.expected
1.074e+09
-3.221e+09
1.074e+09
1.074e+09
1.074e+09
-3.221e+09
1.074e+09
1.074e+09
1.074e+09
-3.221e+09
End-of-File
metric="long"
echo "--- Testing pmval ---"
echo "--- Testing pmval ---" >> $seq.full
_reset
_wrap_off
_test_pmval $metric | _check_wrap_off
_wrap_on
echo "-----------------------" >> $seq.full
_test_pmval $metric | _check_wrap_on
# success, all done
status=0
exit
|