upgradeprovision: never use xattr it's pointless in this usecase
[Samba/ekacnet.git] / source3 / script / tests / test_smbclient_s3.sh
blobff5022015f89fa9c31f5183aa00caa5cb10b1a7d
1 #!/bin/sh
3 # this runs the file serving tests that are expected to pass with samba3
5 if [ $# -lt 4 ]; then
6 cat <<EOF
7 Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD
8 EOF
9 exit 1;
12 SERVER="$1"
13 SERVER_IP="$2"
14 USERNAME="$3"
15 PASSWORD="$4"
16 SMBCLIENT="$VALGRIND ${SMBCLIENT:-$BINDIR/smbclient} $CONFIGURATION"
17 shift 4
18 ADDARGS="$*"
20 test x"$TEST_FUNCTIONS_SH" != x"INCLUDED" && {
21 incdir=`dirname $0`
22 . $incdir/test_functions.sh
25 failed=0
27 # Test that a noninteractive smbclient does not prompt
28 test_noninteractive_no_prompt()
30 prompt="smb"
32 cmd='echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
33 eval echo "$cmd"
34 out=`eval $cmd`
36 if [ $? != 0 ] ; then
37 echo "$out"
38 echo "command failed"
39 false
40 return
43 echo "$out" | grep $prompt >/dev/null 2>&1
45 if [ $? = 0 ] ; then
46 # got a prompt .. fail
47 echo matched interactive prompt in non-interactive mode
48 false
49 else
50 true
54 # Test that an interactive smbclient prompts to stdout
55 test_interactive_prompt_stdout()
57 prompt="smb"
58 tmpfile=/tmp/smbclient.in.$$
60 cat > $tmpfile <<EOF
62 quit
63 EOF
65 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
66 eval echo "$cmd"
67 out=`eval $cmd`
68 ret=$?
69 rm -f $tmpfile
71 if [ $ret != 0 ] ; then
72 echo "$out"
73 echo "command failed"
74 false
75 return
78 echo "$out" | grep $prompt >/dev/null 2>&1
80 if [ $? = 0 ] ; then
81 # got a prompt .. succeed
82 true
83 else
84 echo failed to match interactive prompt on stdout
85 false
89 # Test creating a bad symlink and deleting it.
90 test_bad_symlink()
92 prompt="posix_unlink deleted file /newname"
93 tmpfile=/tmp/smbclient.in.$$
95 cat > $tmpfile <<EOF
96 posix
97 posix_unlink newname
98 symlink badname newname
99 posix_unlink newname
100 quit
103 cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
104 eval echo "$cmd"
105 out=`eval $cmd`
106 ret=$?
107 rm -f $tmpfile
109 if [ $ret != 0 ] ; then
110 echo "$out"
111 echo "failed create then delete bad symlink with error $ret"
112 false
113 return
116 echo "$out" | grep "$prompt" >/dev/null 2>&1
118 ret=$?
119 if [ $ret = 0 ] ; then
120 # got the correct prompt .. succeed
121 true
122 else
123 echo "$out"
124 echo "failed create then delete bad symlink - grep failed with $ret"
125 false
130 testit "smbclient -L $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
131 testit "smbclient -L $SERVER -I $SERVER_IP" $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed=`expr $failed + 1`
133 testit "noninteractive smbclient does not prompt" \
134 test_noninteractive_no_prompt || \
135 failed=`expr $failed + 1`
137 testit "noninteractive smbclient -l does not prompt" \
138 test_noninteractive_no_prompt -l /tmp || \
139 failed=`expr $failed + 1`
141 testit "interactive smbclient prompts on stdout" \
142 test_interactive_prompt_stdout || \
143 failed=`expr $failed + 1`
145 testit "interactive smbclient -l prompts on stdout" \
146 test_interactive_prompt_stdout -l /tmp || \
147 failed=`expr $failed + 1`
149 testit "creating a bad symlink and deleting it" \
150 test_bad_symlink || \
151 failed=`expr $failed + 1`
153 testok $0 $failed