From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
linux-erofs@lists.ozlabs.org
Subject: [PATCH 1/5] erofs-utils: tests: add generic helper for xattrs
Date: Thu, 25 May 2023 16:31:57 +0800 [thread overview]
Message-ID: <20230525083201.23740-2-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20230525083201.23740-1-jefflexu@linux.alibaba.com>
Add a helper checking if xattr progs are available.
Add helpers generating random strings which could be used as
key/value of xattr.
Add a helper checking if same named files under two directories have
same xattrs.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
tests/common/rc | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tests/common/rc b/tests/common/rc
index a9ae369..293e556 100644
--- a/tests/common/rc
+++ b/tests/common/rc
@@ -86,6 +86,12 @@ _require_root()
[ "$(id -u)" = "0" ] || _notrun "must be run as root"
}
+_require_xattr()
+{
+ which setfattr >/dev/null 2>&1 ||
+ _notrun "attr isn't installed, skipped."
+}
+
# this test requires erofs kernel support
_require_erofs()
{
@@ -315,6 +321,32 @@ _require_fssum()
[ -x $FSSUM_PROG ] || _notrun "fssum not built"
}
+# generate random string with maximum $1 length
+_random()
+{
+ head -20 /dev/urandom | base64 -w0 | head -c $1
+}
+
+# generate short random string
+_srandom()
+{
+ _random 16
+}
+
+# check xattrs of same files under two directories
+_check_xattrs()
+{
+ local dir1="$1"
+ local dir2="$2"
+ local dirs=`ls $dir1`
+
+ 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`
+ [ "x$xattr1" = "x$xattr2" ] || _fail "-->check xattrs FAILED"
+ done
+}
+
_check_results()
{
[ -z $srcdir ] && return 0
--
1.8.3.1
next prev parent reply other threads:[~2023-05-25 8:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 8:31 [PATCH 0/5] erofs-utils: tests: restructure test cases for xattr Jingbo Xu
2023-05-25 8:31 ` Jingbo Xu [this message]
2023-05-25 8:31 ` [PATCH 2/5] erofs-utils: tests: add test for xattrs Jingbo Xu
2023-05-25 8:31 ` [PATCH 3/5] erofs-utils: tests: add test for xattrs in different layouts Jingbo Xu
2023-05-25 8:32 ` [PATCH 4/5] erofs-utils: tests: add test for xattr crossing block boundary Jingbo Xu
2023-05-25 8:32 ` [PATCH 5/5] erofs-utils: tests: add test for long xattr name prefixes Jingbo Xu
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=20230525083201.23740-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox