s3: selftest: Add test for orphan 'lost-XXX' directories in streams_depot.
authorJeremy Allison <jra@samba.org>
Wed, 19 Oct 2016 23:33:52 +0000 (16:33 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 21 Oct 2016 02:48:52 +0000 (04:48 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12384

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Oct 21 04:48:52 CEST 2016 on sn-devel-144

source3/script/tests/test_smbclient_s3.sh

index 5e3db5d365b86cd710ed57a50ac1e626a0bf2f6c..22849bd503181c11155da2b10268d06e92361176 100755 (executable)
@@ -1060,6 +1060,43 @@ EOF
     fi
 }
 
+# Test creating then deleting a stream file doesn't leave a lost-XXXXX directory.
+test_streams_depot_delete()
+{
+    tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+    rm -rf "$LOCAL_PATH/lost-*"
+
+    cat > $tmpfile <<EOF
+put ${PREFIX}/smbclient_interactive_prompt_commands foo:bar
+del foo
+ls lost*
+quit
+EOF
+    cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP -mSMB3 $ADDARGS < $tmpfile 2>&1'
+    eval echo "$cmd"
+    out=`eval $cmd`
+    ret=$?
+    rm -f $tmpfile
+
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "failed creating then deleting foo:bar with error $ret"
+       false
+       return
+    fi
+
+    echo "$out" | grep 'NT_STATUS_NO_SUCH_FILE listing \\lost\*'
+    ret=$?
+    if [ $ret != 0 ] ; then
+       echo "$out"
+       echo "deleting foo:bar left lost-XXX directory"
+       rm -rf "$LOCAL_PATH/lost-*"
+       false
+       return
+    fi
+}
+
+
 LOGDIR_PREFIX=test_smbclient_s3
 
 # possibly remove old logdirs:
@@ -1155,6 +1192,10 @@ testit "Ensure widelinks are restricted" \
     test_widelinks || \
     failed=`expr $failed + 1`
 
+testit "streams_depot can delete correctly" \
+    test_streams_depot_delete || \
+    failed=`expr $failed + 1`
+
 testit "rm -rf $LOGDIR" \
     rm -rf $LOGDIR || \
     failed=`expr $failed + 1`