touch: Tests for -h flag

Reviewed by:	kevans
Approved by:	kevans
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54836
This commit is contained in:
Aymeric Wibo
2026-01-23 18:48:13 +01:00
parent 627e126dbb
commit 21efed6cd8
+32 -1
View File
@@ -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
}