#!/bin/sh
# PCP QA Test No. 1693
# Exercise PMI_APPEND flag to pmiStart() - create an archive then
# append additional records in a separate context.
#
# Copyright (c) 2026 Red Hat.  All Rights Reserved.
#

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

. ./common.product
. ./common.filter
. ./common.check

status=0	# success is the default!
trap "cd $here; rm -rf $tmp; exit \$status" 0 1 2 3 15

mkdir $tmp
cd $tmp

# Handles both the pmi* stderr output and pmdumplog output.
_filter()
{
    sed -e '/pmResult/s/ .* numpmid/ ... numpmid/' \
    | _filter_pmdumplog
}

# real QA test starts here
$here/src/check_import_append 2>&1 | _filter

echo
echo "=== archive integrity ==="
pmlogcheck appendtest

echo
echo "=== all four records present ==="
pmdumplog -t appendtest 2>&1 | _filter

echo
echo "=== fallback archive created ==="
pmlogcheck appendnew

echo
echo "=== Phase 4: pmiSetVolumeSize ==="
$here/src/check_volsize 2>&1

echo
echo "=== multi-volume archive integrity ==="
pmlogcheck volsizetest

# success, all done
exit
