[PATCH] erofs-utils: tests: enhance erofs/019

Jingbo Xu jefflexu at linux.alibaba.com
Sat Mar 25 17:09:54 AEDT 2023


Test xattr in following cases:

- multiple inline xattrs for one single file
- multiple share xattrs for one single file
- mixed inline and share xattrs for one single file
- name/value field of xattr crosses block boundary

Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
---

This is used to test the refactoring on xattr on kernel side[1].

This patch relies on the "-b #blocksize" feature, and thus it needs to
be rebased to "-b experimental" branch of erofs-utils.

[1] https://lore.kernel.org/all/20230323000949.57608-1-jefflexu@linux.alibaba.com/

---
 tests/erofs/019 | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/tests/erofs/019 b/tests/erofs/019
index dac2ae3..f733516 100755
--- a/tests/erofs/019
+++ b/tests/erofs/019
@@ -15,6 +15,11 @@ cleanup()
 	rm -rf $tmp.*
 }
 
+generate_random()
+{
+	head -20 /dev/urandom | base64 -w0 | head -c $1
+}
+
 _require_erofs
 
 # remove previous $seqres.full before test
@@ -37,18 +42,37 @@ rm -rf $localdir
 mkdir -p $localdir
 
 # set random xattrs
-cp -nR ../ $localdir
-dirs=`ls $localdir`
-for d in $dirs; do
-	key=`head -20 /dev/urandom | cksum | cut -f1 -d " "`
-	val="0s"`head -3 /dev/urandom | base64 -w0`
-	setfattr -n user.$key -v $val $localdir/$d
-done
 
+# file1: multiple inline xattrs
+touch $localdir/file1
+setfattr -n user.p$(generate_random 16) -v $(generate_random 16) $localdir/file1
+# inline xattr (large name/value crossing block boundary)
+setfattr -n user.p$(generate_random 249) -v $(generate_random 1024) $localdir/file1
+
+# file2: multiple share xattrs
+s_key_1=$(generate_random 16)
+s_key_2=$(generate_random 16)
+s_val=$(generate_random 16)
+
+touch $localdir/file2
+setfattr -n user.s$s_key_1 -v $s_val $localdir/file2
+setfattr -n user.s$s_key_2 -v $s_val $localdir/file2
+
+# file3: mixed inline and share xattrs
+touch $localdir/file3
+setfattr -n user.p$(generate_random 16) -v $(generate_random 16) $localdir/file3
+setfattr -n user.s$s_key_1 -v $s_val $localdir/file3
+
+# file4: share xattr
+touch $localdir/file4
+setfattr -n user.s$s_key_2 -v $s_val $localdir/file4
+
+MKFS_OPTIONS="$MKFS_OPTIONS -b1024 -x1"
 _scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs"
 _scratch_mount 2>>$seqres.full
 
 # check xattrs
+dirs=`ls $localdir`
 for d in $dirs; do
 	xattr1=`getfattr --absolute-names -d $localdir/$d | tail -n+2`
 	xattr2=`getfattr --absolute-names -d $SCRATCH_MNT/$d | tail -n+2`
-- 
1.8.3.1



More information about the Linux-erofs mailing list