#!/bin/sh
# PCP QA Test No. 631
# Check pmlogrewrite and mutually exclusive command line options
#
# 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.*
}

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

for suff in 0 meta index
do
    cp tmparch/foo.$suff $tmp.$suff
done

# real QA test starts here
echo "=== error cases ==="
pmlogrewrite -C -S $tmp /do-not-use-this-argument
pmlogrewrite -S -C $tmp /do-not-use-this-argument
pmlogrewrite -d -S $tmp /do-not-use-this-argument
pmlogrewrite -S -d $tmp /do-not-use-this-argument
pmlogrewrite -i -S $tmp /do-not-use-this-argument
pmlogrewrite -S -i $tmp /do-not-use-this-argument
pmlogrewrite -q -S $tmp /do-not-use-this-argument
pmlogrewrite -S -q $tmp /do-not-use-this-argument
pmlogrewrite -S $tmp /do-not-use-this-argument

echo
echo "=== real work, no change ==="
cat >$tmp.config <<End-of-File
metric sample.colour {
	sem -> instant
}
End-of-File
pmlogrewrite -S -c $tmp.config $tmp
echo "exit status=$?"

echo
echo "=== real work, change ==="
cat >$tmp.config <<End-of-File
metric sample.colour {
	sem -> discrete
}
End-of-File
pmlogrewrite -S -c $tmp.config $tmp
echo "exit status=$?"

# success, all done
status=0
exit
