touch: Test for -a flag

Reviewed by:	kevans
Approved by:	kevans
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54852
This commit is contained in:
Aymeric Wibo
2026-01-23 23:57:58 +01:00
parent 21efed6cd8
commit 578b4ec8f1
+21 -1
View File
@@ -12,6 +12,12 @@ atf_check_mtime()
atf_check -o inline:"$((mtime))\n" stat -f%m "$filename"
}
atf_check_atime()
{
local atime=$1 filename=$2
atf_check -o inline:"$((atime))\n" stat -f%a "$filename"
}
atf_test_case touch_none
touch_none_head()
{
@@ -173,6 +179,19 @@ touch_symlink_no_h_flag_body()
atf_check_mtime $orig_mtime symlink
}
atf_test_case touch_just_atime
touch_just_atime_head()
{
atf_set descr "Update just access time of file (-a)"
}
touch_just_atime_body()
{
atf_check touch -t 200406151337 file
atf_check touch -at 197209071337 file
atf_check_mtime 1087306620 file
atf_check_atime 84721020 file
}
atf_init_test_cases()
{
atf_add_test_case touch_none
@@ -184,5 +203,6 @@ atf_init_test_cases()
atf_add_test_case touch_nocreate
atf_add_test_case touch_symlink_h_flag
atf_add_test_case touch_symlink_no_h_flag
# TODO: add test cases for -a, -m
atf_add_test_case touch_just_atime
# TODO: add test cases for -m
}