#!/bin/sh
# PCP QA Test No. 1347
# Exercise kernel.all.boottime and -v option to pcp-atop(1),
# as well as other optional output from pcp-atop.
#
# Copyright (c) 2020 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

ATOP="$PCP_BINADM_DIR/pcp-atop"
test -f "$ATOP" || _notrun "$ATOP is not installed, skipped"

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

status=1	# failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_logs()
{
    echo "=== std out"
    cat $tmp.out
    echo "=== std err"
    cat $tmp.err
    echo "=== done"
    echo
}

# real QA test starts here
pcp_options="pcp -z --origin=+0.1 --archive $here/archives/pcp-atop-boot"

#
# NB: uid -> username and gid -> groupname mappings are now invariant
# however also note that pcp-atop-boot does not contain group names -
# so these will be reported numerically rather than from the QA host.
#

echo "=== -v option:" | tee -a $seq_full
$pcp_options atop -v 2 3 >$tmp.out 2>$tmp.err
_logs | tee -a $seq_full

echo "=== -m option:" | tee -a $seq_full
$pcp_options atop -R -m 2 3 >$tmp.out 2>$tmp.err
_logs

status=0
exit
