diff mbox series

[v2,4/4] generic/003: Amend the test for exfat

Message ID 20210330220005.56019-5-preichl@redhat.com (mailing list archive)
State New
Headers show
Series Fix some tests that fail for exfat FS | expand

Commit Message

Pavel Reichl March 30, 2021, 10 p.m. UTC
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.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
 tests/generic/003 | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

Comments

Eric Sandeen April 7, 2021, 6:03 p.m. UTC | #1
On 3/30/21 5:00 PM, Pavel Reichl wrote:
> 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.
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>

This looks a whole lot like what I was playing with earlier.  :)

Can you run it say 20 times in a row, and make sure that you don't get
spurious failures by sleeping for /exactly/ the atime granularity?

Thanks,
-Eric
Pavel Reichl April 15, 2021, 9:14 a.m. UTC | #2
On 4/7/21 8:03 PM, Eric Sandeen wrote:
> On 3/30/21 5:00 PM, Pavel Reichl wrote:
>> 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.
>>
>> Signed-off-by: Pavel Reichl <preichl@redhat.com>
> 
> This looks a whole lot like what I was playing with earlier.  :)

good :-)

> 
> Can you run it say 20 times in a row, and make sure that you don't get
> spurious failures by sleeping for /exactly/ the atime granularity?

I tried that for tens of times and no failure. However, since sleep() does not require integer as the parameter, in the next revision I'll propose something as a 2.1 instead of the 2 to be on the safe side, OK?

> 
> Thanks,
> -Eric
>
diff mbox series

Patch

diff --git a/tests/generic/003 b/tests/generic/003
index ec4fdfc1..39596665 100755
--- a/tests/generic/003
+++ b/tests/generic/003
@@ -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
+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" \