All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
	linux-erofs@lists.ozlabs.org
Subject: [PATCH] erofs-utils: tests: add test for long xattr name prefixes
Date: Tue, 11 Apr 2023 17:46:49 +0800	[thread overview]
Message-ID: <20230411094649.17733-1-jefflexu@linux.alibaba.com> (raw)

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

Add test case for this feature.

Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
The long xattr name prefix feature is introduced to erofs-utils by
https://lore.kernel.org/all/20230407140902.97275-1-jefflexu@linux.alibaba.com/

The corresponding kernel patches are at
https://lore.kernel.org/all/20230407141710.113882-1-jefflexu@linux.alibaba.com/
---
 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

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 67e2bbc..791cd67 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
diff --git a/tests/erofs/021 b/tests/erofs/021
new file mode 100755
index 0000000..5feffd4
--- /dev/null
+++ b/tests/erofs/021
@@ -0,0 +1,87 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+#
+# 021 - check long extended attribute name prefix
+#
+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
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
-- 
1.8.3.1


             reply	other threads:[~2023-04-11  9:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  9:46 Jingbo Xu [this message]
2023-04-11  9:48 ` [PATCH] erofs-utils: tests: add test for long xattr name prefixes Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230411094649.17733-1-jefflexu@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=xiang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.