[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / 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 [ $# != 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
16 incdir=`dirname $0`
17 . $incdir/test_functions.sh
18
19 failed=0
20
21 # Test that a noninteractive smbclient does not prompt
22 test_noninteractive_no_prompt()
23 {
24     prompt="smb"
25
26     echo du | \
27         $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp 2>&1 | \
28     grep $prompt
29
30     if [ $? = 0 ] ; then
31         # got a prompt .. fail
32         echo matched interactive prompt in non-interactive mode
33         false
34     else
35         true
36     fi
37 }
38
39 # Test that an interactive smbclient prompts to stdout
40 test_interactive_prompt_stdout()
41 {
42     prompt="smb"
43     tmpfile=/tmp/smbclient.in.$$
44
45     cat > $tmpfile <<EOF
46 du
47 quit
48 EOF
49
50     CLI_FORCE_INTERACTIVE=yes \
51     $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp \
52         < $tmpfile 2>/dev/null | \
53     grep $prompt
54
55     if [ $? = 0 ] ; then
56         # got a prompt .. succeed
57         rm -f $tmpfile
58         true
59     else
60         echo failed to match interactive prompt on stdout
61         rm -f $tmpfile
62         false
63     fi
64 }
65
66 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
67 testit "smbclient -L $SERVER" $SMBCLIENT $CONFIGURATION -L $SERVER -N -p 139 || failed=`expr $failed + 1`
68
69 testit "noninteractive smbclient does not prompt" \
70     test_noninteractive_no_prompt || \
71     failed=`expr $failed + 1`
72
73 testit "noninteractive smbclient -l does not prompt" \
74    test_noninteractive_no_prompt -l /tmp || \
75     failed=`expr $failed + 1`
76
77 testit "interactive smbclient prompts on stdout" \
78    test_interactive_prompt_stdout || \
79     failed=`expr $failed + 1`
80
81 testit "interactive smbclient -l prompts on stdout" \
82    test_interactive_prompt_stdout -l /tmp || \
83     failed=`expr $failed + 1`
84
85 testok $0 $failed