The branch, master has been updated via cc606c7c786 s3:tests: Reformat test_durable_handle_reconnect.sh via 7366bd11783 s3:tests: Reformat test_dropbox.sh via 4d79f8e1582 s3:tests: Reformat test_dfree_quota.sh via fcbcfc8653a s3:tests: Reformat test_dfree_command.sh via cdecce9c073 s3:tests: Reformat test_delete_veto_files_only_rmdir.sh from 7a36b018889 dsdb: Do not reuse "ret" variable as return code and for memcmp() comparison
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit cc606c7c786d38672c7472aa68441197014e6de2 Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:08 2022 +0200 s3:tests: Reformat test_durable_handle_reconnect.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Thu May 5 03:42:13 UTC 2022 on sn-devel-184 commit 7366bd117831c1043b986dd08ec3a0c7b8486cca Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:08 2022 +0200 s3:tests: Reformat test_dropbox.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 4d79f8e15821152bb2c8f33d270432be70cea577 Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:08 2022 +0200 s3:tests: Reformat test_dfree_quota.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit fcbcfc8653a00fe148f436b6c3a31aa700e13f8a Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:08 2022 +0200 s3:tests: Reformat test_dfree_command.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit cdecce9c073eb7730d103d4420e50512d668d334 Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:08 2022 +0200 s3:tests: Reformat test_delete_veto_files_only_rmdir.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: .../tests/test_delete_veto_files_only_rmdir.sh | 217 ++++++++++---------- source3/script/tests/test_dfree_command.sh | 29 +-- source3/script/tests/test_dfree_quota.sh | 222 +++++++++++---------- source3/script/tests/test_dropbox.sh | 94 ++++----- .../script/tests/test_durable_handle_reconnect.sh | 14 +- 5 files changed, 290 insertions(+), 286 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/script/tests/test_delete_veto_files_only_rmdir.sh b/source3/script/tests/test_delete_veto_files_only_rmdir.sh index d2c3b2198f7..08f257ff8a6 100755 --- a/source3/script/tests/test_delete_veto_files_only_rmdir.sh +++ b/source3/script/tests/test_delete_veto_files_only_rmdir.sh @@ -5,10 +5,10 @@ # if [ $# -lt 6 ]; then -cat <<EOF + cat <<EOF Usage: $0 SERVER SERVER_IP USERNAME PASSWORD SHAREPATH SMBCLIENT EOF -exit 1; + exit 1 fi SERVER=${1} @@ -34,69 +34,69 @@ rmdir_path="$SHAREPATH/dir" # test_dangle_symlink_delete_veto_rmdir() { - local dangle_symlink_path="$rmdir_path/bad_link" - local tmpfile=$PREFIX/smbclient.in.$$ + local dangle_symlink_path="$rmdir_path/bad_link" + local tmpfile=$PREFIX/smbclient.in.$$ - # Create rmdir directory. - mkdir -p "$rmdir_path" - # Create dangling symlink underneath. - ln -s "nowhere-foo" "$dangle_symlink_path" + # Create rmdir directory. + mkdir -p "$rmdir_path" + # Create dangling symlink underneath. + ln -s "nowhere-foo" "$dangle_symlink_path" - cat > "$tmpfile" <<EOF + cat >"$tmpfile" <<EOF cd dir ls quit EOF - local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/delete_veto_files_only -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' - eval echo "$cmd" - out=$(eval "$cmd") - ret=$? - - # Check for smbclient error. - if [ $ret != 0 ] ; then - echo "Failed accessing share delete_veto_files_only - $ret" - echo "$out" - return 1 - fi - - # We should NOT see the dangling symlink file. - echo "$out" | grep bad_link - ret=$? - if [ $ret -eq 0 ] ; then - echo "Saw dangling symlink bad_link in share delete_veto_files_only" - echo "$out" - return 1 - fi - - # Try and remove the directory, should succeed. - cat > "$tmpfile" <<EOF + local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/delete_veto_files_only -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + ret=$? + + # Check for smbclient error. + if [ $ret != 0 ]; then + echo "Failed accessing share delete_veto_files_only - $ret" + echo "$out" + return 1 + fi + + # We should NOT see the dangling symlink file. + echo "$out" | grep bad_link + ret=$? + if [ $ret -eq 0 ]; then + echo "Saw dangling symlink bad_link in share delete_veto_files_only" + echo "$out" + return 1 + fi + + # Try and remove the directory, should succeed. + cat >"$tmpfile" <<EOF rd dir quit EOF - local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/delete_veto_files_only -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' - eval echo "$cmd" - out=$(eval "$cmd") - ret=$? - - # Check for smbclient error. - if [ $ret != 0 ] ; then - echo "Failed accessing share delete_veto_files_only - $ret" - echo "$out" - return 1 - fi - - # We should get no NT_STATUS_ errors. - echo "$out" | grep NT_STATUS_ - ret=$? - if [ $ret -eq 0 ] ; then - echo "Got error NT_STATUS_ in share delete_veto_files_only" - echo "$out" - return 1 - fi - - return 0 + local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/delete_veto_files_only -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + ret=$? + + # Check for smbclient error. + if [ $ret != 0 ]; then + echo "Failed accessing share delete_veto_files_only - $ret" + echo "$out" + return 1 + fi + + # We should get no NT_STATUS_ errors. + echo "$out" | grep NT_STATUS_ + ret=$? + if [ $ret -eq 0 ]; then + echo "Got error NT_STATUS_ in share delete_veto_files_only" + echo "$out" + return 1 + fi + + return 0 } # @@ -105,79 +105,78 @@ EOF # test_dangle_symlink_veto_files_nodelete() { - local dangle_symlink_path="$rmdir_path/bad_link" - local tmpfile=$PREFIX/smbclient.in.$$ + local dangle_symlink_path="$rmdir_path/bad_link" + local tmpfile=$PREFIX/smbclient.in.$$ - # Create rmdir directory. - mkdir -p "$rmdir_path" - # Create dangling symlink underneath. - ln -s "nowhere-foo" "$dangle_symlink_path" + # Create rmdir directory. + mkdir -p "$rmdir_path" + # Create dangling symlink underneath. + ln -s "nowhere-foo" "$dangle_symlink_path" - cat > "$tmpfile" <<EOF + cat >"$tmpfile" <<EOF cd dir ls quit EOF - local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/veto_files_nodelete -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' - eval echo "$cmd" - out=$(eval "$cmd") - ret=$? - - # Check for smbclient error. - if [ $ret != 0 ] ; then - echo "Failed accessing share veto_files_nodelete - $ret" - echo "$out" - return 1 - fi - - # We should NOT see the dangling symlink file. - echo "$out" | grep bad_link - ret=$? - if [ $ret -eq 0 ] ; then - echo "Saw dangling symlink bad_link in share veto_files_nodelete" - echo "$out" - return 1 - fi - - # Try and remove the directory, should fail with DIRECTORY_NOT_EMPTY. - cat > "$tmpfile" <<EOF + local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/veto_files_nodelete -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + ret=$? + + # Check for smbclient error. + if [ $ret != 0 ]; then + echo "Failed accessing share veto_files_nodelete - $ret" + echo "$out" + return 1 + fi + + # We should NOT see the dangling symlink file. + echo "$out" | grep bad_link + ret=$? + if [ $ret -eq 0 ]; then + echo "Saw dangling symlink bad_link in share veto_files_nodelete" + echo "$out" + return 1 + fi + + # Try and remove the directory, should fail with DIRECTORY_NOT_EMPTY. + cat >"$tmpfile" <<EOF rd dir quit EOF - local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/veto_files_nodelete -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' - eval echo "$cmd" - out=$(eval "$cmd") - ret=$? - - # Check for smbclient error. - if [ $ret != 0 ] ; then - echo "Failed accessing share veto_files_nodelete - $ret" - echo "$out" - return 1 - fi - - # We should get NT_STATUS_DIRECTORY_NOT_EMPTY errors. - echo "$out" | grep NT_STATUS_DIRECTORY_NOT_EMPTY - ret=$? - if [ $ret -ne 0 ] ; then - echo "Should get NT_STATUS_DIRECTORY_NOT_EMPTY in share veto_files_nodelete" - echo "$out" - return 1 - fi - - return 0 + local cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT //$SERVER/veto_files_nodelete -U$USERNAME%$PASSWORD $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + ret=$? + + # Check for smbclient error. + if [ $ret != 0 ]; then + echo "Failed accessing share veto_files_nodelete - $ret" + echo "$out" + return 1 + fi + + # We should get NT_STATUS_DIRECTORY_NOT_EMPTY errors. + echo "$out" | grep NT_STATUS_DIRECTORY_NOT_EMPTY + ret=$? + if [ $ret -ne 0 ]; then + echo "Should get NT_STATUS_DIRECTORY_NOT_EMPTY in share veto_files_nodelete" + echo "$out" + return 1 + fi + + return 0 } - testit "rmdir can delete directory containing dangling symlink" \ - test_dangle_symlink_delete_veto_rmdir || failed=$(expr "$failed" + 1) + test_dangle_symlink_delete_veto_rmdir || failed=$(expr "$failed" + 1) rm -rf "$rmdir_path" testit "rmdir cannot delete directory delete_veto_files_no containing dangling symlink" \ - test_dangle_symlink_veto_files_nodelete || failed=$(expr "$failed" + 1) + test_dangle_symlink_veto_files_nodelete || failed=$(expr "$failed" + 1) rm -rf "$rmdir_path" exit "$failed" diff --git a/source3/script/tests/test_dfree_command.sh b/source3/script/tests/test_dfree_command.sh index 715496d47d7..0a087aeccb5 100755 --- a/source3/script/tests/test_dfree_command.sh +++ b/source3/script/tests/test_dfree_command.sh @@ -5,10 +5,10 @@ # if [ $# -lt 6 ]; then -cat <<EOF + cat <<EOF Usage: test_dfree_command.sh SERVER DOMAIN USERNAME PASSWORD PREFIX SMBCLIENT EOF -exit 1; + exit 1 fi SERVER=$1 @@ -22,17 +22,18 @@ protocol=$7 shift 7 failed=0 -incdir=`dirname $0`/../../../testprogs/blackbox +incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh -test_smbclient_dfree() { +test_smbclient_dfree() +{ name="$1" share="$2" cmd="$3" - expected="$4" + expected="$4" + shift shift shift - shift subunit_start_test "$name" output=$($VALGRIND $smbclient //$SERVER/$share -c "$cmd" $@ 2>&1) status=$? @@ -50,17 +51,17 @@ test_smbclient_dfree() { } if [ $protocol = "SMB3" ]; then - test_smbclient_dfree "Test dfree command share root SMB3" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1` - test_smbclient_dfree "Test dfree command subdir1 SMB3" dfree "cd subdir1; l" "8000 1024. 80" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1` - test_smbclient_dfree "Test dfree command subdir2 SMB3" dfree "cd subdir2; l" "32000 1024. 320" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1` + test_smbclient_dfree "Test dfree command share root SMB3" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=$(expr $failed + 1) + test_smbclient_dfree "Test dfree command subdir1 SMB3" dfree "cd subdir1; l" "8000 1024. 80" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=$(expr $failed + 1) + test_smbclient_dfree "Test dfree command subdir2 SMB3" dfree "cd subdir2; l" "32000 1024. 320" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=$(expr $failed + 1) elif [ $protocol = "NT1" ]; then - test_smbclient_dfree "Test dfree command share root NT1" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=`expr $failed + 1` -#SMB1 queries disk usage stat on the share's root, regardless of working directory - test_smbclient_dfree "Test dfree command subdir1 NT1" dfree "cd subdir1; l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=`expr $failed + 1` + test_smbclient_dfree "Test dfree command share root NT1" dfree "l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=$(expr $failed + 1) + #SMB1 queries disk usage stat on the share's root, regardless of working directory + test_smbclient_dfree "Test dfree command subdir1 NT1" dfree "cd subdir1; l" "2000 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=NT1 || failed=$(expr $failed + 1) else - echo "unsupported protocol $protocol" | subunit_fail_test "Test dfree command" - $failed=`expr $failed + 1` + echo "unsupported protocol $protocol" | subunit_fail_test "Test dfree command" + $failed=$(expr $failed + 1) fi exit $failed diff --git a/source3/script/tests/test_dfree_quota.sh b/source3/script/tests/test_dfree_quota.sh index a1403a8c4ba..e14f6349201 100755 --- a/source3/script/tests/test_dfree_quota.sh +++ b/source3/script/tests/test_dfree_quota.sh @@ -4,17 +4,17 @@ # if [ $# -lt 6 ]; then -cat <<EOF + cat <<EOF Usage: test_dfree_quota.sh SERVER DOMAIN USERNAME PASSWORD LOCAL_PATH SMBCLIENT SMBCQUOTAS SMBCACLS EOF -exit 1; + exit 1 fi SERVER=$1 DOMAIN=$2 USERNAME=$3 PASSWORD=$4 -ENVDIR=`dirname $5` +ENVDIR=$(dirname $5) WORKDIR=$5/dfree smbclient=$6 smbcquotas=$7 @@ -25,21 +25,23 @@ failed=0 CONFFILE=$ENVDIR/lib/dfq.conf -incdir=`dirname $0`/../../../testprogs/blackbox +incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh -sighup_smbd() { - kill -HUP -`cat $ENVDIR/pid/smbd.pid` +sighup_smbd() +{ + kill -HUP -$(cat $ENVDIR/pid/smbd.pid) } -conf_lines() { - local uid - local gid - uid=$(id -u $USERNAME) - gid=$(id -g $USERNAME) - uid1=$(id -u user1) - uid2=$(id -u user2) -cat <<ABC +conf_lines() +{ + local uid + local gid + uid=$(id -u $USERNAME) + gid=$(id -g $USERNAME) + uid1=$(id -u user1) + uid2=$(id -u user2) + cat <<ABC conf1:df:block size = 512:disk free = 10:disk size = 20 conf2:df:block size = 1024:disk free = 10:disk size = 20 conf3:df:block size = 4096:disk free = 750:disk size = 281474976710656 @@ -83,45 +85,46 @@ sgid:g98765:block size = 4096:hard limit = 50:soft limit = 50:cur blocks = 40 ABC } -setup_1_conf() { - conf_name="$1" - subdir="$2" - absdir=`readlink -f $WORKDIR/$subdir` - conf_lines | sed -rn "s/^$conf_name:(.*)/\1/p" | tr ":" "\n" | \ - awk -F '=' -v atdir=$absdir 'NF==1 {section=$1} NF==2 {sub(/\s*$/, "", $1); printf "\tfake_dfq:%s/%s/%s =%s\n", section, $1, atdir, $2}' +setup_1_conf() +{ + conf_name="$1" + subdir="$2" + absdir=$(readlink -f $WORKDIR/$subdir) + conf_lines | sed -rn "s/^$conf_name:(.*)/\1/p" | tr ":" "\n" | + awk -F '=' -v atdir=$absdir 'NF==1 {section=$1} NF==2 {sub(/\s*$/, "", $1); printf "\tfake_dfq:%s/%s/%s =%s\n", section, $1, atdir, $2}' } -setup_conf() { - rm $CONFFILE - touch $CONFFILE +setup_conf() +{ + rm $CONFFILE + touch $CONFFILE - until [ -z "$1" ] - do - setup_1_conf $1 $2 >> $CONFFILE - shift - shift - done - sighup_smbd - #let it load... - sleep .5 + until [ -z "$1" ]; do + setup_1_conf $1 $2 >>$CONFFILE + shift + shift + done + sighup_smbd + #let it load... + sleep .5 } - -test_smbclient_dfree() { +test_smbclient_dfree() +{ name="$1" - share="$2" - dir="$3" - confs="$4" - expected="$5" - shift - shift - shift - shift - subunit_start_test "$name" - setup_conf $confs - output=$($VALGRIND $smbclient //$SERVER/$share -c "cd $dir; l" $@ 2>&1) - status=$? - if [ "$status" = "0" ]; then + share="$2" + dir="$3" + confs="$4" + expected="$5" + shift + shift + shift + shift + subunit_start_test "$name" + setup_conf $confs + output=$($VALGRIND $smbclient //$SERVER/$share -c "cd $dir; l" $@ 2>&1) + status=$? + if [ "$status" = "0" ]; then received=$(echo "$output" | awk '/blocks of size/ {print $1, $5, $6}') if [ "$expected" = "$received" ]; then subunit_pass_test "$name" @@ -136,7 +139,8 @@ test_smbclient_dfree() { # Issue two queries to different directories in one session to test # caching effects -test_smbclient_dfree_2() { +test_smbclient_dfree_2() +{ name="$1" share="$2" dir1="$3" @@ -146,12 +150,12 @@ test_smbclient_dfree_2() { subunit_start_test "$name" setup_conf $confs output=$($VALGRIND $smbclient //$SERVER/$share \ - -c "cd $dir1; du; cd ..; cd $dir2 ; du" $@ 2>&1) + -c "cd $dir1; du; cd ..; cd $dir2 ; du" $@ 2>&1) status=$? if [ "$status" = "0" ]; then - received=$(echo "$output" | \ - awk '/blocks of size/ {print $1, $5, $6}' | \ - tr '\n' ' ') -- Samba Shared Repository