blob: f3b39efecb09ec070279292f89e16a10c80aac70 (
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
|
#!/bin/sh
PATH=../../../src:$PATH
tmp=t2-ln.$$
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
cd ..
rm -rf $tmp
exit $fail
|