s3-selftest: Add test for posix large reads and writes
[gd/samba-autobuild/.git] / source3 / script / tests / test_smbclient_posix_large.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: test_smbclient_posix_large.sh ccache smbclient3 server prefix <smbclient args>
6 EOF
7 exit 1;
8 fi
9
10 KRB5CCNAME=$1
11 export KRB5CCNAME
12 SMBCLIENT3=$2
13 SERVER=$3
14 PREFIX=$4
15 shift 4
16 ADDARGS="$*"
17
18 # Test that a noninteractive smbclient does not prompt
19 test_large_write_read()
20 {
21
22     cat > $PREFIX/largefile-script <<EOF
23 posix
24 put $PREFIX/largefile largefile
25 get largefile $PREFIX/largefile2
26 rm largefile
27 quit
28 EOF
29
30     cmd='$SMBCLIENT3 //$SERVER/xcopy_share $ADDARGS < $PREFIX/largefile-script 2>&1'
31     eval echo "$cmd"
32     out=`eval $cmd`
33
34     if [ $? != 0 ] ; then
35         echo "$out"
36         echo "command failed"
37         false
38         return
39     fi
40
41     echo "$out" | grep "getting file" >/dev/null 2>&1
42
43     if [ $? = 0 ] ; then
44         true
45     else
46         echo did not get success message
47         false
48     fi
49 }
50
51 rm -f $PREFIX/largefile
52 dd if=/dev/zero of=$PREFIX/largefile skip=20M count=1 bs=1
53
54 incdir=`dirname $0`/../../../testprogs/blackbox
55 . $incdir/subunit.sh
56
57 testit "smbclient large posix write read" test_large_write_read || failed=`expr $failed + 1`
58
59 testit "cmp of read and written files" cmp $PREFIX/largefile $PREFIX/largefile2 || failed=`expr $failed + 1`
60 rm -f $PREFIX/largefile2
61
62 testok $0 $failed