* tests/ln/misc.sh: Use getlimits_. Check the behavior of 'ln -f' with a
missing target an existing file and a file where the link would be
placed.
---
 tests/ln/misc.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/ln/misc.sh b/tests/ln/misc.sh
index 612cc4bc7..6e8dfc4b3 100755
--- a/tests/ln/misc.sh
+++ b/tests/ln/misc.sh
@@ -18,6 +18,7 @@
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ln
+getlimits_
 
 t=tln-symlink
 d=tln-subdir
@@ -96,6 +97,18 @@ ln --no-dereference -fs "$af" $ld || fail=1
 test -f $ld || fail=1
 rm -rf $d $f $ld
 
+# Test that 'ln -f' doesn't overwrite a file with a link when the
+# target does not exist.
+cat <<EOF >exp || framework_failure_
+ln: failed to access 'missing': $ENOENT
+EOF
+echo a > $f || framework_failure_
+cp $f exp-$f || framework_failure_
+returns_ 1 ln -f missing $f >out 2>err || fail=1
+compare /dev/null out || fail=1
+compare exp err || fail=1
+compare exp-$f $f || fail=1
+
 # -f on a existing file should not generate an error
 rm -rf $d $f
 touch $f || framework_failure_
-- 
2.55.0


Reply via email to