[PATCH] erofs-utils: tests: check the compress-hints functionality
Gao Xiang
hsiangkao at linux.alibaba.com
Thu Sep 16 01:10:06 AEST 2021
Jianan,
On Wed, Sep 15, 2021 at 07:21:49PM +0800, Huang Jianan via Linux-erofs wrote:
> Signed-off-by: Huang Jianan <huangjianan at oppo.com>
Thanks for this! I'm fine with the patch, let me fold some
random modification as well.
> ---
> tests/Makefile.am | 5 ++-
> tests/common/rc | 2 +-
> tests/erofs/017 | 78 +++++++++++++++++++++++++++++++++++++++++++++
> tests/erofs/017.out | 2 ++
> 4 files changed, 85 insertions(+), 2 deletions(-)
> create mode 100755 tests/erofs/017
> create mode 100644 tests/erofs/017.out
>
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 1d73a1b..632dcf5 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -70,9 +70,12 @@ TESTS += erofs/014
> # 015 - regression test for battach on full buffer block
> TESTS += erofs/015
>
> -# 006 - verify the uncompressed image with 2-level random files
> +# 016 - verify the uncompressed image with 2-level random files
> TESTS += erofs/016
>
> +# 017 - check the compress-hints functionality
> +TESTS += erofs/017
> +
> EXTRA_DIST = common/rc erofs
>
> clean-local: clean-local-check
> diff --git a/tests/common/rc b/tests/common/rc
> index a6b6014..abd88d1 100644
> --- a/tests/common/rc
> +++ b/tests/common/rc
> @@ -185,7 +185,7 @@ _scratch_cycle_mount()
>
> _get_filesize()
> {
> - stat -c %s "$1"
> + stat -c %s "$1"
> }
>
> _require_fssum()
> diff --git a/tests/erofs/017 b/tests/erofs/017
> new file mode 100755
> index 0000000..a12d1ad
> --- /dev/null
> +++ b/tests/erofs/017
> @@ -0,0 +1,78 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0+
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +
> +# get standard environment, filters and checks
> +. "${srcdir}/common/rc"
> +
> +cleanup()
> +{
> + cd /
> + rm -rf $tmp.*
> +}
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +echo "QA output created by $seq"
> +
> +[ -z "$lz4hc_on" ] && \
> + _notrun "lz4hc compression is disabled, skipped."
> +
> +if [ -z $SCRATCH_DEV ]; then
> + SCRATCH_DEV=$tmp/erofs_$seq.img
> + rm -f SCRATCH_DEV
> +fi
> +
> +localdir="$tmp/$seq"
> +rm -rf $localdir
> +mkdir -p $localdir
> +
> +# collect files pending for verification
> +dirs=`find ../ -maxdepth 1 -type d -printf '%p:'`
> +IFS=':'
> +for d in $dirs; do
> + [ $d = '../' ] && continue
> + [ -z "${d##\.\./tests*}" ] && continue
> + [ -z "${d##\.\./\.*}" ] && continue
> + cp -nR $d $localdir
> +done
> +unset IFS
> +
> +# init compress_hints
> +compress_hints="$tmp/compress_hints"
> +rm -rf $compress_hints
> +# ignore warning
> +MKFS_OPTIONS="${MKFS_OPTIONS} -d1 -zlz4hc --compress-hints=$compress_hints"
> +
> +echo "0" > $compress_hints
> +_scratch_mkfs $localdir && \
> + _fail "successfully mkfs with invalid compress_hints"
> +
> +echo "0 \.c$" > $compress_hints
> +echo "1048577 \.am$" >> $compress_hints
> +echo "8192 \.h$" >> $compress_hints
> +_scratch_mkfs $localdir || _fail "failed to mkfs"
> +
> +# verify lz4hc compressed image
> +_require_erofs
> +_require_fssum
> +
> +_scratch_mount 2>>$seqres.full
> +
> +FSSUM_OPTS="-MAC"
> +[ $FSTYP = "erofsfuse" ] && FSSUM_OPTS="${FSSUM_OPTS}T"
> +
> +sum1=`$FSSUM_PROG $FSSUM_OPTS $localdir`
> +echo "$localdir checksum is $sum1" >>$seqres.full
> +sum2=`$FSSUM_PROG $FSSUM_OPTS $SCRATCH_MNT`
> +echo "$SCRATCH_MNT checksum is $sum2" >>$seqres.full
> +
> +[ "x$sum1" = "x$sum2" ] || _fail "-->checkMD5 FAILED"
> +_scratch_unmount
> +
> +echo Silence is golden
> +status=0
> +exit 0
> diff --git a/tests/erofs/017.out b/tests/erofs/017.out
> new file mode 100644
> index 0000000..8222844
> --- /dev/null
> +++ b/tests/erofs/017.out
> @@ -0,0 +1,2 @@
> +QA output created by 017
> +Silence is golden
> --
> 2.25.1
More information about the Linux-erofs
mailing list