erofs-utils: tests: add compression algorithms check for tests
PATCH 1/1 erofs-utils: tests: add compression algorithms check for tests
_require_erofs_compression is added to check whether the compression algorithms are supported in the test environment before starting tests.
Signed-off-by Jiawei Wang <[email protected]>
--- tests/common/rc | 16 ++++++++++++++++ tests/erofs/008 | 2 ++ tests/erofs/009 | 2 ++ tests/erofs/010 | 2 ++ tests/erofs/011 | 2 ++ tests/erofs/017 | 2 ++ tests/erofs/018 | 2 ++ tests/erofs/024 | 2 ++ 8 files changed, 30 insertions(+)
tests/common/rc +16 -0
@@ -148,6 +148,22 @@ _require_fscache() [ -x $CACHEFILESD_PROG ] || _notrun "cachefilesd not built" } +_require_erofs_compression() +{ + local opt="$*" + local random_dir="$tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)" + + mkdir -p $random_dir/test $random_dir/mnt > /dev/null 2>&1 + truncate -s 1m $random_dir/test/file > /dev/null 2>&1 + + eval "$MKFS_EROFS_PROG $opt $random_dir/tmp.erofs $random_dir/test" >> /dev/null 2>&1 + _try_mount $random_dir/tmp.erofs $random_dir/mnt || \ + _notrun "fail to mount filesystem in _require_erofs_compression" + _do_unmount $random_dir/mnt + + rm -rf $random_dir +} + # Do the actual mkfs work. _do_mkfs() {
tests/erofs/008 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lz4_on" ] && \ _notrun "lz4 compression is disabled, skipped." +_require_erofs_compression "-zlz4" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/009 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lz4hc_on" ] && \ _notrun "lz4hc compression is disabled, skipped." +_require_erofs_compression "-zlz4hc" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/010 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lz4_on" ] && \ _notrun "lz4 compression is disabled, skipped." +_require_erofs_compression "-zlz4" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/011 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lz4hc_on" ] && \ _notrun "lz4hc compression is disabled, skipped." +_require_erofs_compression "-zlz4hc" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/017 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lz4_on" ] && \ _notrun "lz4 compression is disabled, skipped." +_require_erofs_compression "-zlz4" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/018 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$lzma_on" ] && \ _notrun "lzma compression is disabled, skipped." +_require_erofs_compression "-zlzma" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
tests/erofs/024 +2 -0
@@ -27,6 +27,8 @@ echo "QA output created by $seq" [ -z "$deflate_on" ] && \ _notrun "deflate compression is disabled, skipped." +_require_erofs_compression "-zdeflate,9" + if [ -z $SCRATCH_DEV ]; then SCRATCH_DEV=$tmp/erofs_$seq.img rm -f SCRATCH_DEV
Signature · 1 line
2.34.1