#!/bin/sh
# PCP QA Test No. 926
# Exercise the ganglia2pcp utility
#
# Copyright (c) 2015 Martins Innus.  All Rights Reserved.
#
# The test archives are machine specific. If a set of 
# files for your architecture is not present, please: 
#
# cd  qa/ganglia && mk-gangliatest
#
# and submit the results.

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

which ganglia2pcp >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "ganglia2pcp not installed"

perl -e "use Date::Parse" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "perl Date::Parse module not installed"

perl -e "use Date::Format" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "perl Date::Format module not installed"

perl -e "use RRDs" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "perl RRDs module not installed"

rm -f $seq.out
machine=`uname -m`
case "$machine"
in
i?86|athlon)
    machine=32
    ;;
amd64|x86_64)
    machine=64
    ;;
esac
[ -f $seq.out.$machine ] || \
	_notrun No qualified output for `uname -m` architecture. Please run mk-gangliatest and submit the new files.
ln $seq.out.$machine $seq.out || exit 1

status=0        # success is the default!
$sudo rm -rf $tmp.* $seq.full
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

# real QA test starts here
# only one dir for now, add more if we get more sample data
# rrdtool can't read data from different architectures

indir=./ganglia/gangliatest.$machine

echo
echo "=== $indir ==="
rm -f $tmp.0 $tmp.index $tmp.meta
outfile=`basename $tmp`
outdir=`dirname $tmp`
ganglia2pcp  -s "Feb 1 12:00:00 UTC 2015" -f $outfile -d $outdir -Z UTC $indir

if [ -f $tmp.0 ]
then
    pmdumplog -z -a $tmp
fi

# success, all done
exit

