blob: 872767b2fb528f26ac5ebfb2af321c707a4482a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/sh
tmp=t2-ln.$$
if test "$VERBOSE" = yes; then
set -x
ln --version
fi
test_failure=0
mkdir $tmp || test_failure=1
cd $tmp || test_failure=1
if test $test_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
t=tln-symlink
d=tln-subdir
ld=tln-symlink-to-subdir
f=tln-file
fail=0
# Create a simple symlink with both source and destination files
# in current directory.
touch $f || test_failure=1
rm -f $t || test_failure=1
ln -s $f $t || fail=1
test -f $t || fail=1
rm $t $f
# Create a symlink with source file and explicit destination directory/file.
touch $f || test_failure=1
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
ln -s ../$f $d/$t || fail=1
test -f $d/$t || fail=1
rm -rf $d $f
# Create a symlink with source file and destination directory.
touch $f || test_failure=1
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
ln -s ../$f $d || fail=1
test -f $d/$f || fail=1
rm -rf $d $f
# Make sure we get a failure with existing dest without -f option
touch $t || test_failure=1
# FIXME: don't ignore the error message but rather test
# it to make sure it's the right one.
ln -s $t $t 2> /dev/null && fail=1
rm $t
# Make sure -sf fails when src and dest are the same
touch $t && test_failure=1
ln -sf $t $t 2> /dev/null && fail=1
rm $t
# Create a symlink with source file and no explicit directory
rm -rf $d || test_failure=1
mkdir $d || test_failure=1
touch $d/$f || test_failure=1
ln -s $d/$f || fail=1
test -f $f || fail=1
rm -rf $d $f
# Create a symlink with source file and destination symlink-to-directory.
rm -rf $d $f $ld || test_failure=1
touch $f || test_failure=1
mkdir $d || test_failure=1
ln -s $d $ld
ln -s ../$f $ld || fail=1
test -f $d/$f || fail=1
rm -rf $d $f $ld
# Create a symlink with source file and destination symlink-to-directory.
# BUT use the new --no-dereference option.
rm -rf $d $f $ld || test_failure=1
touch $f || test_failure=1
mkdir $d || test_failure=1
ln -s $d $ld
af=`pwd`/$f
ln --no-dereference -fs $af $ld || fail=1
test -f $ld || fail=1
rm -rf $d $f $ld
# Try to create a symlink with backup where the destination file exists
# and the backup file name is a hard link to the destination file.
touch a b || test_failure=1
ln b b~ || test_failure=1
ln -f --b=simple a b || fail=1
# Create a hard link to a dangling symlink.
# This is not portable. At least sunos4.1.4 and OpenBSD 2.3 fail this test.
# They get this:
# ln: cannot create hard link `hard-to-dangle' to `no-such-dir': \
# No such file or directory
#
#ln -s /no-such-dir || fail=1
#ln no-such-dir hard-to-dangle || fail=1
cd ..
../../src/rm -rf $tmp
exit $fail
|