s4:client:tests: create temporary files under $PREFIX/SELFTEST_TMPDIR
authorStefan Metzmacher <metze@samba.org>
Mon, 23 Nov 2020 08:58:30 +0000 (09:58 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 13 Apr 2021 08:23:35 +0000 (08:23 +0000)
Tests should not create files in the build nor the source directory!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/client/tests/test_cifsdd.sh
source4/client/tests/test_smbclient.sh

index e59d37ae7bb81628817b3ef1ef16a5372c23b31b..404cb4688fa3707614d5b73364c72373c8189e32 100755 (executable)
@@ -34,8 +34,10 @@ compare() {
     testit "$1" cmp "$2" "$3" || failed=`expr $failed + 1`
 }
 
-sourcepath=tempfile.src.$$
-destpath=tempfile.dst.$$
+sourcefile=tempfile.src.$$
+sourcepath=${SELFTEST_TMPDIR}/$sourcefile
+destfile=tempfile.dst.$$
+destpath=${SELFTEST_TMPDIR}/$destfile
 
 # Create a source file with arbitrary contents
 dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
@@ -52,18 +54,18 @@ compare "Checking local differences" $sourcepath $destpath
 
 # Check whether we can do a round trip
 runcopy "Testing local -> remote copy" \
-           if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs 
+           if=$sourcepath of=//$SERVER/$SHARE/$sourcefile bs=$bs
 runcopy "Testing remote -> local copy" \
-           if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs 
+           if=//$SERVER/$SHARE/$sourcefile of=$destpath bs=$bs
 compare "Checking differences" $sourcepath $destpath 
 
 # Check that copying within the remote server works
 runcopy "Testing local -> remote copy" \
-           if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
+           if=//$SERVER/$SHARE/$sourcefile of=//$SERVER/$SHARE/$sourcefile bs=$bs
 runcopy "Testing remote -> remote copy" \
-           if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs 
+           if=//$SERVER/$SHARE/$sourcefile of=//$SERVER/$SHARE/$destfile bs=$bs
 runcopy "Testing remote -> local copy" \
-           if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs
+           if=//$SERVER/$SHARE/$destfile of=$destpath bs=$bs
 compare "Checking differences" $sourcepath $destpath
 
 done
index d2f38e3fccf4310ace0a1549765ec9fd4c7f963e..6840863244d96b51655764a523d40f0e6d834c61 100755 (executable)
@@ -42,21 +42,21 @@ testit "share and server list" $VALGRIND $smbclient -L $SERVER $CONFIGURATION  -
 testit "share and server list anonymously" $VALGRIND $smbclient -N -L $SERVER $CONFIGURATION $@ || failed=`expr $failed + 1`
 
 # Use the smbclient binary as our test file
-cat $smbclient >tmpfile
+cat $smbclient >$PREFIX/tmpfile
 
 # put that file
-runcmd "MPutting file" 'mput tmpfile' || failed=`expr $failed + 1`
+runcmd "MPutting file" "lcd $PREFIX; mput tmpfile" || failed=`expr $failed + 1`
 # check file info
 runcmd "Getting alternative name" 'altname tmpfile'|| failed=`expr $failed + 1`
 # run allinfo on that file
 runcmd "Checking info on file" 'allinfo tmpfile'|| failed=`expr $failed + 1`
 # get that file
-mv tmpfile tmpfile-old
-runcmd "MGetting file" 'mget tmpfile' || failed=`expr $failed + 1`
+mv $PREFIX/tmpfile $PREFIX/tmpfile-old
+runcmd "MGetting file" "lcd $PREFIX; mget tmpfile" || failed=`expr $failed + 1`
 # remove that file
 runcmd "Removing file" 'rm tmpfile' || failed=`expr $failed + 1`
 # compare locally
-testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
+testit "Comparing files" diff $PREFIX/tmpfile-old $PREFIX/tmpfile || failed=`expr $failed + 1`
 # create directory
 # cd to directory
 # cd to top level directory
@@ -90,21 +90,21 @@ runcmd "Getting file system info" 'fsinfo fullsize-information'|| failed=`expr $
 runcmd "Getting file system info" 'fsinfo objectid'|| failed=`expr $failed + 1`
 
 # put that file
-runcmd "Putting file" 'put tmpfile'|| failed=`expr $failed + 1`
+runcmd "Putting file" "lcd $PREFIX; put tmpfile" || failed=`expr $failed + 1`
 # get that file
-mv tmpfile tmpfile-old
-runcmd "Getting file" 'get tmpfile'|| failed=`expr $failed + 1`
+mv $PREFIX/tmpfile $PREFIX/tmpfile-old
+runcmd "Getting file" "lcd $PREFIX; get tmpfile" || failed=`expr $failed + 1`
 runcmd "Getting file EA info" 'eainfo tmpfile'|| failed=`expr $failed + 1`
 # remove that file
 runcmd "Removing file" 'rm tmpfile' || failed=`expr $failed + 1`
 # compare locally
-testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
+testit "Comparing files" diff $PREFIX/tmpfile-old $PREFIX/tmpfile || failed=`expr $failed + 1`
 # put that file
-runcmd "Putting file with different name" 'put tmpfile tmpfilex' || failed=`expr $failed + 1`
+runcmd "Putting file with different name" "lcd $PREFIX; put tmpfile tmpfilex" || failed=`expr $failed + 1`
 # get that file
-runcmd "Getting file again" 'get tmpfilex' || failed=`expr $failed + 1`
+runcmd "Getting file again" "lcd $PREFIX; get tmpfilex" || failed=`expr $failed + 1`
 # compare locally
-testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
+testit "Comparing files" diff $PREFIX/tmpfilex $PREFIX/tmpfile || failed=`expr $failed + 1`
 # remove that file
 runcmd "Removing file" 'rm tmpfilex'|| failed=`expr $failed + 1`
 
@@ -123,11 +123,11 @@ runcmd "Print current working directory" 'pwd'|| failed=`expr $failed + 1`
     echo "password=$PASSWORD"
     echo "username=$USERNAME"
     echo "domain=$DOMAIN"
-) > tmpauthfile
+) > $PREFIX/tmpauthfile
 
-testit "Test login with --authentication-file" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --authentication-file=tmpauthfile  || failed=`expr $failed + 1`
+testit "Test login with --authentication-file" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --authentication-file=$PREFIX/tmpauthfile  || failed=`expr $failed + 1`
 
-PASSWD_FILE="tmppassfile" 
+PASSWD_FILE="$PREFIX/tmppassfile"
 echo "$PASSWORD" > $PASSWD_FILE
 export PASSWD_FILE
 testit "Test login with PASSWD_FILE" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME" || failed=`expr $failed + 1`
@@ -149,5 +149,5 @@ unset PASSWD
 USER=$oldUSER
 export USER
 
-rm -f tmpfile tmpfile-old tmpfilex tmpauthfile tmppassfile
+rm -f $PREFIX/tmpfile $PREFIX/tmpfile-old $PREFIX/tmpfilex $PREFIX/tmpauthfile $PREFIX/tmppassfile
 exit $failed