Skip to contentSkip to conversation

erofs-utils: tests: restructure test cases for xattr

PATCH New Jingbo Xu 1 participant 6 messages May 25, 2023

lore
Share & tools
lore
author
#1 lore raw

PATCH 1/5 erofs-utils: tests: add generic helper for xattrs

In reply to Jingbo Xu

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.

---
 tests/common/rc | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
tests/common/rc +32 -0
index a9ae369..293e556 100644
@@ -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
Signature · 1 line
1.8.3.1

Jingbo Xu

author
#0 lore raw

cover erofs-utils: tests: restructure test cases for xattr

This series restructures some existing test cases for xattr.

- patch 1/2: some generic helpers are extracted from erofs/019 [1]
- patch 3/4: the previous posted test case [2] checking xattrs in different layouts are split into two test cases, i.e. erofs/020 and erofs/021.
- erofs/020 checks xattrs in different layouts and is independent on the "-b#" feature of mkfs.erofs
- erofs/021 checks xattrs crossing block boundary. It is dependent on the "-b#" feature of mkfs.erofs and will "notrun" if mkfs.erofs doesn't support this feature yet
- patch 5: it's the previous posted test case [3] checking long xattr name prefixes, except that it will "notrun" if mkfs.erofs doesn't support "--xattr-prefix" feature yet

[1] https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/tests/erofs/019?h=experimental-tests
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/

Huang Jianan (1):
erofs-utils: tests: add test for xattrs

Jingbo Xu (4):
erofs-utils: tests: add generic helper for xattrs
erofs-utils: tests: add test for xattrs in different layouts
erofs-utils: tests: add test for xattr crossing block boundary
erofs-utils: tests: add test for long xattr name prefixes

 tests/Makefile.am   | 12 +++++++++
 tests/common/rc     | 44 ++++++++++++++++++++++++++++++
 tests/erofs/019     | 55 ++++++++++++++++++++++++++++++++++++++
 tests/erofs/019.out |  2 ++
 tests/erofs/020     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/020.out |  2 ++
 tests/erofs/021     | 60 +++++++++++++++++++++++++++++++++++++++++
 tests/erofs/021.out |  2 ++
 tests/erofs/022     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/022.out |  2 ++
 10 files changed, 333 insertions(+)
 create mode 100755 tests/erofs/019
 create mode 100644 tests/erofs/019.out
 create mode 100755 tests/erofs/020
 create mode 100644 tests/erofs/020.out
 create mode 100755 tests/erofs/021
 create mode 100644 tests/erofs/021.out
 create mode 100755 tests/erofs/022
 create mode 100644 tests/erofs/022.out
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/5 erofs-utils: tests: add test for xattrs

From: Huang Jianan <[email protected]>

Add basic functional check for xattrs.

---
 tests/Makefile.am   |  3 +++
 tests/erofs/019     | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/019.out |  2 ++
 3 files changed, 60 insertions(+)
 create mode 100755 tests/erofs/019
 create mode 100644 tests/erofs/019.out
tests/Makefile.am +3 -0
index 3bd6ad5..b85ae89 100644
@@ -88,6 +88,9 @@ TESTS += erofs/017
 # 018 - verify lzma compressed image
 TESTS += erofs/018
 
+# 019 - check extended attribute functionality
+TESTS += erofs/019
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/erofs/019 new file +55 -0

55 lines not on this page · raw message

tests/erofs/019.out new file +2 -0
new file mode 100644
index 0000000..163484b
@@ -0,0 +1,2 @@
+QA output created by 019
+Silence is golden
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 3/5 erofs-utils: tests: add test for xattrs in different layouts

In reply to Jingbo Xu

Test extended attributes in following layouts:

- multiple inline xattrs for one single file
- multiple share xattrs for one single file
- mixed inline and share xattrs for one single file

---
 tests/Makefile.am   |  3 +++
 tests/erofs/020     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/020.out |  2 ++
 3 files changed, 82 insertions(+)
 create mode 100755 tests/erofs/020
 create mode 100644 tests/erofs/020.out
tests/Makefile.am +3 -0
index b85ae89..1d6ea5c 100644
@@ -91,6 +91,9 @@ TESTS += erofs/018
 # 019 - check extended attribute functionality
 TESTS += erofs/019
 
+# 020 - check extended attributes in different layouts
+TESTS += erofs/020
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/erofs/020 new file +77 -0

77 lines not on this page · raw message

tests/erofs/020.out new file +2 -0
new file mode 100644
index 0000000..20d7944
@@ -0,0 +1,2 @@
+QA output created by 020
+Silence is golden
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH 4/5 erofs-utils: tests: add test for xattr crossing block boundary

In reply to Jingbo Xu

Test the extended attribute which crosses block boundary.

---
 tests/Makefile.am   |  3 +++
 tests/common/rc     |  6 ++++++
 tests/erofs/021     | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/021.out |  2 ++
 4 files changed, 71 insertions(+)
 create mode 100755 tests/erofs/021
 create mode 100644 tests/erofs/021.out
tests/Makefile.am +3 -0
index 1d6ea5c..61bbb4d 100644
@@ -94,6 +94,9 @@ TESTS += erofs/019
 # 020 - check extended attributes in different layouts
 TESTS += erofs/020
 
+# 021 - check extended attributes crossing block boundary
+TESTS += erofs/021
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/common/rc +6 -0
index 293e556..0361c68 100644
@@ -92,6 +92,12 @@ _require_xattr()
 		_notrun "attr isn't installed, skipped."
 }
 
+_require_mkfs_blksize()
+{
+	"$MKFS_EROFS_PROG" --help 2>&1 | grep -q -- '-b#' ||
+		_notrun "-b# feature needed for mkfs.erofs"
+}
+
 # this test requires erofs kernel support
 _require_erofs()
 {
tests/erofs/021 new file +60 -0

60 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
author
#5 lore raw

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

In reply to Jingbo Xu

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

Add test case for this feature.

---
 tests/Makefile.am   |  3 +++
 tests/common/rc     |  6 +++++
 tests/erofs/022     | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/erofs/022.out |  2 ++
 4 files changed, 88 insertions(+)
 create mode 100755 tests/erofs/022
 create mode 100644 tests/erofs/022.out
tests/Makefile.am +3 -0
index 61bbb4d..6295964 100644
@@ -97,6 +97,9 @@ TESTS += erofs/020
 # 021 - check extended attributes crossing block boundary
 TESTS += erofs/021
 
+# 022 - check long extended attribute name prefixes
+TESTS += erofs/022
+
 EXTRA_DIST = common/rc erofs
 
 clean-local: clean-local-check
tests/common/rc +6 -0
index 0361c68..dcd63a9 100644
@@ -98,6 +98,12 @@ _require_mkfs_blksize()
 		_notrun "-b# feature needed for mkfs.erofs"
 }
 
+_require_mkfs_long_prefix()
+{
+	"$MKFS_EROFS_PROG" --help 2>&1 | grep -q -- '--xattr-prefix' ||
+		_notrun "long name prefix feature needed for mkfs.erofs"
+}
+
 # this test requires erofs kernel support
 _require_erofs()
 {
tests/erofs/022 new file +77 -0

77 lines not on this page · raw message

tests/erofs/022.out new file +2 -0
new file mode 100644
index 0000000..394c6a7
@@ -0,0 +1,2 @@
+QA output created by 022
+Silence is golden
Signature · 1 line
1.8.3.1