Added regression test for bug #7234 - Symlink delete fails but incorrectly reports...
authorJeremy Allison <jra@samba.org>
Wed, 10 Mar 2010 22:40:20 +0000 (14:40 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 10 Mar 2010 22:40:20 +0000 (14:40 -0800)
Ensure we can delete a symlink by path.

Jeremy.

source3/script/tests/test_smbclient_s3.sh
source3/script/tests/tests_all.sh

index 1ee829e2fca8352b7133141d18cf72748d04c521..7896b2821fc9756c530e1cee036311b89aeb88e6 100755 (executable)
@@ -2,9 +2,9 @@
 
 # this runs the file serving tests that are expected to pass with samba3
 
-if [ $# -lt 5 ]; then
+if [ $# -lt 6 ]; then
 cat <<EOF
-Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID
+Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD USERID LOCAL_PATH
 EOF
 exit 1;
 fi
@@ -14,8 +14,9 @@ SERVER_IP="$2"
 USERNAME="$3"
 PASSWORD="$4"
 USERID="$5"
+LOCAL_PATH="$6"
 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
-shift 5
+shift 6
 ADDARGS="$*"
 
 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
@@ -127,6 +128,43 @@ EOF
     fi
 }
 
+# Test creating a good symlink and deleting it by path.
+test_good_symlink()
+{
+    tmpfile=/tmp/smbclient.in.$$
+
+    touch "$LOCAL_PATH/foo"
+    ln -s "$LOCAL_PATH/foo" "$LOCAL_PATH/bar"
+    cat > $tmpfile <<EOF
+del bar
+quit
+EOF
+
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed delete good symlink with error $ret"
+       false
+       return
+    fi
+
+    if [ -e "$LOCAL_PATH/bar" ] ; then
+       echo "failed delete good symlink - symlink still exists"
+       rm "$LOCAL_PATH/bar"
+       rm "$LOCAL_PATH/foo"
+       false
+    else
+       # got the correct prompt .. succeed
+       rm "$LOCAL_PATH/foo"
+       true
+    fi
+}
+
 # Test writing into a read-only directory (logon as guest) fails.
 test_read_only_dir()
 {
@@ -264,6 +302,10 @@ testit "creating a bad symlink and deleting it" \
    test_bad_symlink || \
    failed=`expr $failed + 1`
 
+testit "creating a good symlink and deleting it by path" \
+   test_good_symlink || \
+   failed=`expr $failed + 1`
+
 testit "writing into a read-only directory fails" \
    test_read_only_dir || \
    failed=`expr $failed + 1`
index 153f8ea0d5f9e6a823abdb9785a081db7df09ed5..cd0c6eb4566622314ccbda9f4ca5ee1690698c09 100755 (executable)
@@ -20,13 +20,13 @@ smbtorture_s3_encrypted() {
 
 smbclient_s3() {
        echo "RUNNING TESTS smbclient_s3"
-       $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD $USERID \
+       $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD $USERID "$PREFIX_ABS"/tmp \
        || failed=`expr $failed + $?`
 }
 
 smbclient_s3_encrypted() {
        echo "RUNNING TESTS smbclient_s3_encrypted"
-       $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD $USERID "-e" \
+       $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP $USERNAME $PASSWORD $USERID "$PREFIX_ABS"/tmp "-e" \
        || failed=`expr $failed + $?`
 }