Skip to contentSkip to conversation

erofs-utils: tests: add test for long xattr name prefixes

PATCH Superseded Jingbo Xu 2 participants 2 messages Apr 11, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

PATCH 1/1 erofs-utils: tests: add test for long xattr name prefixes

mkfs.erofs supports user specified long xattr name prefix through "--xattr_prefixes" option.

Add test case for this feature.

---
The long xattr name prefix feature is introduced to erofs-utils by
https://lore.kernel.org/all/[email protected]/

The corresponding kernel patches are at
https://lore.kernel.org/all/[email protected]/

---
 tests/Makefile.am   |  3 ++
 tests/erofs/021     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/021.out |  2 ++
 3 files changed, 92 insertions(+)
 create mode 100755 tests/erofs/021
 create mode 100644 tests/erofs/021.out
tests/Makefile.am +3 -0
index 67e2bbc..791cd67 100644
@@ -94,6 +94,9 @@ TESTS += erofs/019
 # 020 - check extended attribute in different layouts
 TESTS += erofs/020
 
+# 021 - check long extended attribute name prefix
+TESTS += erofs/021
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/erofs/021 new file +87 -0

87 lines not on this page · raw message

tests/erofs/021.out new file +2 -0
new file mode 100644
index 0000000..09f4062
@@ -0,0 +1,2 @@
+QA output created by 021
+Silence is golden
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 2 lines · Jingbo Xu

mkfs.erofs supports user specified long xattr name prefix through "--xattr_prefixes" option.

--xattr_prefix?

Quoted 23 lines

Add test case for this feature.

---
The long xattr name prefix feature is introduced to erofs-utils by
https://lore.kernel.org/all/[email protected]/

The corresponding kernel patches are at
https://lore.kernel.org/all/[email protected]/

---
  tests/Makefile.am   |  3 ++
  tests/erofs/021     | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/erofs/021.out |  2 ++
  3 files changed, 92 insertions(+)

create mode 100755 tests/erofs/021
create mode 100644 tests/erofs/021.out

tests/Makefile.am +0 -0
index 67e2bbc..791cd67 100644

tests/Makefile.am TESTS += erofs/019 · line 97

Quoted 4 lines
tests/Makefile.am +1 -0
@@ -94,6 +94,9 @@ TESTS += erofs/019
  # 020 - check extended attribute in different layouts
  TESTS += erofs/020
 
+# 021 - check long extended attribute name prefix

# 021 - check long extended attribute name prefixes

Quoted 11 lines
tests/Makefile.am +2 -0
+TESTS += erofs/021
+
  EXTRA_DIST = common/rc erofs
 
  clean-local: clean-local-check
tests/erofs/021 new file +0 -0
new file mode 100755
index 0000000..5feffd4

tests/erofs/021 line 4

Quoted 4 lines
tests/erofs/021 new file +4 -0
@@ -0,0 +1,87 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+#
+# 021 - check long extended attribute name prefix

# 021 - check long extended attribute name prefixes

Quoted 91 lines
tests/erofs/021 new file +83 -0
+#
+set -x
+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.*
+}
+
+generate_random()
+{
+	head -20 /dev/urandom | base64 -w0 | head -c $1
+}
+
+_require_erofs
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+echo "QA output created by $seq"
+
+have_attr=`which setfattr`
+[ -z "$have_attr" ] && \
+	_notrun "attr isn't installed, 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
+
+# set random xattrs
+
+# file1: multiple inline xattrs
+touch $localdir/file1
+setfattr -n user.infix.p$(generate_random 16) -v $(generate_random 16) $localdir/file1
+setfattr -n user.infix.p$(generate_random 16) -v $(generate_random 16) $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.infix.s$s_key_1 -v $s_val $localdir/file2
+setfattr -n user.infix.s$s_key_2 -v $s_val $localdir/file2
+
+# file3: mixed inline and share xattrs
+touch $localdir/file3
+setfattr -n user.infix.p$(generate_random 16) -v $(generate_random 16) $localdir/file3
+setfattr -n user.infix.s$s_key_1 -v $s_val $localdir/file3
+
+# file4: share xattr
+touch $localdir/file4
+setfattr -n user.infix.s$s_key_2 -v $s_val $localdir/file4
+
+# specify long xattr name prefix through "--xattr-prefix"
+MKFS_OPTIONS="$MKFS_OPTIONS -x1 --xattr-prefix=user.infix."
+_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`
+	[ "x$xattr1" = "x$xattr2" ] || _fail "-->check xattrs FAILED"
+done
+
+_scratch_unmount
+
+echo Silence is golden
+status=0
+exit 0
tests/erofs/021.out new file +2 -0
new file mode 100644
index 0000000..09f4062
@@ -0,0 +1,2 @@
+QA output created by 021
+Silence is golden