The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=21efed6cd8442ba9abb6c8a7e54a2433de9bfc60
commit 21efed6cd8442ba9abb6c8a7e54a2433de9bfc60 Author: Aymeric Wibo <[email protected]> AuthorDate: 2026-01-23 17:48:13 +0000 Commit: Aymeric Wibo <[email protected]> CommitDate: 2026-01-29 15:49:28 +0000 touch: Tests for -h flag Reviewed by: kevans Approved by: kevans Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D54836 --- usr.bin/touch/tests/touch_test.sh | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 }
