r16273: Add smbclient tests to verify that
authorJames Peach <jpeach@samba.org>
Thu, 15 Jun 2006 23:47:41 +0000 (23:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:17:30 +0000 (11:17 -0500)
        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
source3/script/tests/tests_smbclient_s3.sh [new file with mode: 0644]

index 007f3839f7dec4bde2bf5ff47b7669d94ebdefee..98b165e7358ae7776684fc38ec98d3b96271c3ef 100755 (executable)
@@ -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 (file)
index 0000000..d48a692
--- /dev/null
@@ -0,0 +1 @@
+. $SCRIPTDIR/test_smbclient_s3.sh $SERVER $SERVER_IP