aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Wibo <obiwac@FreeBSD.org>2026-01-23 22:57:58 +0000
committerAymeric Wibo <obiwac@FreeBSD.org>2026-01-29 15:50:26 +0000
commit578b4ec8f1a4134027e66a156e6cf801284aab14 (patch)
treed963820ba132bdf6bb35de3ae751c8b41a1496ce
parent21efed6cd8442ba9abb6c8a7e54a2433de9bfc60 (diff)
touch: Test for -a flag
Reviewed by: kevans Approved by: kevans Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54852
-rw-r--r--usr.bin/touch/tests/touch_test.sh22
1 files changed, 21 insertions, 1 deletions
diff --git a/usr.bin/touch/tests/touch_test.sh b/usr.bin/touch/tests/touch_test.sh
index 619f81e0e7c3..cd9dc4623612 100644
--- a/usr.bin/touch/tests/touch_test.sh
+++ b/usr.bin/touch/tests/touch_test.sh
@@ -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
}