2
# Exercise the fix for http://debbugs.gnu.org/8419
4
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
25
u=$(stat --format %i "$1") &&
26
v=$(stat --format %i "$2") && test "$u" = "$v"
32
mkdir s || framework_failure_
34
# a missing link in dest will be created
35
touch s/f || framework_failure_
36
ln s/f s/linkm || framework_failure_
38
# an existing link in dest will be maintained
39
ln s/f s/linke || framework_failure_
41
# a separate older file in dest will be overwritten
42
ln s/f s/fileo || framework_failure_
44
# a separate newer file in dest will be overwritten!
45
ln s/f s/fileu || framework_failure_
50
f=$1 # which of f or linkm to create in t/
53
mkdir -p t/s/ || framework_failure_
55
# a missing link in dest must be created
56
touch t/s/$f || framework_failure_
58
# an existing link must be maintained
59
ln t/s/$f t/s/linke || framework_failure_
61
# a separate older file in dest will be overwritten
62
touch -d '-1 hour' t/s/fileo || framework_failure_
64
# a separate newer file in dest will be overwritten!
65
touch -d '+1 hour' t/s/fileu || framework_failure_
69
# Note we repeat this, creating either one of
70
# two hard linked files from source in the dest, so as to
71
# test both paths in $(cp) for creating the hard links.
72
# The path taken by cp is dependent on which cp encounters
73
# first in the source, which is non deterministic currently
74
# (I'm guessing that results are sorted by inode and
75
# beauses they're the same here, and due to the sort
76
# being unstable, either can be processed first).
82
# Copy all the hard links across. With cp from coreutils-8.12
83
# and prior, it would sometimes mistakenly copy rather than link.
86
same_inode t/s/f t/s/linkm || fail=1
87
same_inode t/s/f t/s/linke || fail=1
88
same_inode t/s/f t/s/fileo || fail=1
89
same_inode t/s/f t/s/fileu || fail=1