#!/bin/sh

cd "$AUTOPKGTEST_TMP"

EXPECTED_TEXT=$(parchive -h)
echo "$EXPECTED_TEXT" > data.txt

parchive a recovery-set.par -n2 data.txt || exit 1

rm data.txt recovery-set.p01 || exit 1

parchive c recovery-set.par || exit 1

parchive r recovery-set.par || exit 1

test -f data.txt || exit 1

RESTORED_TEXT=$(cat data.txt)
if [ "$EXPECTED_TEXT" != "$RESTORED_TEXT" ]; then
    exit 1
fi

exit 0
