aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAymeric Wibo <obiwac@FreeBSD.org>2026-01-23 17:48:13 +0000
committerAymeric Wibo <obiwac@FreeBSD.org>2026-01-29 15:49:28 +0000
commit21efed6cd8442ba9abb6c8a7e54a2433de9bfc60 (patch)
tree4df68a3bf137cecdc28e8aa711083821c665d88d
parent627e126dbb07b167b028380ef61bb45f10493938 (diff)
touch: Tests for -h flag
Reviewed by: kevans Approved by: kevans Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54836
-rw-r--r--usr.bin/touch/tests/touch_test.sh33
1 files changed, 32 insertions, 1 deletions
diff --git a/usr.bin/touch/tests/touch_test.sh b/usr.bin/touch/tests/touch_test.sh
index da39abef622e..619f81e0e7c3 100644
--- a/usr.bin/touch/tests/touch_test.sh
+++ b/usr.bin/touch/tests/touch_test.sh
@@ -144,6 +144,35 @@ touch_nocreate_body()
atf_check -s exit:1 test -f bar
}
+atf_test_case touch_symlink_h_flag
+touch_symlink_h_flag_head()
+{
+ atf_set descr "Update time of symlink but not file pointed to"
+}
+touch_symlink_h_flag_body()
+{
+ atf_check touch -t 200406151337 pointed
+ atf_check ln -s pointed symlink
+ atf_check touch -t 197209071337 -h symlink
+ atf_check_mtime 1087306620 pointed
+ atf_check_mtime 84721020 symlink
+}
+
+atf_test_case touch_symlink_no_h_flag
+touch_symlink_no_h_flag_head()
+{
+ atf_set descr "Update time of file pointed to but not symlink"
+}
+touch_symlink_no_h_flag_body()
+{
+ atf_check touch -t 200406151337 pointed
+ atf_check ln -s pointed symlink
+ local orig_mtime=$(stat -f %m symlink)
+ atf_check touch -t 197209071337 symlink
+ atf_check_mtime 84721020 pointed
+ atf_check_mtime $orig_mtime symlink
+}
+
atf_init_test_cases()
{
atf_add_test_case touch_none
@@ -153,5 +182,7 @@ atf_init_test_cases()
atf_add_test_case touch_relative
atf_add_test_case touch_copy
atf_add_test_case touch_nocreate
- # TODO: add test cases for -a, -h, -m
+ atf_add_test_case touch_symlink_h_flag
+ atf_add_test_case touch_symlink_no_h_flag
+ # TODO: add test cases for -a, -m
}