The branch, master has been updated via b9188763823 s3:tests: Reformat test_net_conf.sh via 41661b779ba s3:tests: Reformat test_net_cache_samlogon.sh from a01cb7b4476 winbindd: Remove a "wrong" error message
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit b91887638231e208535ec2accb70cc944664f361 Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:09 2022 +0200 s3:tests: Reformat test_net_conf.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Alexander Bokovoy <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Tue Jun 7 09:19:43 UTC 2022 on sn-devel-184 commit 41661b779baccd774d638606f38087d9d3ce9e21 Author: Andreas Schneider <a...@samba.org> Date: Fri Apr 22 15:34:09 2022 +0200 s3:tests: Reformat test_net_cache_samlogon.sh shfmt -f source3/script/| xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Alexander Bokovoy <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/script/tests/test_net_cache_samlogon.sh | 6 +- source3/script/tests/test_net_conf.sh | 1502 +++++++++++------------ 2 files changed, 753 insertions(+), 755 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/script/tests/test_net_cache_samlogon.sh b/source3/script/tests/test_net_cache_samlogon.sh index 4114c89fc0e..671806a5e87 100755 --- a/source3/script/tests/test_net_cache_samlogon.sh +++ b/source3/script/tests/test_net_cache_samlogon.sh @@ -4,10 +4,10 @@ # if [ $# -lt 4 ]; then -cat <<EOF + cat <<EOF Usage: $0 SERVER SHARE USER PASS EOF -exit 1; + exit 1 fi SERVER=$1 @@ -18,7 +18,7 @@ smbclient=$BINDIR/smbclient failed=0 -incdir=`dirname $0`/../../../testprogs/blackbox +incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh . $incdir/common_test_fns.inc diff --git a/source3/script/tests/test_net_conf.sh b/source3/script/tests/test_net_conf.sh index 1b9a4be019a..7a70a9b553c 100755 --- a/source3/script/tests/test_net_conf.sh +++ b/source3/script/tests/test_net_conf.sh @@ -5,10 +5,10 @@ # Copyright (C) 2011 Vicentiu Ciorbaru <cvicen...@gmail.com> if [ $# -lt 3 ]; then -cat <<EOF + cat <<EOF Usage: test_net_conf.sh SCRIPTDIR SERVERCONFFILE NET CONFIGURATION [rpc] EOF -exit 1; + exit 1 fi SCRIPTDIR="$1" @@ -20,245 +20,244 @@ RPC="$5" LOGDIR_PREFIX="conf_test" # remove old logs: -for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*") ; do +for OLDDIR in $(find ${PREFIX} -type d -name "${LOGDIR_PREFIX}_*"); do echo "removing old directory ${OLDDIR}" rm -rf ${OLDDIR} done - NET="$VALGRIND ${NET:-$BINDIR/net} $CONFIGURATION" DIR=$(mktemp -d ${PREFIX}/${LOGDIR_PREFIX}_XXXXXX) LOG=$DIR/log - -if test "x${RPC}" = "xrpc" ; then +if test "x${RPC}" = "xrpc"; then NETCMD="${NET} -U${USERNAME}%${PASSWORD} -I ${SERVER_IP} rpc" else NETCMD="${NET}" fi -incdir=`dirname $0`/../../../testprogs/blackbox +incdir=$(dirname $0)/../../../testprogs/blackbox . $incdir/subunit.sh failed=0 -log_print() { - RC=$? - echo "CMD: $*" >>$LOG - echo "RC: $RC" >> $LOG - return $RC -# echo -n . +log_print() +{ + RC=$? + echo "CMD: $*" >>$LOG + echo "RC: $RC" >>$LOG + return $RC + # echo -n . } test_conf_addshare() { - echo '\nTesting conf addshare' >> $LOG - echo ------------------------- >> $LOG - echo '\nDropping existing configuration' >> $LOG - - $NETCMD conf drop - log_print $NETCMD conf drop - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - -#create a lot of shares - for i in $(seq 1 100); do - if [ $(($i % 2)) -eq 0 ]; then - $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ - "test comment" >>$DIR/addshare_exp \ - 2>>$DIR/addshare_exp - log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ - "test comment" - else - $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ - "test comment" >>$DIR/addshare_exp \ - 2>>$DIR/addshare_exp - log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ - "test comment" - fi + echo '\nTesting conf addshare' >>$LOG + echo ------------------------- >>$LOG + echo '\nDropping existing configuration' >>$LOG + + $NETCMD conf drop + log_print $NETCMD conf drop test "x$?" = "x0" || { echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG return 1 } - done - $NETCMD conf listshares > $DIR/listshares_out - log_print $NETCMD conf listshares - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - - for i in $(seq 1 100); do - grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: share not found" | tee -a $LOG - return 1 - fi - done + #create a lot of shares + for i in $(seq 1 100); do + if [ $(($i % 2)) -eq 0 ]; then + $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share$i /tmp "writeable=y" "guest_ok=n" \ + "test comment" + else + $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share$i /tmp "writeable=n" "guest_ok=y" \ + "test comment" + fi + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + done -#check the integrity of the shares -#if it fails, it can also point to an error in showshare - for i in $(seq 1 100); do - $NETCMD conf showshare share$i > $DIR/showshare_out + $NETCMD conf listshares >$DIR/listshares_out + log_print $NETCMD conf listshares test "x$?" = "x0" || { echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG return 1 } - grep "path" $DIR/showshare_out >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: share not found" | tee -a $LOG - return 1 - fi - - if [ $(($i % 2)) -eq 0 ]; then - grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + for i in $(seq 1 100); do + grep "share$i" $DIR/listshares_out >/dev/null 2>>$LOG if [ "$?" = "1" ]; then - echo "ERROR: share not set correctly" | tee -a $LOG + echo "ERROR: share not found" | tee -a $LOG return 1 fi - else - grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: share not set correctly" | tee -a $LOG + done + + #check the integrity of the shares + #if it fails, it can also point to an error in showshare + for i in $(seq 1 100); do + $NETCMD conf showshare share$i >$DIR/showshare_out + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG return 1 - fi - fi + } - if [ $(($i % 2)) -eq 0 ]; then - grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + grep "path" $DIR/showshare_out >/dev/null 2>>$LOG if [ "$?" = "1" ]; then - echo "ERROR: share not set correctly" | tee -a $LOG + echo "ERROR: share not found" | tee -a $LOG return 1 fi - else - grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG + + if [ $(($i % 2)) -eq 0 ]; then + grep "read only *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + else + grep "read only *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + fi + + if [ $(($i % 2)) -eq 0 ]; then + grep "guest ok *= *no" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + else + grep "guest ok *= *yes" $DIR/showshare_out >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: share not set correctly" | tee -a $LOG + return 1 + fi + fi + + grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG if [ "$?" = "1" ]; then echo "ERROR: share not set correctly" | tee -a $LOG return 1 fi - fi + done - grep "comment *= *test comment" $DIR/showshare_out >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: share not set correctly" | tee -a $LOG + echo '\nTaking a conf snapshot for later use' >>$LOG + $NETCMD conf list >$DIR/conf_import_in + log_print $NETCMD conf list + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG return 1 - fi - done - - echo '\nTaking a conf snapshot for later use' >> $LOG - $NETCMD conf list > $DIR/conf_import_in - log_print $NETCMD conf list - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } + } } test_conf_addshare_existing() { -#try adding an already existing share - echo '\nAdding an already existing share' >>$LOG - $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ - "test comment" >>$DIR/addshare_exp \ - 2>>$DIR/addshare_exp - log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ - "test comment" - test "x$?" = "x255" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - - test -z `cat $DIR/addshare_exp` && { - echo "ERROR: addshare output does not match" >> $LOG - return 1 - } - - return 0 + #try adding an already existing share + echo '\nAdding an already existing share' >>$LOG + $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ + "test comment" >>$DIR/addshare_exp \ + 2>>$DIR/addshare_exp + log_print $NETCMD conf addshare share1 /tmp "writeable=n" "guest_ok=y" \ + "test comment" + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + test -z $(cat $DIR/addshare_exp) && { + echo "ERROR: addshare output does not match" >>$LOG + return 1 + } + + return 0 } test_conf_addshare_usage() { -#check to see if command prints usage - echo '\nChecking usage' >>$LOG - $NETCMD conf addshare > $DIR/addshare_usage_exp - log_print $NETCMD conf addshare - test "x$?" = "x255" || { - echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG - return 1 - } - - grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: no/wrong usage message printed" | tee -a $LOG - return 1 - fi + #check to see if command prints usage + echo '\nChecking usage' >>$LOG + $NETCMD conf addshare >$DIR/addshare_usage_exp + log_print $NETCMD conf addshare + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf addshare" $DIR/addshare_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi } test_conf_delshare() { - echo '\nTesting conf delshare' >>$LOG - echo ------------------------- >> $LOG - echo -n '\n' >> $LOG - - $NETCMD conf delshare share1 - log_print $NETCMD conf delshare share1 - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - - $NETCMD conf listshares > $DIR/listshares_out - log_print $NETCMD conf listshares - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - - grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG - if [ "$?" = "0" ]; then - echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG - return 1 - fi + echo '\nTesting conf delshare' >>$LOG + echo ------------------------- >>$LOG + echo -n '\n' >>$LOG + + $NETCMD conf delshare share1 + log_print $NETCMD conf delshare share1 + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + $NETCMD conf listshares >$DIR/listshares_out + log_print $NETCMD conf listshares + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } + + grep "share1$" $DIR/listshares_out >/dev/null 2>>$LOG + if [ "$?" = "0" ]; then + echo "ERROR: delshare did not delete 'share1'" | tee -a $LOG + return 1 + fi } test_conf_delshare_empty() { - echo '\nAttempting to delete non_existing share' - $NETCMD conf delshare share1 - log_print $NETCMD conf delshare share1 - test "x$?" = "x255" || { - echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG - return 1 - } + echo '\nAttempting to delete non_existing share' + $NETCMD conf delshare share1 + log_print $NETCMD conf delshare share1 + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } } test_conf_delshare_usage() { - echo '\nChecking usage' >>$LOG - $NETCMD conf delshare > $DIR/delshare_usage_exp - log_print $NETCMD conf delshare - test "x$?" = "x255" || { - echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG - return 1 - } - - grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG - if [ "$?" = "1" ]; then - echo "ERROR: no/wrong usage message printed" | tee -a $LOG - return 1 - fi + echo '\nChecking usage' >>$LOG + $NETCMD conf delshare >$DIR/delshare_usage_exp + log_print $NETCMD conf delshare + test "x$?" = "x255" || { + echo 'ERROR: RC does not match, expected: 255' | tee -a $LOG + return 1 + } + + grep "$RPC *conf delshare" $DIR/delshare_usage_exp >/dev/null 2>>$LOG + if [ "$?" = "1" ]; then + echo "ERROR: no/wrong usage message printed" | tee -a $LOG + return 1 + fi } test_conf_showshare_case() { echo '\nChecking case in net conf shareshare' >>$LOG - echo '\nDropping existing configuration' >> $LOG + echo '\nDropping existing configuration' >>$LOG $NETCMD conf drop log_print $NETCMD conf drop test "x$?" = "x0" || { @@ -277,7 +276,7 @@ test_conf_showshare_case() # share name in correct case. switch_case=$(echo $share | tr 'A-Za-z' 'a-zA-Z') log_print $NETCMD conf showshare $switch_case - $NETCMD conf showshare $switch_case > $DIR/showshare_out + $NETCMD conf showshare $switch_case >$DIR/showshare_out test "x$?" = "x0" || { echo 'ERROR: net conf showshare failed.' | tee -a $LOG return 1 @@ -295,169 +294,169 @@ test_conf_showshare_case() test_conf_drop() { - echo '\nTesting conf drop' >> $LOG - echo ------------------------- >> $LOG - echo '\nDropping existing configuration' >> $LOG - - $NETCMD conf drop - log_print $NETCMD conf drop - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - -#check to see if listing the configuration yields a blank file - $NETCMD conf list 1>>$DIR/list_out - log_print $NETCMD conf list - test "x$?" = "x0" || { - echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG - return 1 - } - - test -z "`cat $DIR/list_out`" || { - echo "ERROR: Expected list output did not match" | tee -a $LOG - return 1 - } + echo '\nTesting conf drop' >>$LOG + echo ------------------------- >>$LOG + echo '\nDropping existing configuration' >>$LOG + + $NETCMD conf drop + log_print $NETCMD conf drop + test "x$?" = "x0" || { + echo 'ERROR: RC does not match, expected: 0' | tee -a $LOG + return 1 + } -- Samba Shared Repository