#!/bin/sh
# PCP QA Test No. 1302
# pmlogrewrite - delete all instances corner case
# Coverity CID 288219
#
# Copyright (c) 2021 Ken McDonell.  All Rights Reserved.
#

if [ $# -eq 0 ]
then
    seq=`basename $0`
    echo "QA output created by $seq"
else
    # use $seq from caller, unless not set
    [ -n "$seq" ] || seq=`basename $0`
    echo "QA output created by `basename $0` $*"
fi

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

_check_valgrind

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

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@$tmp@TMP@g" \
    # end
}

cat <<'End-of-File' >$tmp.config
# delete all instances for sample.colour
indom 29.1 {
    inst 0 -> delete
    inst 1 -> delete
    inst 2 -> delete
}
End-of-File

# real QA test starts here
_run_valgrind pmlogrewrite -c $tmp.config archives/bozo-20170904 $tmp 2>&1 \
| _filter

pmdumplog -z $tmp sample.colour

# success, all done
exit
