2006-03-23 14:55:38 +00:00
#!/bin/sh
# this runs the file serving tests that are expected to pass with samba3
2009-01-29 10:29:35 +01:00
if [ $# -lt 4 ] ; then
2006-03-23 14:55:38 +00:00
cat <<EOF
2009-01-29 10:29:35 +01:00
Usage: test_smbclient_s3.sh SERVER SERVER_IP USERNAME PASSWORD
2006-03-23 14:55:38 +00:00
EOF
exit 1;
fi
SERVER = " $1 "
SERVER_IP = " $2 "
2009-01-29 10:29:35 +01:00
USERNAME = " $3 "
PASSWORD = " $4 "
2006-08-30 16:58:29 +00:00
SMBCLIENT = " $VALGRIND ${ SMBCLIENT :- $BINDIR /smbclient } $CONFIGURATION "
2009-01-29 10:29:35 +01:00
shift 4
2008-01-04 16:58:23 -08:00
ADDARGS = " $* "
2006-03-23 14:55:38 +00:00
2009-01-30 13:57:24 +01:00
test x" $TEST_FUNCTIONS_SH " != x"INCLUDED" && {
2007-10-10 15:34:30 -05:00
incdir = ` dirname $0 `
. $incdir /test_functions.sh
2009-01-30 13:57:24 +01:00
}
2006-03-23 14:55:38 +00:00
2007-10-10 15:34:30 -05:00
failed = 0
2007-09-28 22:16:14 +00:00
2006-06-15 23:47:41 +00:00
# Test that a noninteractive smbclient does not prompt
test_noninteractive_no_prompt( )
{
prompt = "smb"
2009-01-29 10:29:35 +01:00
cmd = 'echo du | $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS 2>&1'
eval echo " $cmd "
out = ` eval $cmd `
if [ $? != 0 ] ; then
echo " $out "
echo "command failed"
false
return
fi
echo " $out " | grep $prompt >/dev/null 2>& 1
2006-06-15 23:47:41 +00:00
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"
2006-06-16 04:44:59 +00:00
tmpfile = /tmp/smbclient.in.$$
2006-06-15 23:47:41 +00:00
2006-06-16 04:44:59 +00:00
cat > $tmpfile <<EOF
du
quit
EOF
2009-01-29 10:29:35 +01:00
cmd = 'CLI_FORCE_INTERACTIVE=yes $SMBCLIENT $CONFIGURATION "$@" -U$USERNAME%$PASSWORD //$SERVER/tmp -I $SERVER_IP $ADDARGS < $tmpfile 2>&1'
eval echo " $cmd "
out = ` eval $cmd `
ret = $?
rm -f $tmpfile
if [ $ret != 0 ] ; then
echo " $out "
echo "command failed"
false
return
fi
echo " $out " | grep $prompt >/dev/null 2>& 1
2006-06-15 23:47:41 +00:00
if [ $? = 0 ] ; then
# got a prompt .. succeed
true
else
echo failed to match interactive prompt on stdout
false
fi
}
2006-10-08 20:17:55 +00:00
testit " smbclient -L $SERVER_IP " $SMBCLIENT $CONFIGURATION -L $SERVER_IP -N -p 139 || failed = ` expr $failed + 1`
2007-12-29 13:10:25 +01:00
testit " smbclient -L $SERVER -I $SERVER_IP " $SMBCLIENT $CONFIGURATION -L $SERVER -I $SERVER_IP -N -p 139 || failed = ` expr $failed + 1`
2006-06-15 23:47:41 +00:00
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`
2006-03-23 14:55:38 +00:00
2007-10-10 15:34:30 -05:00
testok $0 $failed