From ae2fb4f1093e28e4656371b9bbeb229fd1ed1ada Mon Sep 17 00:00:00 2001 From: James Peach Date: Thu, 15 Jun 2006 23:47:41 +0000 Subject: r16273: Add smbclient tests to verify that in interactive mode, smbclient always prompts on stdout in non-interactive mode, smbclient never prompts (This used to be commit dff1eba81ed4bdd6dbf2df6e7c28b0da74a39615) --- source3/script/tests/test_smbclient_s3.sh | 58 ++++++++++++++++++++++++++++-- source3/script/tests/tests_smbclient_s3.sh | 1 + 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 source3/script/tests/tests_smbclient_s3.sh diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 007f3839f7..98b165e735 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -11,13 +11,67 @@ fi SERVER="$1" SERVER_IP="$2" +SMBCLIENT="$VALGRIND ${SMBCLIENT:-$SRCDIR/bin/smbclient} $CONFIGURATION" incdir=`dirname $0` . $incdir/test_functions.sh failed=0 -testit "smbclient -L $SERVER_IP" $VALGRIND $SRCDIR/bin/smbclient $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` -testit "smbclient -L $SERVER" $VALGRIND $SRCDIR/bin/smbclient $CONFIGURATION -L $SERVER -N -p 139 || failed=`expr $failed + 1` +# Test that a noninteractive smbclient does not prompt +test_noninteractive_no_prompt() +{ + prompt="smb" + + echo du | \ + $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp 2>&1 | \ + grep $prompt + + if [ $? = 0 ] ; then + # got a prompt .. fail + echo matched interactive prompt in non-interactive mode + false + else + true + fi +} + +# Test that an interactive smbclient prompts to stdout +test_interactive_prompt_stdout() +{ + prompt="smb" + + echo du | \ + CLI_FORCE_INTERACTIVE=yes \ + $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp 2>/dev/null | \ + grep $prompt + + if [ $? = 0 ] ; then + # got a prompt .. succeed + true + else + echo failed to match interactive prompt on stdout + false + fi +} + +testit "smbclient -L $SERVER_IP" $SMBCLIENT -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1` +testit "smbclient -L $SERVER" $SMBCLIENT -L $SERVER -N -p 139 || failed=`expr $failed + 1` + +testit "noninteractive smbclient does not prompt" \ + test_noninteractive_no_prompt || \ + failed=`expr $failed + 1` + +testit "noninteractive smbclient -l does not prompt" \ + test_noninteractive_no_prompt -l /tmp || \ + failed=`expr $failed + 1` + +testit "interactive smbclient prompts on stdout" \ + test_interactive_prompt_stdout || \ + failed=`expr $failed + 1` + +testit "interactive smbclient -l prompts on stdout" \ + test_interactive_prompt_stdout -l /tmp || \ + failed=`expr $failed + 1` testok $0 $failed diff --git a/source3/script/tests/tests_smbclient_s3.sh b/source3/script/tests/tests_smbclient_s3.sh new file mode 100644 index 0000000000..d48a692d4b --- /dev/null +++ b/source3/script/tests/tests_smbclient_s3.sh @@ -0,0 +1 @@ +. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP -- cgit