Skip to contentSkip to conversation

Fix some tests that fail for exfat FS

PATCH Superseded Pavel Reichl 2 participants 7 messages Apr 15, 2021 – Apr 19, 2021

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Fix some tests that fail for exfat FS

Mostly just do not run test that require posix permissions and ownership.

Changes in V2 (Thank you for comments on version 1)

* Merged patch #1 and #2 (the one introducing the helper and the other actually using them)
* Fixed generic/597 by introducing _require_symlink
* Fixed generic/598 by adding _require_chmod
** changes are part of patch #1
* Introduced _format_swapon_file()

Changes in version #3 (thanks for the comments and hints!)
* reuse _require_symlinks() instead of introducing _require_symlink()
* implement _require_chown() so it actually checks if chown() is supported.
* Don't special case filtering of MKSWAP_PROG's perm. warn for exfat only.
* Rename _format_swapon_file() to _swapon_file() and also don't special case the perm. warning filtering
* Increase the 'access_delay' by 0.1 s for the exfat to be safe.

Pavel Reichl (4):
common/rc: Add _require_{chown,chmod}()
common: hide permision warning from mkswap for exfat generic/554: hide permision warning on exfat generic/003: Amend the test for exfat

 common/rc         | 33 ++++++++++++++++++++++++++++++++-
 tests/generic/003 | 29 ++++++++++++++++++++---------
 tests/generic/087 |  1 +
 tests/generic/088 |  1 +
 tests/generic/125 |  1 +
 tests/generic/126 |  1 +
 tests/generic/128 |  1 +
 tests/generic/193 |  1 +
 tests/generic/314 |  1 +
 tests/generic/317 |  1 +
 tests/generic/355 |  1 +
 tests/generic/554 |  3 ++-
 tests/generic/597 |  1 +
 tests/generic/598 |  1 +
 14 files changed, 65 insertions(+), 11 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH v3 1/4 common/rc: Add _require_{chown,chmod}()

Add helper functions that ensure that test is only executed on file systems that implement chown, chmod and symbolic links.

Fixed test are: generic/{87,88,125,126,128,193,314,317,355,597,598}

---
 common/rc         | 23 +++++++++++++++++++++++
 tests/generic/087 |  1 +
 tests/generic/088 |  1 +
 tests/generic/125 |  1 +
 tests/generic/126 |  1 +
 tests/generic/128 |  1 +
 tests/generic/193 |  1 +
 tests/generic/314 |  1 +
 tests/generic/317 |  1 +
 tests/generic/355 |  1 +
 tests/generic/597 |  1 +
 tests/generic/598 |  1 +
 12 files changed, 34 insertions(+)
common/rc +23 -0
index 23f86ce6..be292aaf 100644
@@ -2115,6 +2115,29 @@ _require_user()
     [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
 }
 
+# check for a chown support
+#
+_require_chown()
+{
+	rnd_uid=4242
+
+	_require_test
+
+	local file="$TEST_DIR/chown_testfile"
+	touch $file
+	chown ${rnd_uid}:${rnd_uid} $file >/dev/null 2>&1 \
+		|| _notrun "chown is not supported ${FSTYP}"
+	rm -f $file
+}
+
+
+# check for a chmod support
+#
+_require_chmod()
+{
+	_require_chown
+}
+
 # check for a group on the machine, fsgqa as default
 #
 _require_group()
tests/generic/087 +1 -0
index 1f30dbf4..c3576117 100755
@@ -37,6 +37,7 @@ _cleanup()
 # real QA test starts here
 _supported_fs generic
 _require_test
+_require_chown
 
 QA_FS_PERMS=$here/src/fs_perms
 
tests/generic/088 +1 -0
index 9388a083..ad99bd7e 100755
@@ -29,6 +29,7 @@ _filter()
 # real QA test starts here
 _supported_fs generic
 _require_test
+_require_chown
 
 path=$TEST_DIR/t_access
 $here/src/t_access_root $path | tee $seqres.full | _filter
tests/generic/125 +1 -0
index e84248d3..8c8f5cd7 100755
@@ -25,6 +25,7 @@ _supported_fs generic
 _require_test
 _require_user
 _require_odirect
+_require_chmod
 
 TESTDIR=$TEST_DIR/ftrunc
 TESTFILE=$TESTDIR/ftrunc.tmp
tests/generic/126 +1 -0
index ac25d294..636ca00d 100755
@@ -27,6 +27,7 @@ _cleanup()
 # real QA test starts here
 _supported_fs generic
 _require_test
+_require_chown
 
 QA_FS_PERMS=$here/src/fs_perms
 
tests/generic/128 +1 -0
index b3e49eff..c1eae77a 100755
@@ -24,6 +24,7 @@ _supported_fs generic
 
 _require_scratch
 _require_user
+_require_chmod
 
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount "-o nosuid"
tests/generic/193 +1 -0
index 3125efdd..fd0ebbf6 100755
@@ -56,6 +56,7 @@ _supported_fs generic
 
 _require_test
 _require_user
+_require_chown
 
 test_root=$TEST_DIR/$seq.$$.root
 test_user=$TEST_DIR/$seq.$$.user
