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
|
#!/bin/sh
# PCP QA Test No. 1132
# Exercise pcp2xlsx.
#
# Copyright (c) 2017-2018 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.python
$python -c "from pcp import pmapi" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmapi module not installed"
$python -c "from collections import OrderedDict" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python collections OrderedDict module not installed"
$python -c "import openpyxl" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python openpyxl module not installed"
which unzip >/dev/null 2>&1 || _notrun "unzip not installed"
which pcp2xlsx >/dev/null 2>&1 || _notrun "pcp2xlsx not installed"
if [ $PCP_PLATFORM = freebsd ]
then
# workaround Python class teardown problem
# AttributeError: 'NoneType' object has no attribute ...
#
version=`uname -rs | sed -e 's/FreeBSD //'`
case "$version"
in
14.[0-3]-*)
_notrun "Python teardown botch"
# NOTREACHED
;;
esac
fi
status=1 # failure is the default!
signal=$PCP_BINADM_DIR/pmsignal
trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
_unzip_filter()
{
LC_ALL=POSIX sort | \
grep -v sharedStrings | \
sed \
-e "s|Archive:.*||g" \
-e "s|[ ]*$||g" \
-e 's/^\([ ]*\)extracting:/\1 inflating:/' \
#end
}
_xlsx_filter()
{
sed \
-e 's|>.*</dcterms:created>|>|g' \
-e 's|>.*</dcterms:modified>|>|g' \
< $1 > $1.f
mv $1.f $1
}
_path_filter()
{
sed \
-e 's|<c r="B2" s="1" t="inlineStr"><is><t>.*archives/rep</t>|<c r="B2" s="1" t="inlineStr"><is><t>archives/rep</t>|g' \
< $1 > $1.f
mv $1.f $1
}
A="$here/archives/rep"
# real QA test starts here
echo "--- running pcp2xlsx"
pcp2xlsx -a $A -H -I -z -b MB -P 2 -F $tmp.outfile ""
mkdir -p $tmp.dir/ref $tmp.dir/run
cd $tmp.dir/ref
echo "--- unzipping reference output"
unzip $here/sheet/pcp2xlsx.qa.1132.out | _unzip_filter
_xlsx_filter docProps/core.xml
_path_filter xl/worksheets/sheet1.xml
cd $tmp.dir/run
echo "--- unzipping generated output"
unzip $tmp.outfile | _unzip_filter
_xlsx_filter docProps/core.xml
_path_filter xl/worksheets/sheet1.xml
cd $tmp.dir
# openpyxl produced XML changes across versions to we do just a basic
# sanity check here that the expected data are present in the sheet file
fail=0
echo checking output
check_strings="/usr/lib/systemd/systemd mem.util.used kernel.all.sysfork"
for str in $(echo $check_strings | tr ' ' '\n'); do
grep -r $str . > /dev/null 2>&1
[ $? -ne 0 ] && fail=1
grep -r $str . > /dev/null 2>&1
[ $? -ne 0 ] && fail=1
done
if [ $fail -eq 1 ]; then
echo expected data not found in the sheet file
else
echo output ok
fi
cd $here
rm -f $tmp.outfile
# success, all done
status=0
exit
|