#! /bin/sh
# kmchart QA Test No. 010
# Copyright (c) 2008 Aconex.  All Rights Reserved.
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#
# Test kmdumptext output formats
#
seq=`basename $0`
echo "QA output created by $seq"

# get standard functions
. ./common.sh
# get standard filters
. ./common.filter

tmp=/tmp/$$
status=1	# failure is the default!
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_filter()
{
    $PCP_AWK_PROG '
BEGIN			{ state = 0 }
$1 == "Options:"	{ 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 "kmdumptext $i $f -umN"
	kmdumptext -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