tests/generic/314 +1 -0
index 03df81ce..540f0feb 100755
@@ -29,6 +29,7 @@ _cleanup()
 _supported_fs generic
 _require_test
 _require_user
+_require_chown
 
 rm -rf $TEST_DIR/$seq-dir
 
tests/generic/317 +1 -0
index 29c37a57..289dfabe 100755
@@ -45,6 +45,7 @@ _require_scratch
 _require_user
 _require_ugid_map
 _require_userns
+_require_chown
 qa_user_id=`id -u $qa_user`
 
 _filter_output()
tests/generic/355 +1 -0
index 161dd042..74fba0f9 100755
@@ -32,6 +32,7 @@ _supported_fs generic
 _require_test
 _require_user
 _require_odirect
+_require_chown
 
 testfile=$TEST_DIR/$seq.test
 rm -f $testfile
tests/generic/597 +1 -0
index ba769d73..6602dc70 100755
@@ -43,6 +43,7 @@ _require_sysctl_variable fs.protected_hardlinks
 _require_user fsgqa2
 # Do this SECOND so that qa_user is fsgqa, and _user_do uses that account
 _require_user fsgqa
+_require_symlinks
 
 OWNER=fsgqa2
 OTHER=fsgqa
tests/generic/598 +1 -0
index 6b765275..230c3ac7 100755
@@ -43,6 +43,7 @@ _require_sysctl_variable fs.protected_fifos
 _require_user fsgqa2
 # Do this SECOND so that qa_user is fsgqa, and _user_do uses that account
 _require_user fsgqa
+_require_chmod
 
 USER1=fsgqa2
 USER2=fsgqa
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH v3 1/4] common/rc: Add _require_{chown,chmod}()

Quoted 40 lines · Pavel Reichl

Add helper functions that ensure that test is only executed on file systems that implement chown, chmod and symbolic links.

Fixed test are: generic/{87,88,125,126,128,193,314,317,355,597,598}

---
 common/rc         | 23 +++++++++++++++++++++++
 tests/generic/087 |  1 +
 tests/generic/088 |  1 +
 tests/generic/125 |  1 +
 tests/generic/126 |  1 +
 tests/generic/128 |  1 +
 tests/generic/193 |  1 +
 tests/generic/314 |  1 +
 tests/generic/317 |  1 +
 tests/generic/355 |  1 +
 tests/generic/597 |  1 +
 tests/generic/598 |  1 +
 12 files changed, 34 insertions(+)
common/rc +11 -0
index 23f86ce6..be292aaf 100644
@@ -2115,6 +2115,29 @@ _require_user()
     [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands."
 }
 
