#!/bin/sh # PCP QA Test No. 371 # # Parsing and error checking for the mapfile used by sheet2pcp # # Copyright (c) 2010 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 sheet2pcp >/dev/null 2>&1 [ $? -eq 0 ] || _notrun "sheet2pcp not installed" perl -e "use XML::TokeParser" >/dev/null 2>&1 [ $? -eq 0 ] || _notrun "perl XML::TokeParser module not installed" perl -e "use Spreadsheet::Read" >/dev/null 2>&1 [ $? -eq 0 ] || _notrun "perl Spreadsheet::Read module not installed" _filter() { sed \ -e "s;$tmp;TMP;" } status=0 # success is the default! $sudo rm -rf $tmp.* $seq.full trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 cat <<'End-of-File' >$tmp.simple.csv "DATE";"Metric A";"Metric B";"Metric C" End-of-File # real QA test starts here echo "Usage and file existence checks ..." sheet2pcp sheet2pcp $tmp.simple.csv sheet2pcp $tmp.simple.csv $tmp.mapfile sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp extra sheet2pcp $tmp.simple.csv /no/such/file $tmp echo echo "Mapfile syntax errors ..." cat <<'End-of-File' >$tmp.mapfile bar kernel.percpu.cpu.sys kernel.all.cpu.sys bad.pmid.one bad.pmid.two bad.indom.one bad.indom.two bad.indom.three bad.units.one bad.units.two bad.units.three bad.units.four bad.type.one bad.type.two bad.sem.one badmetricname no.foo.metric kernel.percpu.cpu.sys[cpu0] kernel.percpu.cpu.sys[cpu1] kernel.percpu.cpu.sys[cpu3 kernel.percpu.cpu.sys[cpu4][fluff End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo cat <<'End-of-File' >$tmp.mapfile hinv.ncpu hinv.ncpu End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo cat <<'End-of-File' >$tmp.mapfile hinv.ncpu End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo cat <<'End-of-File' >$tmp.mapfile hinv.ncpu hinv.ncpu End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo echo "Mapfile semantic errors ..." cat <<'End-of-File' >$tmp.mapfile hinv.ncpu hinv.ncpu foo hinv.ncpu foo[one instance] foo[one other instance] End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo cat <<'End-of-File' >$tmp.mapfile hinv.ncpu kernel.percpu.cpu.someother hinv.ncpu End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter echo echo "Should be OK ..." cat <<'End-of-File' >$tmp.mapfile kernel.percpu.cpu.sys hinv.ncpu good.pmid.one good.pmid.two good.indom.one good.indom.two hinv.ncpu kernel.percpu.cpu.sys[cpu0] kernel.percpu.cpu.sys[cpu1] End-of-File sheet2pcp $tmp.simple.csv $tmp.mapfile $tmp 2>&1 \ | _filter # don't expect an output archive as there are no rows of data # in the spreadsheet # [ -f $tmp.0 -o -f $tmp.index -o -f $tmp.meta ] && pmdumplog -az $tmp # success, all done exit