git: 2916ae647303 - main - makefs: Fix atime tests on MS-DOS (FAT) file systems

Jose Luis Duran <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a88a3cd.32eb0.38a5be96__9742.1196101763$1787339751$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by jlduran:

URL: https://cgit.FreeBSD.org/src/commit/?id=2916ae647303e3bd92e533002a8e6c476417fe7f

commit 2916ae647303e3bd92e533002a8e6c476417fe7f
Author:     Jose Luis Duran <[email protected]>
AuthorDate: 2026-08-21 19:14:03 +0000
Commit:     Jose Luis Duran <[email protected]>
CommitDate: 2026-08-21 19:14:03 +0000

    makefs: Fix atime tests on MS-DOS (FAT) file systems
    
    On FAT file systems, access time has a resolution of 1 day, so it is
    really the access date.
    
    Strip the time component from the epoch timestamp in order to check the
    access time.
    
    Reference: https://learn.microsoft.com/en-us/windows/win32/sysinfo/file-times
    
    Reviewed by:    ngie
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54584
---
 usr.sbin/makefs/tests/makefs_msdos_tests.sh | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/usr.sbin/makefs/tests/makefs_msdos_tests.sh b/usr.sbin/makefs/tests/makefs_msdos_tests.sh
index f800bbcd6925..3abf17528559 100644
--- a/usr.sbin/makefs/tests/makefs_msdos_tests.sh
+++ b/usr.sbin/makefs/tests/makefs_msdos_tests.sh
@@ -48,6 +48,8 @@ atf_test_case T_flag_dir cleanup
 T_flag_dir_body()
 {
 	timestamp=1742574908 # Even value, timestamp precision is 2s.
+	# FAT directory entries don't have an access time, just a date.
+	timestamp_atime=$((timestamp - timestamp % 86400))
 
 	create_test_dirs
 	mkdir -p $TEST_INPUTS_DIR/dir1
@@ -56,8 +58,7 @@ T_flag_dir_body()
 
 	mount_image
 	eval $(stat -s  $TEST_MOUNT_DIR/dir1)
-	# FAT directory entries don't have an access time, just a date.
-	#atf_check_equal $st_atime $timestamp
+	atf_check_equal $st_atime $timestamp_atime
 	atf_check_equal $st_mtime $timestamp
 	atf_check_equal $st_ctime $timestamp
 }
@@ -72,6 +73,9 @@ T_flag_F_flag_body()
 {
 	timestamp_F=1742574908 # Even value, timestamp precision is 2s.
 	timestamp_T=1742574910
+	# FAT directory entries don't have an access time, just a date.
+	timestamp_F_atime=$((timestamp_F - timestamp_F % 86400))
+
 	create_test_dirs
 	mkdir -p $TEST_INPUTS_DIR/dir1
 
@@ -82,8 +86,7 @@ T_flag_F_flag_body()
 
 	mount_image
 	eval $(stat -s  $TEST_MOUNT_DIR/dir1)
-	# FAT directory entries don't have an access time, just a date.
-	#atf_check_equal $st_atime $timestamp
+	atf_check_equal $st_atime $timestamp_F_atime
 	atf_check_equal $st_mtime $timestamp_F
 	atf_check_equal $st_ctime $timestamp_F
 }
@@ -97,6 +100,8 @@ atf_test_case T_flag_mtree cleanup
 T_flag_mtree_body()
 {
 	timestamp=1742574908 # Even value, timestamp precision is 2s.
+	# FAT directory entries don't have an access time, just a date.
+	timestamp_atime=$((timestamp - timestamp % 86400))
 
 	create_test_dirs
 	mkdir -p $TEST_INPUTS_DIR/dir1
@@ -106,8 +111,7 @@ T_flag_mtree_body()
 
 	mount_image
 	eval $(stat -s  $TEST_MOUNT_DIR/dir1)
-	# FAT directory entries don't have an access time, just a date.
-	#atf_check_equal $st_atime $timestamp
+	atf_check_equal $st_atime $timestamp_atime
 	atf_check_equal $st_mtime $timestamp
 	atf_check_equal $st_ctime $timestamp
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.