#!/bin/sh
# PCP QA Test No. 1010
# Test pmdumptext output formats
#
seq=`basename $0`
echo "QA output created by $seq"

status=1	# failure is the default!
. ./common.qt
trap "_cleanup_qt; exit \$status" 0 1 2 3 15

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

_filter()
{
    $PCP_AWK_PROG '
BEGIN			{ state = 0 }
$1 == "General"		{ print; print "...:"; state = 1; next }
$1 == "Reporting"	{ print; print "...:"; state = 1; next }
state == 1 && NF == 0	{ state = 0 }
state == 1		{ next }
			{ print }' \
    | sed "s/^[A-Za-z]* [A-Za-z]* [ 0-3][0-9] [ 0-2][0-9]:[0-5][0-9]:[0-5][0-9]/VERY_VERY_LONG_TIME/" \
    | sed "s/^[ 0-2][0-9]:[0-5][0-9]:[0-5][0-9]/SHRTTIME/"
}

# real QA test starts here

cat << end-of-file > $tmp.log_conf
log mandatory on 1 second {
    sample.hordes.one
    sample.double
}
end-of-file
pmlogger -c $tmp.log_conf -s 5s $tmp.log
offset=`_arch_start $tmp.log 0`

cat << end-of-file > $tmp.conf
sample.hordes.one["3"]
sample.double.ten
sample.double.hundred
sample.double.million
sample.double.ten	0.5
sample.double.hundred	-0.0033
sample.double.million	0.000056
end-of-file

for i in '' '-i' '-i -w 10'
do
    for f in '' '-M' '-F' '-G' '-f %H:%M:%S'
    do
	echo
	echo "pmdumptext $i $f -umN"
	pmdumptext -O $offset $i $f -d' ' -umN -t 1 -s 3 -c $tmp.conf -a $tmp.log 2>&1 \
	| _filter 
    done
done

# success, all done
status=0
exit
