summaryrefslogtreecommitdiff
path: root/qa/490
blob: 3203c13921f9e21c0b8c53c626b95179c5d67c96 (plain)
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
#!/bin/sh
# PCP QA Test No. 490
# check for mem leaks in pmlogrewrite
#
# Copyright (c) 2011 Ken McDonell.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

which pmlogrewrite >/dev/null 2>&1 || _notrun "pmlogrewrite not installed"
_check_valgrind

status=0	# success is the default!
$sudo rm -rf $tmp.* $seq.full
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e "s;$tmp;TMP;g" \
	-e "s/^\([+-][+-][+-] TMP\...t*\).*/\1/"
}

_cmp()
{
    if [ ! -f "$1.0" ]
    then
	echo "Arrgh ... $1.0 missing" | _filter
	return
    fi
    if [ ! -f "$2.0" ]
    then
	echo "Arrgh ... $2.0 missing" | _filter
	return
    fi
    pmdumplog -z -a $1 | tee -a $seq.full | sed -e '/\[[0-9][0-9]* bytes]/d' >$tmp.in
    pmdumplog -z -a $2 | tee -a $seq.full | sed -e '/\[[0-9][0-9]* bytes]/d' >$tmp.out
    if [ -n "$oldfilter" ]
    then
	$oldfilter <$tmp.in >$tmp.tmp
	mv $tmp.tmp $tmp.in
    fi
    if [ -n "$newfilter" ]
    then
	$newfilter <$tmp.out >$tmp.tmp
	mv $tmp.tmp $tmp.out
    fi
    echo "pmdumplog diffs ..."
    diff -u $tmp.in $tmp.out | _filter
}

# find sample.mirage values and rescale like pmlogrewrite is expected to
#
# 10:47:07.419  29.0.37 (sample.mirage):
#                inst [0 or "m-00"] value 27
#                inst [12 or "m-12"] value 1226
#                inst [13 or "m-13"] value 1325
#                inst [15 or "m-15"] value 1524
#                inst [16 or "m-16"] value 1623
#              29.0.7 (sample.drift): value 88
_scale()
{
    $PCP_AWK_PROG '
/\(sample.mirage\):/		{ xlate=1; print; next }
xlate == 1 && $1 != "inst"	{ xlate = 0 }
xlate == 1 && $1 == "inst"	{ $6 = int((3600*$6 + 512)/1024) }
				{ print }'
}

# same as _scale, w/out scale conversion ... copy awk whitespace rewriting
_noscale()
{
    $PCP_AWK_PROG '
/\(sample.mirage\):/		{ xlate=1; print; next }
xlate == 1 && $1 != "inst"	{ xlate = 0 }
xlate == 1 && $1 == "inst"	{ $6 = $6+0 }
				{ print }'
}

# real QA test starts here

cat <<End-of-File >$tmp.conf
global {
    hostname -> whizz-bang.engr.sgi.com
    TZ -> "GMT+10"
    Time -> +30
}
indom 1.5 {
    indom -> 42.10
    iname "15 minute" -> "forever"
    iname "1 minute" -> "1 minute is not very long unlike this string"
    inst 15 -> 9999
}
metric 1.*.* { pmid -> 42.*.* }
metric irix.kernel.all.load { name->load type->double }
metric hinv.ncpu { name->hinv.number_of_cpus type->U64 }
End-of-File
rm -f $tmp.new.*
cat $tmp.conf >>$seq.full
_run_valgrind pmlogrewrite -c $tmp.conf src/rattle $tmp.new 2>$tmp.err | _filter
cat $tmp.err >>$seq.full
_cmp src/rattle $tmp.new

cat <<End-of-File >$tmp.conf
metric sample.mirage_longlong { type->U32 indom->NULL }
metric sample.scale_step.time_up_secs { type->FLOAT units->0,1,0,0,MSEC,0 }
End-of-File
rm -f $tmp.new.*
cat $tmp.conf >>$seq.full
_run_valgrind pmlogrewrite -c $tmp.conf src/sample_expr $tmp.new 2>$tmp.err | _filter
cat $tmp.err >>$seq.full
_cmp src/sample_expr $tmp.new

cat <<End-of-File >$tmp.conf
metric sample.bin { name -> x23456789.sample.bin type -> 64 }
metric sample.mirage { type -> FLOAT units -> 1,-1,0,MBYTE,HOUR,0 }
metric sample.drift { delete }
indom 29.2 {
    iname "bin-100" -> delete
    iname "bin-400" -> delete
    iname "bin-500" -> delete
    iname "bin-600" -> delete
    inst 900 -> delete }
indom 29.3 { iname "m-00" -> delete inst 33 -> delete }
End-of-File
rm -f $tmp.new.*
cat $tmp.conf >>$seq.full
_run_valgrind pmlogrewrite -s -c $tmp.conf src/mirage $tmp.new 2>$tmp.err | _filter
cat $tmp.err >>$seq.full
oldfilter=_scale
newfilter=_noscale
_cmp src/mirage $tmp.new

echo
echo "=== correctness checked in QA 493 ... only care about valgrind here ==="
cat <<End-of-File >$tmp.conf
metric sample.ulong.bin_ctr {
    indom -> NULL output MIN
    type -> DOUBLE
    units -> 1,0,0,BYTE,0,0
}
metric sample.ulonglong.bin_ctr {
    indom -> NULL output MAX
    type -> 32
    units -> 1,0,0,BYTE,0,0
}
metric sampledso.double.bin_ctr {
    indom -> NULL output AVG
    type -> FLOAT
}
metric sample.float.bin_ctr {
    indom -> NULL output SUM
    type -> U64
}
metric sample.longlong.bin_ctr {
    indom -> NULL output FIRST
    type -> 64
    units -> 1,-1,0,KBYTE,SEC,0
}
indom 29.2 { inst 200 -> DELETE }
indom 30.2 { inst 800 -> DELETE }
End-of-File
rm -f $tmp.new.*
cat $tmp.conf >>$seq.full
_run_valgrind pmlogrewrite -s -c $tmp.conf src/mirage $tmp.new 2>$tmp.err | _filter
cat $tmp.err >>$seq.full

# success, all done
exit