#!/bin/sh
# PCP QA Test No. 687
# pmlogger -C checkout
#
# Copyright (c) 2018 Ken McDonell.  All Rights Reserved.
#

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

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

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

_filter()
{
    sed \
	-e "s@$PCP_BINADM_DIR@PCP_BINADM_DIR@" \
	-e "s@$PCP_VAR_DIR@PCP_VAR_DIR@" \
	-e "s@$tmp@$TMP@" \
    # end
}

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

# real QA test starts here
echo "=== syntax errors ==="
cat <<End-of-File >$tmp.config
log fobar on once {
    sample.bin
}
End-of-File
$PCP_BINADM_DIR/pmlogger -Cc $tmp.config 2>&1 | _filter

echo "=== no errors ==="
cat <<End-of-File >$tmp.config
log mandatory on once {
    sample.bin
}
End-of-File
$PCP_BINADM_DIR/pmlogger -Cc $tmp.config 2>&1 | _filter

echo
echo "=== should be in man page ==="
TERM=dumb man pmlogger \
| sed -n \
    -e 's/.//g' \
    -e 's/  */ /g' \
    -e '/\[-[^]]*C/{
s//[-...C/
s/C.*/C...] .../
p
}' \
    -e '/The -C option/{
s/configuration file.*/configuration file .../p
}' \
# end

echo
echo "=== should be in usage message ==="
$PCP_BINADM_DIR/pmlogger --help 2>&1 | grep .-C

status=0
exit
