4 # Parsing and error checking for the mapfile used by sheet2pcp
6 # Copyright (c) 2010 Ken McDonell. All Rights Reserved.
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
17 which sheet2pcp
>/dev
/null
2>&1
18 [ $?
-eq 0 ] || _notrun
"sheet2pcp not installed"
19 perl
-e "use XML::TokeParser" >/dev
/null
2>&1
20 [ $?
-eq 0 ] || _notrun
"perl XML::TokeParser module not installed"
21 perl
-e "use Spreadsheet::Read" >/dev
/null
2>&1
22 [ $?
-eq 0 ] || _notrun
"perl Spreadsheet::Read module not installed"
30 status
=0 # success is the default!
31 $sudo rm -rf $tmp.
* $seq.full
32 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34 cat <<'End-of-File' >$tmp.simple.csv
35 "DATE";"Metric A";"Metric B";"Metric C"
39 # real QA test starts here
41 echo "Usage and file existence checks ..."
43 sheet2pcp
$tmp.simple.csv
44 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
45 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp extra
47 sheet2pcp
$tmp.simple.csv
/no
/such
/file $tmp
50 echo "Mapfile syntax errors ..."
51 cat <<'End-of-File' >$tmp.mapfile
52 <?xml version="1.0" encoding="UTF-8"?>
53 <sheet heading="1" blah="123"> <!-- unexpected attr -->
54 <foo><!-- bogus tag -->bar</foo>
55 <metric pmid="60.0.2" indom="60.0" units="0,1,0,0,PM_TIME_MSEC,0"
56 type="PM_TYPE_U64" sem="PM_SEM_COUNTER">
57 kernel.percpu.cpu.sys</metric>
58 <metric pmid="60.0.22" units="0,1,0,0,PM_TIME_MSEC,0" fungus="bogus"
59 type="PM_TYPE_U64" sem="PM_SEM_COUNTER">
60 kernel.all.cpu.sys</metric>
61 <metric pmid="60.0">bad.pmid.one</metric>
62 <metric pmid="6x.0.2">bad.pmid.two</metric>
63 <metric indom="60.0.0">bad.indom.one</metric>
64 <metric indom="60">bad.indom.two</metric>
65 <metric indom="bozo">bad.indom.three</metric>
66 <metric units="0,0,0,0,0">bad.units.one</metric>
67 <metric units="0,0,0,0,0,0,0">bad.units.two</metric>
68 <metric units="BOZO,0,0,PM_SPACE_BOZO,0,0,">bad.units.three</metric>
69 <metric units="1,0,0,PM_SPACE_BOZO,0,0,">bad.units.four</metric>
70 <metric type="PM_TYPE_FOO">bad.type.one</metric>
71 <metric type="">bad.type.two</metric>
72 <metric sem="PM_SEM_FOO">bad.sem.one</metric>
73 <metric sem="PM_SEM_COUNTER"></metric> <!-- no metric name -->
74 <datetime monkey="true"></datetime>
75 <data hi="ho">badmetricname</data>
77 <data>no.foo.metric</data>
78 <data>kernel.percpu.cpu.sys[cpu0]</data>
79 <data>kernel.percpu.cpu.sys[cpu1]</data>
80 <data>kernel.percpu.cpu.sys[cpu3</data> <!-- missing ] -->
81 <data>kernel.percpu.cpu.sys[cpu4][fluff</data> <!-- extra stuff -->
84 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
88 cat <<'End-of-File' >$tmp.mapfile
89 <?xml version="1.0" encoding="UTF-8"?>
91 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE">
93 <data>hinv.ncpu</data>
94 <!--no datetime element-->
97 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
101 cat <<'End-of-File' >$tmp.mapfile
102 <?xml version="1.0" encoding="UTF-8"?>
104 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE"> hinv.ncpu </metric>
105 <datetime></datetime>
106 <!--no data element-->
109 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
113 cat <<'End-of-File' >$tmp.mapfile
114 <?xml version="1.0" encoding="UTF-8"?>
115 <sheet datefmt="DD-MM-YYYY">
116 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE"> hinv.ncpu </metric>
117 <datetime></datetime>
123 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
127 echo "Mapfile semantic errors ..."
128 cat <<'End-of-File' >$tmp.mapfile
129 <?xml version="1.0" encoding="UTF-8"?>
131 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE"> hinv.ncpu </metric>
132 <metric>hinv.ncpu</metric> <!-- dup name -->
133 <metric indom="PMI_DOMAIN.1">foo</metric>
134 <data> hinv.ncpu </data>
135 <data>foo[one instance]</data>
136 <data>foo[one other instance]</data> <!-- fails unique to space rule -->
137 <datetime></datetime>
140 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
144 cat <<'End-of-File' >$tmp.mapfile
145 <?xml version="1.0" encoding="UTF-8"?>
147 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE">
150 <metric pmid="60.0.32">kernel.percpu.cpu.someother</metric> <!-- dup pmid -->
151 <datetime></datetime>
152 <data> hinv.ncpu </data>
155 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
160 echo "Should be OK ..."
161 cat <<'End-of-File' >$tmp.mapfile
162 <?xml version="1.0" encoding="UTF-8"?>
163 <!--For PCP QA 371-->
165 <metric pmid="60.0.2" indom="60.0" units="0,1,0,0,PM_TIME_MSEC,0"
166 type="PM_TYPE_U64" sem="PM_SEM_COUNTER">
167 kernel.percpu.cpu.sys</metric>
168 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE">
170 <metric pmid="PM_ID_NULL">good.pmid.one</metric>
171 <metric pmid="PMI_DOMAIN.0.63">good.pmid.two</metric>
172 <metric indom="PM_INDOM_NULL">good.indom.one</metric>
173 <metric indom="PMI_DOMAIN.27">good.indom.two</metric>
174 <datetime></datetime>
175 <data>hinv.ncpu</data>
176 <data>kernel.percpu.cpu.sys[cpu0]</data>
177 <data>kernel.percpu.cpu.sys[cpu1]</data>
181 sheet2pcp
$tmp.simple.csv
$tmp.mapfile
$tmp 2>&1 \
184 # don't expect an output archive as there are no rows of data
187 [ -f $tmp.0 -o -f $tmp.index
-o -f $tmp.meta
] && pmdumplog
-az $tmp