zsh completions: minor tweaks
[pcp.git] / qa / 371
blob7da9a5c84069db309547f7449ad72a9ecc03c30f
1 #!/bin/sh
2 # PCP QA Test No. 371
4 # Parsing and error checking for the mapfile used by sheet2pcp
6 # Copyright (c) 2010 Ken McDonell. All Rights Reserved.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard environment, filters and checks
13 . ./common.product
14 . ./common.filter
15 . ./common.check
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"
24 _filter()
26 sed \
27 -e "s;$tmp;TMP;"
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"
36 End-of-File
39 # real QA test starts here
41 echo "Usage and file existence checks ..."
42 sheet2pcp
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
49 echo
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>
76 <data></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 -->
82 </sheet>
83 End-of-File
84 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
85 | _filter
87 echo
88 cat <<'End-of-File' >$tmp.mapfile
89 <?xml version="1.0" encoding="UTF-8"?>
90 <sheet>
91 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE">
92 hinv.ncpu</metric>
93 <data>hinv.ncpu</data>
94 <!--no datetime element-->
95 </sheet>
96 End-of-File
97 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
98 | _filter
100 echo
101 cat <<'End-of-File' >$tmp.mapfile
102 <?xml version="1.0" encoding="UTF-8"?>
103 <sheet>
104 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE"> hinv.ncpu </metric>
105 <datetime></datetime>
106 <!--no data element-->
107 </sheet>
108 End-of-File
109 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
110 | _filter
112 echo
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>
118 <data>
119 hinv.ncpu
120 </data>
121 </sheet>
122 End-of-File
123 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
124 | _filter
126 echo
127 echo "Mapfile semantic errors ..."
128 cat <<'End-of-File' >$tmp.mapfile
129 <?xml version="1.0" encoding="UTF-8"?>
130 <sheet>
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>
138 </sheet>
139 End-of-File
140 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
141 | _filter
143 echo
144 cat <<'End-of-File' >$tmp.mapfile
145 <?xml version="1.0" encoding="UTF-8"?>
146 <sheet>
147 <metric pmid="60.0.32" type="PM_TYPE_U32" sem="PM_SEM_DISCRETE">
148 hinv.ncpu
149 </metric>
150 <metric pmid="60.0.32">kernel.percpu.cpu.someother</metric> <!-- dup pmid -->
151 <datetime></datetime>
152 <data> hinv.ncpu </data>
153 </sheet>
154 End-of-File
155 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
156 | _filter
159 echo
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-->
164 <sheet heading="1">
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">
169 hinv.ncpu</metric>
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>
178 <!--pmiDump-->
179 </sheet>
180 End-of-File
181 sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \
182 | _filter
184 # don't expect an output archive as there are no rows of data
185 # in the spreadsheet
187 [ -f $tmp.0 -o -f $tmp.index -o -f $tmp.meta ] && pmdumplog -az $tmp
189 # success, all done
190 exit