3 if test "$VERBOSE" = yes; then
10 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
11 trap '(exit $?); exit' 1 2 13 15
14 mkdir $tmp || framework_failure=1
15 cd $tmp || framework_failure=1
19 ld=tln-symlink-to-subdir
23 # Create a simple symlink with both source and destination files
24 # in current directory.
25 touch $f || framework_failure=1
26 rm -f $t || framework_failure=1
31 # Create a symlink with source file and explicit destination directory/file.
32 touch $f || framework_failure=1
33 rm -rf $d || framework_failure=1
34 mkdir $d || framework_failure=1
35 ln -s ../$f $d/$t || fail=1
36 test -f $d/$t || fail=1
39 # Create a symlink with source file and destination directory.
40 touch $f || framework_failure=1
41 rm -rf $d || framework_failure=1
42 mkdir $d || framework_failure=1
43 ln -s ../$f $d || fail=1
44 test -f $d/$f || fail=1
47 # See whether a trailing slash is followed too far.
48 touch $f || framework_failure=1
49 rm -rf $d || framework_failure=1
50 mkdir $d $d/$f || framework_failure=1
51 ln $f $d/ 2> /dev/null && fail=1
52 ln -s $f $d/ 2> /dev/null && fail=1
55 # Make sure we get a failure with existing dest without -f option
56 touch $t || framework_failure=1
57 # FIXME: don't ignore the error message but rather test
58 # it to make sure it's the right one.
59 ln -s $t $t 2> /dev/null && fail=1
62 # Make sure -sf fails when src and dest are the same
63 touch $t || framework_failure=1
64 ln -sf $t $t 2> /dev/null && fail=1
67 # Create a symlink with source file and no explicit directory
68 rm -rf $d || framework_failure=1
69 mkdir $d || framework_failure=1
70 touch $d/$f || framework_failure=1
75 # Create a symlink with source file and destination symlink-to-directory.
76 rm -rf $d $f $ld || framework_failure=1
77 touch $f || framework_failure=1
78 mkdir $d || framework_failure=1
80 ln -s ../$f $ld || fail=1
81 test -f $d/$f || fail=1
84 # Create a symlink with source file and destination symlink-to-directory.
85 # BUT use the new --no-dereference option.
86 rm -rf $d $f $ld || framework_failure=1
87 touch $f || framework_failure=1
88 mkdir $d || framework_failure=1
91 ln --no-dereference -fs $af $ld || fail=1
95 # Try to create a symlink with backup where the destination file exists
96 # and the backup file name is a hard link to the destination file.
97 touch a b || framework_failure=1
98 ln b b~ || framework_failure=1
99 ln -f --b=simple a b || fail=1
101 # ===================================================
102 # determine if link(2) follows symlinks on this system
103 touch a || framework_failure=1
104 ln -s a symlink || framework_failure=1
105 ln symlink hard-to-sym > /dev/null 2>&1 || framework_failure=1
106 ls=`ls -lG hard-to-sym`x
108 *'hard-to-symx') link_follows_symlink=yes ;;
109 *'hard-to-sym -> ax') link_follows_symlink=no ;;
110 *) framework_failure=1 ;;
113 if test $link_follows_symlink = no; then
114 # Create a hard link to a dangling symlink.
115 # This is not portable. At least sunos4.1.4 and OpenBSD 2.3 fail this test.
117 # ln: cannot create hard link `hard-to-dangle' to `no-such-dir': \
118 # No such file or directory
120 ln -s /no-such-dir || fail=1
121 ln no-such-dir hard-to-dangle > /dev/null 2>&1 || fail=1
123 rm -rf a symlink hard-to-sym hard-to-dangle
124 # ===================================================
126 # Make sure ln can make simple backups.
127 # This was fixed in 4.0.34. Broken in 4.0r.
128 for cmd in ln cp mv ginstall; do
130 touch a x || framework_failure=1
131 $cmd --backup=simple --suffix=.orig x a || fail=1
132 test -f a.orig || fail=1
135 # ===================================================
136 # With coreutils-5.2.1, this would mistakenly access argv[1][-1].
137 # I'm including it here, in case some day programs like valgrind detect that.
138 # Purify probably would have done so.
139 ln foo '' 2> /dev/null
141 # ===================================================
143 if test $framework_failure = 1; then
144 echo 'failure in testing framework' 1>&2