c10aed0ee650ee56eaffcc81fa39f805e8577c74
[metze/samba/wip.git] / source3 / script / tests / test_smbclient_s3.sh
1 #!/bin/sh
2
3 # this runs the file serving tests that are expected to pass with samba3
4
5 if [ $# -lt 2 ]; then
6 cat <<EOF
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP
8 EOF
9 exit 1;
10 fi
11
12 SERVER="$1"
13 SERVER_IP="$2"
14 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
15 shift 2
16 ADDARGS="$*"
17
18 incdir=`dirname $0`
19 . $incdir/test_functions.sh
20
21 failed=0
22
23 # Test that a noninteractive smbclient does not prompt
24 test_noninteractive_no_prompt()
25 {
26     prompt="smb"
27
28     echo du | \
29         $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I SERVER_IP $ADDARGS 2>&1 | \
30     grep $prompt
31
32     if [ $? = 0 ] ; then
33         # got a prompt .. fail
34         echo matched interactive prompt in non-interactive mode
35         false
36     else
37         true
38     fi
39 }
40
41 # Test that an interactive smbclient prompts to stdout
42 test_interactive_prompt_stdout()
43 {
44     prompt="smb"
45     tmpfile=/tmp/smbclient.in.$$
46
47     cat > $tmpfile <<EOF
48 du
49 quit
50 EOF
51
52     CLI_FORCE_INTERACTIVE=yes \
53     $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP \
54         $ADDARGS < $tmpfile 2>/dev/null | \
55     grep $prompt
56
57     if [ $? = 0 ] ; then
58         # got a prompt .. succeed
59         rm -f $tmpfile
60         true
61     else
62         echo failed to match interactive prompt on stdout
63         rm -f $tmpfile
64         false
65     fi
66 }
67
68 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
69 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
70
71 testit "noninteractive smbclient does not prompt" \
72     test_noninteractive_no_prompt || \
73     failed=`expr $failed + 1`
74
75 testit "noninteractive smbclient -l does not prompt" \
76    test_noninteractive_no_prompt -l /tmp || \
77     failed=`expr $failed + 1`
78
79 testit "interactive smbclient prompts on stdout" \
80    test_interactive_prompt_stdout || \
81     failed=`expr $failed + 1`
82
83 testit "interactive smbclient -l prompts on stdout" \
84    test_interactive_prompt_stdout -l /tmp || \
85     failed=`expr $failed + 1`
86
87 testok $0 $failed