s3:tests: Create a test directory for a clean test
authorAndreas Schneider <asn@samba.org>
Tue, 4 Apr 2017 09:07:36 +0000 (11:07 +0200)
committerJeremy Allison <jra@samba.org>
Sat, 8 Apr 2017 10:29:19 +0000 (12:29 +0200)
The test fails on openSUSE Tumbleweed with:

NT_STATUS_FILE_IS_A_DIRECTORY opening remote file \foo\bar\testfile

This cleans up the code to create a directory 'test' which can be
completely removed so nothing will stay behind. It also makes sure that
all parent directories are created and the files have some content.

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

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): Sat Apr  8 12:29:19 CEST 2017 on sn-devel-144

source3/script/tests/test_smbclient_s3.sh

index 9bff883f63f1cab420720d1aa1a67dc3b10940f3..a7bffcbd63206f5b1a49094c63d51d8f8169dc37 100755 (executable)
@@ -1100,29 +1100,26 @@ EOF
 test_nosymlinks()
 {
 # Setup test dirs.
-    slink_name="$LOCAL_PATH/nosymlinks/source"
-    slink_target="$LOCAL_PATH/nosymlinks/target"
-    mkdir_target="$LOCAL_PATH/nosymlinks/a"
-    dir1="$LOCAL_PATH/nosymlinks/foo"
-    dir2="$LOCAL_PATH/nosymlinks/foo/bar"
-    get_target="$LOCAL_PATH/nosymlinks/foo/bar/testfile"
-
-    rm -f $slink_target
-    rm -f $slink_name
-    rm -rf $mkdir_target
-    rm -rf $dir1
+    test_dir="$LOCAL_PATH/nosymlinks/test"
 
-    touch $slink_target
+    slink_name="$test_dir/source"
+    slink_target="$test_dir/target"
+    foobar_dir="$test_dir/foo/bar"
+    get_target="$test_dir/foo/bar/testfile"
+
+    rm -rf $test_dir
+
+    mkdir -p $test_dir
+    echo "$slink_target" > $slink_target
     ln -s $slink_target $slink_name
 
-    mkdir $dir1
-    mkdir $dir2
-    touch $get_target
+    mkdir -p $foobar_dir
+    echo "$get_target" > $get_target
 
 # Getting a file through a symlink name should fail.
     tmpfile=$PREFIX/smbclient_interactive_prompt_commands
     cat > $tmpfile <<EOF
-get source
+get test\\source
 quit
 EOF
     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
@@ -1149,8 +1146,8 @@ EOF
 
 # But we should be able to create and delete directories.
     cat > $tmpfile <<EOF
-mkdir a
-mkdir a\\b
+mkdir test\\a
+mkdir test\\a\\b
 quit
 EOF
     cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/nosymlinks -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
@@ -1176,7 +1173,7 @@ EOF
 
 # Ensure regular file/directory access also works.
     cat > $tmpfile <<EOF
-cd foo\\bar
+cd test\\foo\\bar
 ls
 get testfile -
 quit