#!/bin/sh
# PCP QA Test No. 1399
# Exercise the pcp-pidstat command's -l flag as a standalone as well as in combination with other flags/options.
#
# Copyright (c) 2017 Red Hat.  All Rights Reserved.
#

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

. ./common.python

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

test -x $PCP_BINADM_DIR/pcp-pidstat || _notrun "No pcp-pidstat(1) installed"

pcp_pidstat="$PCP_BINADM_DIR/pcp-pidstat"

archive1="-a $here/archives/pcp-pidstat-process-args"

# real QA test starts here 
echo && echo pcp-pidstat output: Display the process command name and all its arguments.
$pcp_pidstat -z $archive1 -l -s 3

# Use of -l flag in combination of other flags starts here
# -l & -R 
echo && echo pcp-pidstat output: Report realtime priority and scheduling policy information of processes along with its arguments.
$pcp_pidstat -z $archive1 -R -l -s 3

# -l & -r
echo && echo pcp-pidstat output: Report page faults and memory utilization of processes along with its arguments
$pcp_pidstat -z $archive1 -r -l -s 3

#-l & -k
echo && echo pcp-pidstat output: Report page faults and memory utilization.
$pcp_pidstat -z $archive1 -k -l -s 3

#-l & -B
echo && echo pcp-pidstat output: -B Report process state information. Use -B "all" or -B "comma separated states". Use -B "detail" for showing time spent in every state per process.

$pcp_pidstat -z $archive1 -B R,Z -l -s 3

echo "All:"

$pcp_pidstat -z $archive1 -z -B all -l -s 3

echo "Detailed:"

$pcp_pidstat -z $archive1 -B detail -l -s 3

# success, all done
status=0
exit

