#!/bin/sh
# PCP QA Test No. 1407
# test pmchart with Iostat view
#
# Copyright (c) 2018 Red Hat.  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 pmchart >/dev/null 2>&1 || _notrun "pmchart not installed"
[ -z "$DISPLAY" -a -z "$PCPQA_CLOSE_X_SERVER" ] && _notrun "need DISPLAY or PCPQA_CLOSE_X_SERVER"

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

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

if [ -z "$DISPLAY" ]
then
    export DISPLAY=$PCPQA_CLOSE_X_SERVER
fi

# check pmchart can parse Iostat view
#
export PCP_STDERR=$tmp.err
pmchart -C -c Iostat
if [ -s $tmp.err ]
then
    echo "Arrgh ... stderr from pmchart -C -c iostat"
    cat $tmp.err
    exit
fi

echo expect no output, especially no qt/scaling or divide by zero exceptions
pmchart -z -a $here/archives/zero_disk_activity -c Iostat -t 0.1 -O'@fri jul 13 00:11:40' -o $tmp.out.png 2>>$tmp.err
sed <$tmp.err >$tmp.tmp \
    -e '/libGL error: No matching fbConfigs/d' \
    -e '/libGL error: failed to load driver: swrast/d' \
# end
if [ -s $tmp.tmp ]
then
    echo "Arrgh ... stderr from pmchart ..."
    cat $tmp.err
    exit
fi

# success, all done
status=0
exit
