08f5cad618184518558ba8e3c4046efb1ce570c6
[gd/samba-autobuild/.git] / source4 / script / tests / test_smbclient.sh
1 #!/bin/sh
2
3 if [ $# -lt 5 ]; then
4 cat <<EOF
5 Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
6 EOF
7 exit 1;
8 fi
9
10 SERVER=$1
11 USERNAME=$2
12 PASSWORD=$3
13 DOMAIN=$4
14 PREFIX=$5
15 shift 5
16 failed=0
17
18 runcmd() {
19         name="$1"
20         shift
21         testit "$name" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN "-U"$USERNAME"%"$PASSWORD" $@
22 }
23
24 incdir=`dirname $0`
25 . $incdir/test_functions.sh
26
27 # Generate random file
28 cat >tmpfile<<EOF
29 foo
30 bar
31 bloe
32 blah
33 EOF
34
35
36 # put that file
37 echo mput tmpfile | runcmd "MPutting file" || failed=`expr $failed + 1`
38 # check file info
39 echo altname tmpfile | runcmd "Getting alternative name" || failed=`expr $failed + 1`
40 # run allinfo on that file
41 echo allinfo tmpfile | runcmd "Checking info on file" || failed=`expr $failed + 1`
42 # get that file
43 mv tmpfile tmpfile-old
44 echo mget tmpfile | runcmd "MGetting file" || failed=`expr $failed + 1`
45 # remove that file
46 echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
47 # compare locally
48 testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
49 # create directory
50 echo mkdir bla | runcmd "Creating directory" || failed=`expr $failed + 1`
51 # cd to directory
52 echo cd bla | runcmd "Changing directory" || failed=`expr $failed + 1`
53 # cd to top level directory
54 echo cd .. | runcmd "Going back" || failed=`expr $failed + 1`
55 # remove directory
56 echo rmdir bla | runcmd "Removing directory"  || failed=`expr $failed + 1`
57 # enable recurse, create nested directory
58 echo "recurse; echo mkdir bla/bloe; exit" | runcmd "Creating nested directory" || failed=`expr $failed + 1`
59 # remove parent directory
60 echo rmdir bla/bloe | runcmd "Removing directory" || failed=`expr $failed + 1`
61 # remove child directory
62 echo rmdir bla | runcmd "Removing directory" || failed=`expr $failed + 1`
63 # run fsinfo
64 echo fsinfo objectid | runcmd "Getting file system info" || failed=`expr $failed + 1`
65
66 # put that file
67 echo put tmpfile | runcmd "Putting file" || failed=`expr $failed + 1`
68 # get that file
69 mv tmpfile tmpfile-old
70 echo get tmpfile | runcmd "Getting file" || failed=`expr $failed + 1`
71 # remove that file
72 echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
73 # compare locally
74 testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
75 # put that file
76 echo put tmpfile tmpfilex | runcmd "Putting file with different name" || failed=`expr $failed + 1`
77 # get that file
78 echo get tmpfilex | runcmd "Getting file again" || failed=`expr $failed + 1`
79 # compare locally
80 testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
81 # remove that file
82 echo rm tmpfilex | runcmd "Removing file" || failed=`expr $failed + 1`
83
84 # do some simple operations using old protocol versions
85 echo ls | runcmd "List directory with LANMAN1" -m LANMAN1 || failed=`expr $failed + 1`
86 echo ls | runcmd "List directory with LANMAN2" -m LANMAN2 || failed=`expr $failed + 1`
87
88 rm -f tmpfile tmpfile-old tmpfilex
89
90 testok $0 $failed