* [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory
@ 2023-06-14 3:26 Jingbo Xu
2023-06-14 3:26 ` [PATCH 2/2] erofs-utils: tests: add test for xattrs in random layouts Jingbo Xu
2023-06-14 7:49 ` [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Gao Xiang
0 siblings, 2 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-06-14 3:26 UTC (permalink / raw)
To: hsiangkao, linux-erofs; +Cc: huyue2
Enhance _check_xattrs() helper checking all descendants under the
target directory.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
tests/common/rc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/common/rc b/tests/common/rc
index dcd63a9..f234fdc 100644
--- a/tests/common/rc
+++ b/tests/common/rc
@@ -350,11 +350,11 @@ _check_xattrs()
{
local dir1="$1"
local dir2="$2"
- local dirs=`ls $dir1`
+ local entries=`find $dir1 -mindepth 1 -printf '%P\n' -type f`
- for d in $dirs; do
- xattr1=`getfattr --absolute-names -d $dir1/$d | tail -n+2`
- xattr2=`getfattr --absolute-names -d $dir2/$d | tail -n+2`
+ for entry in $entries; do
+ xattr1=`getfattr --absolute-names -d $dir1/$entry | tail -n+2`
+ xattr2=`getfattr --absolute-names -d $dir2/$entry | tail -n+2`
[ "x$xattr1" = "x$xattr2" ] || _fail "-->check xattrs FAILED"
done
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] erofs-utils: tests: add test for xattrs in random layouts
2023-06-14 3:26 [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Jingbo Xu
@ 2023-06-14 3:26 ` Jingbo Xu
2023-06-14 7:49 ` [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Gao Xiang
1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-06-14 3:26 UTC (permalink / raw)
To: hsiangkao, linux-erofs; +Cc: huyue2
Generate and check random xattrs. Set xattrs on tested file as much
as possible until the number or size of xattrs has reached the upper
limit for single file, e.g. maximum one block size for xattrs for
single file in ext4.
The same xattr may be shared among multiple tested files or not.
Thus the layout of mixed inline and shared xattrs is tested.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
tests/Makefile.am | 3 ++
tests/erofs/023 | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/erofs/023.out | 2 +
3 files changed, 109 insertions(+)
create mode 100755 tests/erofs/023
create mode 100644 tests/erofs/023.out
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6295964..b0e7806 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -100,6 +100,9 @@ TESTS += erofs/021
# 022 - check long extended attribute name prefixes
TESTS += erofs/022
+# 023 - check extended attributes in random layouts
+TESTS += erofs/023
+
EXTRA_DIST = common/rc erofs
clean-local: clean-local-check
diff --git a/tests/erofs/023 b/tests/erofs/023
new file mode 100755
index 0000000..7998705
--- /dev/null
+++ b/tests/erofs/023
@@ -0,0 +1,104 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+#
+# 023 - check extended attributes in random layouts
+#
+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
+_require_xattr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+echo "QA output created by $seq"
+
+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
+
+# feed random seed
+RANDOM=$$
+
+# build file list of all descendant files under the directory
+cp -nR ../ $localdir
+entries=`find $localdir -mindepth 1 -type f -not -path '*git*' -printf '%P\n'`
+i=0
+for file in $entries; do
+ files[$i]="$file"
+ i=$((i+1))
+done
+num_files=${#files[*]}
+[ $num_files -eq 0 ] && _notrun "empty file list"
+
+# set random xattrs
+for file in ${files[*]}; do
+ while true; do
+ key=$(_random $(($RANDOM%32)))
+ val=$(_random $(($RANDOM%32)))
+
+ # allow of xattrs with empty value
+ VAL_OPTIONS=""
+ if [ -n "$val" ]; then
+ VAL_OPTIONS="-v $val"
+ fi
+
+ # move to next file if the disk space for xattr has been consumed
+ # for the current file
+ setfattr -n user.$key $VAL_OPTIONS $localdir/$file >>$seqres.full 2>&1 \
+ || break
+
+ # share this xattr or not?
+ if [ $(($RANDOM%2)) -ne 0 ]; then
+ # tag this xattr to other files to build shared xattrs
+ # generate a random step in [1, 64]
+ step=$(($(($RANDOM%64))+1))
+ i=0
+ while true; do
+ i=$(($i+$step))
+ if [ $i -lt $num_files ]; then
+ setfattr -n user.$key $VAL_OPTIONS $localdir/${files[$i]} \
+ >>$seqres.full 2>&1
+ else
+ break
+ fi
+ done
+ fi
+ done
+done
+
+# round 1: test mixed of inline and shared xattrs (default)
+_scratch_unmount
+MKFS_OPTIONS="$MKFS_OPTIONS"
+_scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs"
+_scratch_mount 2>>$seqres.full
+_check_xattrs $localdir $SCRATCH_MNT
+
+# round 2: test shared xattrs
+_scratch_unmount
+MKFS_OPTIONS="$MKFS_OPTIONS -x1"
+_scratch_mkfs $localdir >> $seqres.full 2>&1 || _fail "failed to mkfs"
+_scratch_mount 2>>$seqres.full
+_check_xattrs $localdir $SCRATCH_MNT
+
+_scratch_unmount
+
+echo Silence is golden
+status=0
+exit 0
diff --git a/tests/erofs/023.out b/tests/erofs/023.out
new file mode 100644
index 0000000..5c4197b
--- /dev/null
+++ b/tests/erofs/023.out
@@ -0,0 +1,2 @@
+QA output created by 023
+Silence is golden
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory
2023-06-14 3:26 [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Jingbo Xu
2023-06-14 3:26 ` [PATCH 2/2] erofs-utils: tests: add test for xattrs in random layouts Jingbo Xu
@ 2023-06-14 7:49 ` Gao Xiang
1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2023-06-14 7:49 UTC (permalink / raw)
To: Jingbo Xu, linux-erofs; +Cc: huyue2
On 2023/6/14 11:26, Jingbo Xu wrote:
> Enhance _check_xattrs() helper checking all descendants under the
> target directory.
>
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
I've folded this patch into
"erofs-utils: tests: add generic helper for xattrs"
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-14 7:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-14 3:26 [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Jingbo Xu
2023-06-14 3:26 ` [PATCH 2/2] erofs-utils: tests: add test for xattrs in random layouts Jingbo Xu
2023-06-14 7:49 ` [PATCH 1/2] erofs-utils: tests: check xattrs for all descendants under target directory Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox