diff options
author | Stefan Metzmacher <metze@samba.org> | 2020-11-23 09:58:30 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2021-04-13 08:23:35 +0000 |
commit | d260d2c59bf7a7026e3c4fd07209c32f6764210d (patch) | |
tree | 3101f8d5b5328f0a876d83a921d36b8dea25aa00 /source4/client | |
parent | 3d618689e254429cd2c36132af0c0b3904c1d7e4 (diff) | |
download | samba-d260d2c59bf7a7026e3c4fd07209c32f6764210d.tar.gz |
s4:client:tests: create temporary files under $PREFIX/SELFTEST_TMPDIR
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>
Diffstat (limited to 'source4/client')
-rwxr-xr-x | source4/client/tests/test_cifsdd.sh | 16 | ||||
-rwxr-xr-x | source4/client/tests/test_smbclient.sh | 32 |
2 files changed, 25 insertions, 23 deletions
diff --git a/source4/client/tests/test_cifsdd.sh b/source4/client/tests/test_cifsdd.sh index e59d37ae7bb..404cb4688fa 100755 --- a/source4/client/tests/test_cifsdd.sh +++ b/source4/client/tests/test_cifsdd.sh @@ -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 diff --git a/source4/client/tests/test_smbclient.sh b/source4/client/tests/test_smbclient.sh index d2f38e3fccf..6840863244d 100755 --- a/source4/client/tests/test_smbclient.sh +++ b/source4/client/tests/test_smbclient.sh @@ -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 |