.
[coreutils.git] / tests / ln / misc
blobf3b39efecb09ec070279292f89e16a10c80aac70
1 #!/bin/sh
3 PATH=../../../src:$PATH
4 tmp=t2-ln.$$
6 test_failure=0
7 mkdir $tmp || test_failure=1
8 cd $tmp || test_failure=1
10 if test $test_failure = 1; then
11 echo 'failure in testing framework'
12 exit 1
16 t=tln-symlink
17 d=tln-subdir
18 ld=tln-symlink-to-subdir
19 f=tln-file
20 fail=0
22 # Create a simple symlink with both source and destination files
23 # in current directory.
24 touch $f || test_failure=1
25 rm -f $t || test_failure=1
26 ln -s $f $t || fail=1
27 test -f $t || fail=1
28 rm $t $f
30 # Create a symlink with source file and explicit destination directory/file.
31 touch $f || test_failure=1
32 rm -rf $d || test_failure=1
33 mkdir $d || test_failure=1
34 ln -s ../$f $d/$t || fail=1
35 test -f $d/$t || fail=1
36 rm -rf $d $f
38 # Create a symlink with source file and destination directory.
39 touch $f || test_failure=1
40 rm -rf $d || test_failure=1
41 mkdir $d || test_failure=1
42 ln -s ../$f $d || fail=1
43 test -f $d/$f || fail=1
44 rm -rf $d $f
46 # Make sure we get a failure with existing dest without -f option
47 touch $t || test_failure=1
48 # FIXME: don't ignore the error message but rather test
49 # it to make sure it's the right one.
50 ln -s $t $t 2> /dev/null && fail=1
51 rm $t
53 # Make sure -sf fails when src and dest are the same
54 touch $t && test_failure=1
55 ln -sf $t $t 2> /dev/null && fail=1
56 rm $t
58 # Create a symlink with source file and no explicit directory
59 rm -rf $d || test_failure=1
60 mkdir $d || test_failure=1
61 touch $d/$f || test_failure=1
62 ln -s $d/$f || fail=1
63 test -f $f || fail=1
64 rm -rf $d $f
66 # Create a symlink with source file and destination symlink-to-directory.
67 rm -rf $d $f $ld || test_failure=1
68 touch $f || test_failure=1
69 mkdir $d || test_failure=1
70 ln -s $d $ld
71 ln -s ../$f $ld || fail=1
72 test -f $d/$f || fail=1
73 rm -rf $d $f $ld
75 # Create a symlink with source file and destination symlink-to-directory.
76 # BUT use the new --no-dereference option.
77 rm -rf $d $f $ld || test_failure=1
78 touch $f || test_failure=1
79 mkdir $d || test_failure=1
80 ln -s $d $ld
81 af=`pwd`/$f
82 ln --no-dereference -fs $af $ld || fail=1
83 test -f $ld || fail=1
84 rm -rf $d $f $ld
86 cd ..
87 rm -rf $tmp
89 exit $fail