diff options
author | Jim Meyering <jim@meyering.net> | 2006-11-18 20:00:39 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-11-18 20:00:39 +0100 |
commit | 0cafba44bbef7c5eb64979544a1ec95a389ec55f (patch) | |
tree | 7bfbb62a72231e651643c6545b5f00f697be1254 /tests | |
parent | 1a0333565f1a89d87b36e7a5c83bac9c145a9916 (diff) | |
download | coreutils-0cafba44bbef7c5eb64979544a1ec95a389ec55f.tar.xz |
"ln --backup f f" produces a misleading diagnostic:
ln: creating hard link `f' => `f': No such file or directory
* src/ln.c (do_link): Give a better diagnostic in this unusual case.
(do_link): Rename local: s/lstat_ok/dest_lstat_ok/.
* tests/ln/Makefile.am (TESTS): Add hard-backup.
* tests/ln/hard-backup: New test for the above.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ln/Makefile.am | 2 | ||||
-rwxr-xr-x | tests/ln/hard-backup | 54 |
2 files changed, 55 insertions, 1 deletions
diff --git a/tests/ln/Makefile.am b/tests/ln/Makefile.am index 8048a9852..79bedce31 100644 --- a/tests/ln/Makefile.am +++ b/tests/ln/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in -*-Makefile-*-. AUTOMAKE_OPTIONS = 1.2 gnits -TESTS = target-1 sf-1 misc backup-1 +TESTS = hard-backup target-1 sf-1 misc backup-1 EXTRA_DIST = $(TESTS) TESTS_ENVIRONMENT = \ PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" diff --git a/tests/ln/hard-backup b/tests/ln/hard-backup new file mode 100755 index 000000000..e37938d38 --- /dev/null +++ b/tests/ln/hard-backup @@ -0,0 +1,54 @@ +#!/bin/sh +# Ensure that 'ln --backup F F' gives a proper diagnostic. + +# Copyright (C) 2006 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + ln --version +fi + +. $srcdir/../envvar-check +. $srcdir/../lang-default + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +touch f || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +ln --backup f f 2> out && fail=1 +cat <<\EOF > exp || fail=1 +ln: `f' and `f' are the same file +EOF + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail |