From: Stefan Metzmacher Date: Thu, 19 Nov 2020 17:10:02 +0000 (+0000) Subject: s3:script:tests: create temporary files under $PREFIX/SELFTEST_TMPDIR X-Git-Tag: tevent-0.11.0~1191 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cef28acbd2b3295a5d79575d6598d5d1fb92f005;p=thirdparty%2Fsamba.git s3:script:tests: create temporary files under $PREFIX/SELFTEST_TMPDIR Tests should not create files in the build nor the source directory! They should cope with read only access to them. Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett Reviewed-by: Andreas Schneider --- diff --git a/source3/script/tests/test_aio_outstanding.sh b/source3/script/tests/test_aio_outstanding.sh index b189343bb24..f4265277a1a 100755 --- a/source3/script/tests/test_aio_outstanding.sh +++ b/source3/script/tests/test_aio_outstanding.sh @@ -22,6 +22,9 @@ incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh failed=0 + +cd $SELFTEST_TMPDIR || exit 1 + # # Note if we already have any panics in the smbd log. # diff --git a/source3/script/tests/test_close_denied_share.sh b/source3/script/tests/test_close_denied_share.sh index bcd3883a064..58850e754e3 100755 --- a/source3/script/tests/test_close_denied_share.sh +++ b/source3/script/tests/test_close_denied_share.sh @@ -22,6 +22,8 @@ incdir=$(dirname $0)/../../../testprogs/blackbox failed=0 +cd $SELFTEST_TMPDIR || exit 1 + rm -f smbclient-stdin smbclient-stdout mkfifo smbclient-stdin smbclient-stdout diff --git a/source3/script/tests/test_durable_handle_reconnect.sh b/source3/script/tests/test_durable_handle_reconnect.sh index 2f6b308eebe..c75c6124ef1 100755 --- a/source3/script/tests/test_durable_handle_reconnect.sh +++ b/source3/script/tests/test_durable_handle_reconnect.sh @@ -7,6 +7,8 @@ . $(dirname $0)/../../../testprogs/blackbox/subunit.sh failed=0 +cd $SELFTEST_TMPDIR || exit 1 + delay_inject_conf=$(dirname $SMB_CONF_PATH)/delay_inject.conf echo 'delay_inject:ntimes = 5000' > $delay_inject_conf diff --git a/source3/script/tests/test_forceuser_validusers.sh b/source3/script/tests/test_forceuser_validusers.sh index 4b6d66e9fa2..d9150c95a67 100755 --- a/source3/script/tests/test_forceuser_validusers.sh +++ b/source3/script/tests/test_forceuser_validusers.sh @@ -25,6 +25,7 @@ failed=0 incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh +cd $SELFTEST_TMPDIR || exit 1 run_cmd_nooutput() { CMD="$1" diff --git a/source3/script/tests/test_large_acl.sh b/source3/script/tests/test_large_acl.sh index 9b6901fcfb1..d18c098b512 100755 --- a/source3/script/tests/test_large_acl.sh +++ b/source3/script/tests/test_large_acl.sh @@ -23,6 +23,8 @@ SMBCACLS="$VALGRIND ${SMBCACLS} ${ADDARGS}" incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh +cd $SELFTEST_TMPDIR || exit 1 + # build a file to work with build_files() { diff --git a/source3/script/tests/test_local_s3.sh b/source3/script/tests/test_local_s3.sh index d92e328d030..0b71a8d284d 100755 --- a/source3/script/tests/test_local_s3.sh +++ b/source3/script/tests/test_local_s3.sh @@ -14,8 +14,9 @@ incdir=`dirname $0`/../../../testprogs/blackbox failed=0 +cd $SELFTEST_TMPDIR || exit 1 -if test -x bin/talloctort ; then +if test -x $BINDIR/talloctort ; then testit "talloctort" $VALGRIND $BINDIR/talloctort || \ failed=`expr $failed + 1` else @@ -25,7 +26,7 @@ fi testit "replace_testsuite" $VALGRIND $BINDIR/replace_testsuite || \ failed=`expr $failed + 1` -if test -x bin/tdbtorture ; then +if test -x $BINDIR/tdbtorture ; then testit "tdbtorture" $VALGRIND $BINDIR/tdbtorture || \ failed=`expr $failed + 1` else diff --git a/source3/script/tests/test_netfileenum.sh b/source3/script/tests/test_netfileenum.sh index e917ad42862..e8c464307b8 100755 --- a/source3/script/tests/test_netfileenum.sh +++ b/source3/script/tests/test_netfileenum.sh @@ -21,6 +21,8 @@ incdir=$(dirname $0)/../../../testprogs/blackbox failed=0 +cd $SELFTEST_TMPDIR || exit 1 + rm -f smbclient-stdin smbclient-stdout smbclient-stderr mkfifo smbclient-stdin smbclient-stdout smbclient-stderr diff --git a/source3/script/tests/test_open_eintr.sh b/source3/script/tests/test_open_eintr.sh index 437934d1cd7..3eabb2a4bc7 100755 --- a/source3/script/tests/test_open_eintr.sh +++ b/source3/script/tests/test_open_eintr.sh @@ -24,6 +24,8 @@ incdir=$(dirname $0)/../../../testprogs/blackbox failed=0 +cd $SELFTEST_TMPDIR || exit 1 + rm -f smbclient-stdin smbclient-stdout smbclient-stderr mkfifo smbclient-stdin smbclient-stdout smbclient-stderr diff --git a/source3/script/tests/test_preserve_case.sh b/source3/script/tests/test_preserve_case.sh index 04885f12a1e..28da484b52d 100755 --- a/source3/script/tests/test_preserve_case.sh +++ b/source3/script/tests/test_preserve_case.sh @@ -29,6 +29,8 @@ failed=0 incdir=`dirname $0`/../../../testprogs/blackbox . $incdir/subunit.sh +cd $SELFTEST_TMPDIR || exit 1 + test_smbclient() { name="$1" share="$2" diff --git a/source3/script/tests/test_registry_upgrade.sh b/source3/script/tests/test_registry_upgrade.sh index cf14141818d..066adf883ec 100755 --- a/source3/script/tests/test_registry_upgrade.sh +++ b/source3/script/tests/test_registry_upgrade.sh @@ -15,7 +15,7 @@ BASE_DIR="${SCRIPT_DIR}/../../.." NET="$1" DBWRAP_TOOL="$2 --persistent" DATADIR="${BASE_DIR}/testdata/samba3" -WORKSPACE="${PREFIX}/registry_upgrade" +WORKSPACE="${SELFTEST_TMPDIR}/registry_upgrade" CONFIG_FILE="${WORKSPACE}/smb.conf" CONFIGURATION="--configfile=${CONFIG_FILE}" @@ -26,6 +26,8 @@ incdir="${BASE_DIR}/testprogs/blackbox" failed=0 +cd $SELFTEST_TMPDIR || exit 1 + REGPATH="HKLM\Software\Samba" LOGDIR_PREFIX="registry_upgrade" @@ -77,7 +79,7 @@ registry_upgrade() { echo registry_upgrade $1 | tee -a $LOG - cp -v $DATADIR/registry.tdb $WORKSPACE/registry.tdb >> $LOG 2>&1 + (cat $DATADIR/registry.tdb > $WORKSPACE/registry.tdb) >> $LOG 2>&1 REGISTRY="${WORKSPACE}/registry.tdb" @@ -173,24 +175,18 @@ registry_upgrade() } } -# remove old logs -for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do - echo "removing old directory ${OLDDIR}" - rm -rf ${OLDDIR} -done - # remove old workspace rm -rf $WORKSPACE mkdir $WORKSPACE -DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) +DIR=$(mktemp -d ${WORKSPACE}/${LOGDIR_PREFIX}_XXXXXX) LOG=$DIR/log testit "registry_upgrade" registry_upgrade || failed=`expr $failed + 1` if [ $failed -eq 0 ]; then - rm -r $DIR + rm -rf $WORKSPACE fi testok $0 $failed diff --git a/source3/script/tests/test_shadow_copy_torture.sh b/source3/script/tests/test_shadow_copy_torture.sh index 240a0083506..ce10bae3670 100755 --- a/source3/script/tests/test_shadow_copy_torture.sh +++ b/source3/script/tests/test_shadow_copy_torture.sh @@ -26,6 +26,8 @@ SNAPSHOT="@GMT-2015.10.31-19.40.30" failed=0 +cd $SELFTEST_TMPDIR || exit 1 + # build a hierarchy of files, symlinks, and directories build_files() { diff --git a/source3/script/tests/test_smb1_shadow_copy_torture.sh b/source3/script/tests/test_smb1_shadow_copy_torture.sh index cae9c023f82..3cda7ac15af 100755 --- a/source3/script/tests/test_smb1_shadow_copy_torture.sh +++ b/source3/script/tests/test_smb1_shadow_copy_torture.sh @@ -26,6 +26,8 @@ SNAPSHOT="@GMT-2015.10.31-19.40.30" failed=0 +cd $SELFTEST_TMPDIR || exit 1 + # build a hierarchy of files, symlinks, and directories build_files() { diff --git a/source3/script/tests/test_smbclient_mget.sh b/source3/script/tests/test_smbclient_mget.sh index 45f62f15d4d..a1ac59b8de6 100755 --- a/source3/script/tests/test_smbclient_mget.sh +++ b/source3/script/tests/test_smbclient_mget.sh @@ -19,6 +19,8 @@ USERNAME="$1"; shift PASSWORD="$1"; shift DIRECTORY="$1"; shift +cd $SELFTEST_TMPDIR || exit 1 + # Can't use "testit" here -- it somehow breaks the -c command passed # to smbclient into two, spoiling the "mget" diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 7f801decb39..a9d59095bd3 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -1105,16 +1105,17 @@ test_nosymlinks() rm -rf $local_test_dir local_nosymlink_target_file="nosymlink_target_file" - echo "$local_slink_target" > $local_nosymlink_target_file + echo "$local_slink_target" > $PREFIX/$local_nosymlink_target_file local_foobar_target_file="testfile" - echo "$share_target_file" > $local_foobar_target_file + echo "$share_target_file" > $PREFIX/$local_foobar_target_file tmpfile=$PREFIX/smbclient_interactive_prompt_commands cat > $tmpfile <