s3:tests: Fix directory creation and deletion of test_nosymlinks()
authorAndreas Schneider <asn@samba.org>
Tue, 18 Jul 2017 10:29:16 +0000 (12:29 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 19 Jul 2017 09:59:52 +0000 (11:59 +0200)
This should fix flakey autobuild.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12914

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul 19 11:59:52 CEST 2017 on sn-devel-144

source3/script/tests/test_smbclient_s3.sh

index 557d94d85485de50316c594c9818100f0dc690cf..203f2c27d2ed7561fe3f70a02f9c22a2e6254459 100755 (executable)
@@ -1042,21 +1042,61 @@ EOF
 test_nosymlinks()
 {
 # Setup test dirs.
-    test_dir="$LOCAL_PATH/nosymlinks/test"
+    local_test_dir="$LOCAL_PATH/nosymlinks/test"
+    local_slink_name="$local_test_dir/source"
+    local_slink_target="$local_test_dir/nosymlink_target_file"
 
-    slink_name="$test_dir/source"
-    slink_target="$test_dir/target"
-    foobar_dir="$test_dir/foo/bar"
-    get_target="$test_dir/foo/bar/testfile"
+    share_test_dir="test"
+    share_foo_dir="$share_test_dir/foo"
+    share_foobar_dir="$share_test_dir/foo/bar"
+    share_target_file="$share_test_dir/foo/bar/testfile"
+
+    rm -rf $local_test_dir
 
-    rm -rf $test_dir
+    local_nosymlink_target_file="nosymlink_target_file"
+    echo "$local_slink_target" > $local_nosymlink_target_file
 
-    mkdir -p $test_dir
-    echo "$slink_target" > $slink_target
-    ln -s $slink_target $slink_name
+    local_foobar_target_file="testfile"
+    echo "$share_target_file" > $local_foobar_target_file
+
+    tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+    cat > $tmpfile <<EOF
+mkdir $share_test_dir
+mkdir $share_foo_dir
+mkdir $share_foobar_dir
+cd /$share_test_dir
+put $local_nosymlink_target_file
+cd /$share_foobar_dir
+put $local_foobar_target_file
+quit
+EOF
+
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+    rm -f $local_nosymlink_target_file
+    rm -f $local_foobar_target_file
+
+    if [ $ret -ne 0 ] ; then
+       echo "$out"
+       echo "failed accessing local_symlinks with error $ret"
+       false
+       return
+    fi
+
+    echo "$out" | grep 'NT_STATUS_'
+    ret=$?
+    if [ $ret -eq 0 ] ; then
+       echo "$out"
+       echo "failed - got an NT_STATUS error"
+       false
+       return
+    fi
 
-    mkdir -p $foobar_dir
-    echo "$get_target" > $get_target
+# Create the symlink locally
+    ln -s $local_slink_target $local_slink_name
 
 # Getting a file through a symlink name should fail.
     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
@@ -1129,6 +1169,33 @@ EOF
        return 1
     fi
 
+    echo "$out" | grep 'NT_STATUS'
+    ret=$?
+    if [ $ret -eq 0 ] ; then
+       echo "$out"
+       echo "failed - NT_STATUS_XXXX doing cd foo\\bar; get testfile on \\nosymlinks"
+       return 1
+    fi
+
+# CLEANUP
+    rm -f $local_slink_name
+
+    cat > $tmpfile <<EOF
+deltree test
+quit
+EOF
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret -ne 0 ] ; then
+       echo "$out"
+       echo "failed accessing nosymlinks with error $ret"
+       return 1
+    fi
+
     echo "$out" | grep 'NT_STATUS'
     ret=$?
     if [ $ret -eq 0 ] ; then