[PATCH 3/4] erofs-utils: tests: add test for dump.erofs

Huang Jianan jnhuang at linux.alibaba.com
Fri Sep 9 12:18:15 AEST 2022


Add basic functional check for dump.erofs.

Signed-off-by: Huang Jianan <jnhuang at linux.alibaba.com>
---
 tests/Makefile.am   |  6 +++-
 tests/erofs/021     | 83 +++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/021.out |  2 ++
 3 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100755 tests/erofs/021
 create mode 100644 tests/erofs/021.out

diff --git a/tests/Makefile.am b/tests/Makefile.am
index b85ae89..bb1624d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,7 +22,8 @@ TESTS_ENVIRONMENT = \
 	fi; \
 	[ -z $$MKFS_EROFS_PROG ] && export MKFS_EROFS_PROG=../mkfs/mkfs.erofs; \
 	[ -z $$FSCK_EROFS_PROG ] && export FSCK_EROFS_PROG=../fsck/fsck.erofs; \
-	[ -z $$EROFSFUSE_PROG ] && export EROFSFUSE_PROG=../fuse/erofsfuse;
+	[ -z $$EROFSFUSE_PROG ] && export EROFSFUSE_PROG=../fuse/erofsfuse; \
+	[ -z $$DUMP_EROFS_PROG ] && export DUMP_EROFS_PROG=../dump/dump.erofs;
 
 if ENABLE_LZ4
 TESTS_ENVIRONMENT += export lz4_on=1;
@@ -91,6 +92,9 @@ TESTS += erofs/018
 # 019 - check extended attribute functionality
 TESTS += erofs/019
 
+# 021 - check dump basic functionality
+TESTS += erofs/021
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
diff --git a/tests/erofs/021 b/tests/erofs/021
new file mode 100755
index 0000000..2bb45e7
--- /dev/null
+++ b/tests/erofs/021
@@ -0,0 +1,83 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+#
+# 021 check dump basic functionality
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$(echo $0 | awk '{print $((NF-1))"/"$NF}' FS="/")
+
+# get standard environment, filters and checks
+. "${srcdir}/common/rc"
+
+cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+_require_erofs
+
+# 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 ]; 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
+
+uuid="98136b8d-d5a7-429c-b6ea-2021f19d7d93"
+timestamp="Thu Jan  1 08:00:00 1970"
+
+MKFS_OPTIONS="${MKFS_OPTIONS} -zlz4hc -T0 -U$uuid"
+_scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs"
+_scratch_mount 2>>$seqres.full
+
+do_dump="$DUMP_EROFS_PROG $SCRATCH_DEV"
+echo "dump information for $SCRATCH_DEV" >>$seqres.full
+
+uuid_dump=`$do_dump |awk '/UUID/{print $3}'`
+echo "uuid: $uuid_dump" >>$seqres.full
+[ "x$uuid" = "x$uuid_dump" ] || _fail "check uuid fail"
+
+timestamp_dump=`$do_dump |awk -F"created:[ ]+" '/created:/{print $2}'`
+echo "timestamp: $timestamp_dump" >>$seqres.full
+[ "x$timestamp" = "x$timestamp_dump" ] || _fail "check timestamp fail"
+
+nid_sb=`$do_dump |awk '/root nid/{print $4}'`
+echo "root nid from superblock: $nid_sb" >>$seqres.full
+nid_ino=`$do_dump --path=/ |awk '/NID/{print $2}'`
+echo "root nid from inode: $nid_ino" >>$seqres.full
+[ "x$nid_sb" = "x$nid_ino" ] || _fail "check root nid fail"
+
+dirs_dump=`$do_dump --path=/ --ls |awk '/\s*[0-9]+\s+[0-9]+\s+/{print $3}'`
+echo "list root directory:\n$dirs_dump" >>$seqres.full
+dirs_ls=`ls -aU $SCRATCH_MNT`
+echo "list root directory for $SCRATCH_MNT:\n$dirs_ls" >>$seqres.full
+[ "x$dirs_dump" = "x$dirs_ls" ] || _fail "check ls fail"
+
+_scratch_unmount
+
+echo Silence is golden
+status=0
+exit 0
diff --git a/tests/erofs/021.out b/tests/erofs/021.out
new file mode 100644
index 0000000..09f4062
--- /dev/null
+++ b/tests/erofs/021.out
@@ -0,0 +1,2 @@
+QA output created by 021
+Silence is golden
-- 
2.34.1



More information about the Linux-erofs mailing list