4 # Copyright (C) 2009-2016 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
23 # ===================================================
24 # ensure -s silently overrides -L, -P
25 touch a || framework_failure_
26 ln -L -s a symlink1 || fail
=1
27 ln -P -s symlink1 symlink2 || fail
=1
28 ln -s -L -P symlink2 symlink3 || fail
=1
30 # ===================================================
31 # ensure that -L follows symlinks, and overrides -P
32 if ln -P -L symlink3 hard-to-a
; then
33 ls=$
(ls -lG hard-to-a
)x
36 *'hard-to-a -> '*x
) fail
=1 ;;
37 *) framework_failure_
;;
43 # ===================================================
44 # ensure that -P links (or at least duplicates) symlinks, and overrides -L
45 if ln -L -P symlink3 hard-to-3
; then
46 ls=$
(ls -lG hard-to-3
)x
48 *'hard-to-3 -> symlink2x') ;;
49 *'hard-to-3x') fail
=1 ;;
50 *'hard-to-3 -> '*x
) fail
=1 ;;
51 *) framework_failure_
;;
57 # ===================================================
58 # Create a hard link to a dangling symlink.
59 ln -s /no-such-dir || framework_failure_
60 ln -L no-such-dir hard-to-dangle
2>err
&& fail
=1
62 *" failed to access 'no-such-dir'":*) ;;
65 ln -P no-such-dir hard-to-dangle || fail
=1
67 # ===================================================
68 # Create a hard link to a symlink to a directory.
69 mkdir d || framework_failure_
70 ln -s d link-to-dir || framework_failure_
71 ln -L link-to-dir hard-to-dir-link
2>err
&& fail
=1
73 *": link-to-dir: hard link not allowed for directory"*) ;;
76 ln -P link-to-dir
/ hard-to-dir-link
2>err
&& fail
=1
78 *": link-to-dir/: hard link not allowed for directory"*) ;;
81 ln -P link-to-dir hard-to-dir-link || fail
=1