1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#!/bin/bash
BINDIR="$1"
ASSET_DIR="$2"
TEST_ASSETS="$3"
TEST_ASSETS_SHOULD_FAIL="$4"
. $(dirname $0)/test-lib.sh
has_fsck=$(check_erofs_fsck)
set -e
tmpfile=$(mktemp --tmpdir lcfs-test.XXXXXX)
tmpfile2=$(mktemp --tmpdir lcfs-test.XXXXXX)
trap 'rm -rf -- "$tmpfile" "$tmpfile2"' EXIT
# Ensure our builtin dumpfiles are strict, minus some exceptions
declare -A nonstrict
nonstrict=(
["no-newline.dump"]="1"
["longlink.dump"]="1"
["honggfuzz-longlink-unterminated.dump"]="1"
)
for format in erofs ; do
for file in ${TEST_ASSETS} ; do
if [ ! -f $ASSET_DIR/$file ] ; then
continue;
fi
VERSION=""
VERSION_ARG=""
if test -f $ASSET_DIR/$file.version ; then
VERSION="$(cat $ASSET_DIR/$file.version)"
VERSION_ARG="--min-version=$VERSION --max-version=$VERSION"
fi
echo Verifying $file $VERSION_ARG
EXPECTED_SHA=$(cat $ASSET_DIR/$file.sha256);
if [[ $file == *.gz ]] ; then
CAT=zcat
else
CAT=cat
fi
if test -v "nonstrict[$file]"; then
unset CFS_PARSE_STRICT
else
export CFS_PARSE_STRICT=1
fi
$CAT $ASSET_DIR/$file | ${VALGRIND_PREFIX} ${BINDIR}/mkcomposefs $VERSION_ARG --from-file - $tmpfile
SHA=$(sha256sum $tmpfile | awk "{print \$1}")
# Run fsck.erofs to make sure we're not generating anything weird
if [ $has_fsck == y ]; then
fsck.erofs $tmpfile
fi
# Ensure dump reproduces the same file
${VALGRIND_PREFIX} ${BINDIR}/composefs-dump $tmpfile $tmpfile2
if ! cmp $tmpfile $tmpfile2; then
echo Dump is not reproducible
exit 1
fi
${VALGRIND_PREFIX} ${BINDIR}/composefs-info dump $tmpfile | ${VALGRIND_PREFIX} ${BINDIR}/mkcomposefs $VERSION_ARG --from-file - $tmpfile2
if ! cmp $tmpfile $tmpfile2; then
echo Dump is not reproducible via composefs-info dump
exit 1
fi
if [ $SHA != $EXPECTED_SHA ]; then
echo Invalid $format checksum of file generated from $file: $SHA, expected $EXPECTED_SHA
exit 1
fi
echo "ok $file (CFS_PARSE_STRICT=${CFS_PARSE_STRICT:-0})"
done
done
|