diff options
Diffstat (limited to 'tests/ln/misc')
-rwxr-xr-x | tests/ln/misc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/ln/misc b/tests/ln/misc new file mode 100755 index 000000000..f3b39efec --- /dev/null +++ b/tests/ln/misc @@ -0,0 +1,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 |