#!/bin/sh
# PCP QA Test No. 1653
# Checks for pmda-denki
#
# Copyright (c) 2021 Christian Horn.  All Rights Reserved.
#

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

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

[ $PCP_PLATFORM = linux ] || _notrun "Linux-specific kernel metrics"

_cleanup()
{
    cd $here
    $sudo cp $tmp.install $PCP_PMDAS_DIR/denki/Install
    _cleanup_pmda denki
}

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

_filter()
{
    sed \
	-e "s,$here,PWD,g" \
	-e "s,$PCP_PMDAS_DIR,PCP_PMDAS_DIR,g" \
    # end
}

# real QA test starts here
_prepare_pmda denki
$sudo cp $PCP_PMDAS_DIR/denki/Install $tmp.install

echo
echo "### Extracting test datasets..."
echo
cd $here/denki/
tar xzf bigsystem.tgz
tar xzf Thinkpad_L480_bat_busy.tgz

echo
echo "### Installing test dataset 1..."
echo
cd $PCP_PMDAS_DIR/denki
ROOTPATH="$here/denki/Thinkpad_L480_bat_busy"
$sudo sed -ie \
	"s,^args.*,args=\"-U root -r ${ROOTPATH}\","  \
	Install
$sudo ./Install 2>&1
pminfo -fF denki

echo
echo "### Installing test dataset 2..."
echo
ROOTPATH="$here/denki/bigsystem"
$sudo sed -ie \
	"s,^args.*,args=\"-U root -r ${ROOTPATH}\","  \
	Install
$sudo ./Install 2>&1
pminfo -fF denki

echo
echo "### Removing test datasets..."
echo
rm -rf $here/denki/bigsystem
rm -rf $here/denki/Thinkpad_L480_bat_busy

# success, all done
exit