+# check for a chown support
+#
+_require_chown()
+{
+	rnd_uid=4242
+
+	_require_test
+
+	local file="$TEST_DIR/chown_testfile"
+	touch $file
+	chown ${rnd_uid}:${rnd_uid} $file >/dev/null 2>&1 \

common/rc _require_user() · line 2138

Quoted 10 lines
common/rc +10 -0
+		|| _notrun "chown is not supported ${FSTYP}"
+	rm -f $file
+}
+
+
+# check for a chmod support
+#
+_require_chmod()
+{
+	_require_chown

It's not clear to me why _require_chown also works for _require_chmod, other than actually doing chmod test. Some comments would be good.

Thanks,
Eryu

P.S. I've applied other patches in this patchset, thanks for the fixes!

#3 lore raw

Re: [PATCH v3 1/4] common/rc: Add _require_{chown,chmod}()

Quoted 1 line · Eryu Guan

On Thu, Apr 15, 2021 at 11:49:02AM +0200, Pavel Reichl wrote:

...

Quoted 7 lines

common/rc _require_user() · line 2138

Quoted 4 lines
common/rc +4 -0
+#
+_require_chmod()
+{
+	_require_chown

It's not clear to me why _require_chown also works for _require_chmod, other than actually doing chmod test. Some comments would be good.

Yeah, sorry about that. I just sent v4 of this patch that attempts to implement _require_chmod() properly.

Quoted 5 lines

Thanks,
Eryu

P.S. I've applied other patches in this patchset, thanks for the fixes!

Awesome, thanks for the reviews.

Quoted 1 line
#4 lore raw

PATCH v3 2/4 common: hide permision warning from mkswap for exfat

In reply to Pavel Reichl

exfat does not support posix file permisions, so warning from mkswap is inavitable. This patch hides the warning message so the test won't fail.

---
 common/rc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/rc +2 -1
index be292aaf..47098b55 100644
@@ -2374,7 +2374,8 @@ _format_swapfile() {
 	# Swap files must be nocow on Btrfs.
 	$CHATTR_PROG +C "$fname" > /dev/null 2>&1
 	_pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full
-	$MKSWAP_PROG "$fname" >> $seqres.full
+	# Ignore permission complaints on filesystems that don't support perms
+	$MKSWAP_PROG "$fname" 2> >(grep -v 'insecure permission' >&2) >> $seqres.full
 }
 
 # Check that the filesystem supports swapfiles
Signature · 1 line
2.30.2
#5 lore raw

PATCH v3 3/4 generic/554: hide permision warning on exfat

In reply to Pavel Reichl
---
 common/rc         | 7 +++++++
 tests/generic/554 | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
common/rc +7 -0
index 47098b55..fb1f7598 100644
@@ -2378,6 +2378,13 @@ _format_swapfile() {
 	$MKSWAP_PROG "$fname" 2> >(grep -v 'insecure permission' >&2) >> $seqres.full
 }
 
+_swapon_file() {
+	local fname="$1"
+
+	# Ignore permission complaints on filesystems that don't support perms
+	swapon "$fname" 2> >(grep -v "insecure permissions" >&2)
+}
+
 # Check that the filesystem supports swapfiles
 _require_scratch_swapfile()
 {
tests/generic/554 +2 -1
index fa4f97d2..da9bfce5 100755
@@ -46,7 +46,8 @@ $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&
 
 echo swap files return ETXTBUSY
 _format_swapfile $SCRATCH_MNT/swapfile 16m
-swapon $SCRATCH_MNT/swapfile
+_swapon_file $SCRATCH_MNT/swapfile
+
 $XFS_IO_PROG -f -c "copy_range -l 32k $SCRATCH_MNT/file" $SCRATCH_MNT/swapfile
 swapoff $SCRATCH_MNT/swapfile
 
Signature · 1 line
2.30.2
#6 lore raw

PATCH v3 4/4 generic/003: Amend the test for exfat

In reply to Pavel Reichl

Update the test so it can be run even for exfat which has 2 seconds granularity for access_time and does not have a timestamp for metadata change.

---
 tests/generic/003 | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
tests/generic/003 +20 -9
index ec4fdfc1..b2a3db39 100755
@@ -37,6 +37,13 @@ _require_relatime
 
 rm -f $seqres.full
 
+if [ "$FSTYP" = "exfat" ]; then
+	# exfat's timestamp for access_time has double seconds granularity
+	access_delay=2.1
+else
+	access_delay=1
+fi
+
 _stat() {
 	stat -c "%x;%y;%z" $1
 }
@@ -79,14 +86,14 @@ echo "aaa" > $TPATH/dir1/file1
 file1_stat_before_first_access=`_stat $TPATH/dir1/file1`
 
 # Accessing file1 the first time
-sleep 1
+sleep $access_delay
 cat $TPATH/dir1/file1 > /dev/null
 file1_stat_after_first_access=`_stat $TPATH/dir1/file1`
 _compare_stat_times YNN "$file1_stat_before_first_access" \
 	"$file1_stat_after_first_access" "after accessing file1 first time"
 
 # Accessing file1 a second time
-sleep 1
+sleep $access_delay
 cat $TPATH/dir1/file1 > /dev/null
 file1_stat_after_second_access=`_stat $TPATH/dir1/file1`
 _compare_stat_times NNN "$file1_stat_after_first_access" \
@@ -109,7 +116,7 @@ _compare_stat_times NYY "$dir2_stat_before_file_creation" \
 
 # Accessing file2
 file2_stat_before_first_access=`_stat $TPATH/dir2/file2`
-sleep 1
+sleep $access_delay
 cat $TPATH/dir2/file2 > /dev/null
 file2_stat_after_first_access=`_stat $TPATH/dir2/file2`
 _compare_stat_times YNN "$file2_stat_before_first_access" \
@@ -135,11 +142,15 @@ echo "xyz" > $TPATH/dir1/file1
 file1_stat_after_modify=`_stat $TPATH/dir1/file1`
 _compare_stat_times NYY "$file1_stat_before_modify" \
 	"$file1_stat_after_modify" "after modifying file1"
-sleep 1
-mv $TPATH/dir1/file1 $TPATH/dir1/file1_renamed
-file1_stat_after_change=`_stat $TPATH/dir1/file1_renamed`
-_compare_stat_times NNY "$file1_stat_after_modify" \
-	"$file1_stat_after_change" "after changing file1"
+
+# exfat does not support last metadata change timestamp
+if [ "$FSTYP" != "exfat" ]; then
+	sleep 1
+	mv $TPATH/dir1/file1 $TPATH/dir1/file1_renamed
+	file1_stat_after_change=`_stat $TPATH/dir1/file1_renamed`
+	_compare_stat_times NNY "$file1_stat_after_modify" \
+		"$file1_stat_after_change" "after changing file1"
+fi
 
 # Mounting with strictatime option and
 # accessing a previously created file twice
@@ -148,7 +159,7 @@ cat $TPATH/dir2/file3 > /dev/null
 file3_stat_after_second_access=`_stat $TPATH/dir2/file3`
 _compare_stat_times YNN "$file3_stat_after_first_access" \
 	"$file3_stat_after_second_access" "after accessing file3 second time"
-sleep 1
+sleep $access_delay
 cat $TPATH/dir2/file3 > /dev/null
 file3_stat_after_third_access=`_stat $TPATH/dir2/file3`
 _compare_stat_times YNN "$file3_stat_after_second_access" \
Signature · 1 line
2.30.2