diff --git a/tests/Makefile.am b/tests/Makefile.am index fdc1639..bd3e330 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,7 @@ TESTS = \ git-cleanup \ garbage \ global-reject-files \ + hardlinks \ inname \ line-numbers \ merge \ diff --git a/tests/file-create-modes b/tests/file-create-modes index 2ea44ec..e80a79a 100644 --- a/tests/file-create-modes +++ b/tests/file-create-modes @@ -10,6 +10,7 @@ require cat require sed +require chmod use_local_patch use_tmpdir diff --git a/tests/file-modes b/tests/file-modes index 8475182..9c28dd8 100644 --- a/tests/file-modes +++ b/tests/file-modes @@ -10,6 +10,7 @@ require cat require sed +require chmod use_local_patch use_tmpdir diff --git a/tests/hardlinks b/tests/hardlinks new file mode 100644 index 0000000..7eb3a28 --- /dev/null +++ b/tests/hardlinks @@ -0,0 +1,50 @@ +# Copyright 2009-2024 Free Software Foundation, Inc. +# +# Copying and distribution of this file, with or without modification, +# in any medium, are permitted without royalty provided the copyright +# notice and this notice are preserved. + +# Patch must not overwrite backup files it has created itself. +# (Backup file tests for symlinks are in tests/symlinks.) + +. $srcdir/test-lib.sh + +require cat +require hardlinks +use_local_patch +use_tmpdir + +# ============================================================== + +# Hardlinks between source files + +echo one > f +ln f g + +cat > fg.diff < | +# \ / : * ? " < > | TAB +# Filenames with trailing space characters cat > d.diff < f -ln f g - -cat > fg.diff < f cat > f.diff < /dev/null`" in *GNU*) ;; @@ -17,10 +17,55 @@ require_gnu_diff() { esac } +_try_chmod() { + chmod "$1" "$2" && test "`ls -l "$2" | cut -b2-10`" = "$3" +} + +_require_chmod() { + tmp=`mktemp working-chmod.XXXXXXXX` + if ! _try_chmod 644 "$tmp" "rw-r--r--" || \ + ! _try_chmod 600 "$tmp" "rw-------"; then + rm -f "$tmp" + echo "This test requires chmod support" >&2 + exit 77 + fi + rm -f "$tmp" +} + +_require_hardlinks() { + tmpdir=`mktemp -d hardlinks.XXXXXXXX` + if ! touch "$tmpdir/f" || + ! ln "$tmpdir/f" "$tmpdir/g"; then + rm -rf "$tmpdir" + echo "This test requires hardlink support" >&2 + exit 77 + fi + rm -rf "$tmpdir" +} + +_require_symlinks() { + tmpdir=`mktemp -d hardlinks.XXXXXXXX` + if ! touch "$tmpdir/f" || + ! ln -s "f" "$tmpdir/g"; then + rm -rf "$tmpdir" + echo "This test requires symlink support" >&2 + exit 77 + fi + rm -rf "$tmpdir" +} + +_require_special_characters() { + if ! tmp=`mktemp ' '.XXXXXXXX`; then + echo "This test requires special character support in filenames" >&2 + exit 77 + fi + rm -f "$tmp" +} + require() { utility="$1" - if type require_${utility} > /dev/null 2> /dev/null; then - require_${utility} + if type _require_${utility} > /dev/null 2> /dev/null; then + _require_${utility} elif ! type "${utility}" > /dev/null 2> /dev/null; then echo "This test requires the ${utility} utility" >&2 exit 77 diff --git a/tests/unmodified-files b/tests/unmodified-files index 93d078a..77cb8bc 100644 --- a/tests/unmodified-files +++ b/tests/unmodified-files @@ -7,6 +7,7 @@ . $srcdir/test-lib.sh require cat +require hardlinks use_local_patch use_tmpdir