]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: test: add test cases for -ef
authorCollin Funk <collin.funk1@gmail.com>
Thu, 13 Nov 2025 03:58:52 +0000 (19:58 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 13 Nov 2025 18:53:45 +0000 (10:53 -0800)
* tests/test/test-file.sh: Check that -ef works as expected on files,
symbolic links, and hard links.

tests/test/test-file.sh

index d5fb449672e6ce76d0a2fa7b132f713fcb63b26e..026ca9778a3d3c721d6c1f9bccb2e43d256c1f9c 100755 (executable)
@@ -61,4 +61,34 @@ returns_ 1 env test file1 -nt file2 || fail=1
 env test file1 -ot file2 || fail=1
 returns_ 1 env test file2 -ot file1 || fail=1
 
+# Test "-ef" on files that do not resolve.
+returns_ 1 env test missing1 -ef missing2 || fail=1
+returns_ 1 env test missing2 -ef missing1 || fail=1
+returns_ 1 env test file1 -ef missing1 || fail=1
+returns_ 1 env test missing1 -ef file1 || fail=1
+
+# Test "-ef" on normal files.
+env test file1 -ef file1 || fail=1
+returns_ 1 env test file1 -ef file2 || fail=1
+
+# Test "-ef" on symbolic links.
+ln -s file1 symlink1 || framework_failure_
+ln -s file2 symlink2 || framework_failure_
+env test file1 -ef symlink1 || fail=1
+env test symlink1 -ef file1 || fail=1
+returns_ 1 env test file1 -ef symlink2 || fail=1
+returns_ 1 env test symlink2 -ef file1 || fail=1
+returns_ 1 env test symlink1 -ef symlink2 || fail=1
+returns_ 1 env test symlink2 -ef symlink1 || fail=1
+
+# Test "-ef" on hard links.
+if ln file1 hardlink1 && ln file2 hardlink2; then
+  env test file1 -ef hardlink1 || fail=1
+  env test hardlink1 -ef file1 || fail=1
+  returns_ 1 env test file1 -ef hardlink2 || fail=1
+  returns_ 1 env test hardlink2 -ef file1 || fail=1
+  returns_ 1 env test hardlink1 -ef hardlink2 || fail=1
+  returns_ 1 env test hardlink2 -ef hardlink1 || fail=1
+fi
+
 Exit $fail