summaryrefslogtreecommitdiff
path: root/source4/client
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-06-26 10:56:59 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-06-26 10:56:59 +0200
commit26e9194e3a3ff9b065fec43ad5f3b63187eb533b (patch)
treeb51e0d4bfca35a0482f8cd06a21e857128d1e815 /source4/client
parent4f4949a8f4d729e189e873f8f5b0161e875d3501 (diff)
downloadsamba-26e9194e3a3ff9b065fec43ad5f3b63187eb533b.tar.gz
samba-26e9194e3a3ff9b065fec43ad5f3b63187eb533b.tar.bz2
samba-26e9194e3a3ff9b065fec43ad5f3b63187eb533b.zip
Move blackbox tests closer to what they're testing.
(This used to be commit c9b2e2aa861ccc01e5d92cfe468be1f6324ed294)
Diffstat (limited to 'source4/client')
-rwxr-xr-xsource4/client/tests/test_cifsdd.sh73
-rwxr-xr-xsource4/client/tests/test_smbclient.sh166
2 files changed, 239 insertions, 0 deletions
diff --git a/source4/client/tests/test_cifsdd.sh b/source4/client/tests/test_cifsdd.sh
new file mode 100755
index 0000000000..08bfb25e80
--- /dev/null
+++ b/source4/client/tests/test_cifsdd.sh
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# Basic script to make sure that cifsdd can do both local and remote I/O.
+
+if [ $# -lt 4 ]; then
+cat <<EOF
+Usage: test_cifsdd.sh SERVER USERNAME PASSWORD DOMAIN
+EOF
+exit 1;
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+samba4bindir=`dirname $0`/../../bin
+DD=$samba4bindir/cifsdd
+
+SHARE=tmp
+DEBUGLEVEL=1
+
+runcopy() {
+ message="$1"
+ shift
+
+ testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
+ "$@" || failed=`expr $failed + 1`
+}
+
+compare() {
+ testit "$1" cmp "$2" "$3" || failed=`expr $failed + 1`
+}
+
+sourcepath=tempfile.src.$$
+destpath=tempfile.dst.$$
+
+# Create a source file with arbitrary contents
+dd if=$DD of=$sourcepath bs=1024 count=50 > /dev/null
+
+ls -l $sourcepath
+
+for bs in 512 4k 48k ; do
+
+echo "Testing $bs block size ..."
+
+# Check whether we can do local IO
+runcopy "Testing local -> local copy" if=$sourcepath of=$destpath bs=$bs
+compare "Checking local differences" $sourcepath $destpath
+
+# Check whether we can do a round trip
+runcopy "Testing local -> remote copy" \
+ if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
+runcopy "Testing remote -> local copy" \
+ if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs
+compare "Checking differences" $sourcepath $destpath
+
+# Check that copying within the remote server works
+runcopy "Testing local -> remote copy" \
+ if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs
+runcopy "Testing remote -> remote copy" \
+ if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs
+runcopy "Testing remote -> local copy" \
+ if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs
+compare "Checking differences" $sourcepath $destpath
+
+done
+
+rm -f $sourcepath $destpath
+
+exit $failed
diff --git a/source4/client/tests/test_smbclient.sh b/source4/client/tests/test_smbclient.sh
new file mode 100755
index 0000000000..27a3488c88
--- /dev/null
+++ b/source4/client/tests/test_smbclient.sh
@@ -0,0 +1,166 @@
+#!/bin/sh
+# Blackbox tests for smbclient
+# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2006-2007 Andrew Bartlett <abartlet@samba.org>
+
+if [ $# -lt 5 ]; then
+cat <<EOF
+Usage: test_smbclient.sh SERVER USERNAME PASSWORD DOMAIN PREFIX
+EOF
+exit 1;
+fi
+
+SERVER=$1
+USERNAME=$2
+PASSWORD=$3
+DOMAIN=$4
+PREFIX=$5
+shift 5
+failed=0
+
+samba4bindir=`dirname $0`/../../bin
+smbclient=$samba4bindir/smbclient
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+runcmd() {
+ name="$1"
+ cmd="$2"
+ shift
+ shift
+ echo "test: $name"
+ $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ fi
+ return $status
+}
+
+testit "share and server list" $VALGRIND $smbclient -L $SERVER $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
+
+testit "share and server list anonymously" $VALGRIND $smbclient -N -L $SERVER $CONFIGURATION $@ || failed=`expr $failed + 1`
+
+testit "domain join" $VALGRIND bin/net join $DOMAIN $CONFIGURATION -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
+
+# Generate random file
+cat >tmpfile<<EOF
+foo
+bar
+bloe
+blah
+EOF
+
+# put that file
+runcmd "MPutting file" 'mput tmpfile' || failed=`expr $failed + 1`
+# check file info
+runcmd "Getting alternative name" 'altname tmpfile'|| failed=`expr $failed + 1`
+# run allinfo on that file
+runcmd "Checking info on file" 'allinfo tmpfile'|| failed=`expr $failed + 1`
+# get that file
+mv tmpfile tmpfile-old
+runcmd "MGetting file" 'mget tmpfile' || failed=`expr $failed + 1`
+# remove that file
+runcmd "Removing file" 'rm tmpfile' || failed=`expr $failed + 1`
+# compare locally
+testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
+# create directory
+# cd to directory
+# cd to top level directory
+# remove directory
+runcmd "Creating directory, Changing directory, Going back" 'mkdir bla; cd bla; cd ..; rmdir bla' || failed=`expr $failed + 1`
+# enable recurse, create nested directory
+runcmd "Creating nested directory" 'mkdir bla/bloe' || failed=`expr $failed + 1`
+# remove child directory
+runcmd "Removing directory" 'rmdir bla/bloe' || failed=`expr $failed + 1`
+# remove parent directory
+runcmd "Removing directory" 'rmdir bla'|| failed=`expr $failed + 1`
+# enable recurse, create nested directory
+runcmd "Creating nested directory" 'mkdir bla' || failed=`expr $failed + 1`
+# rename bla to bla2
+runcmd "rename of nested directory" 'rename bla bla2' || failed=`expr $failed + 1`
+# deltree
+runcmd "deltree of nested directory" 'deltree bla2' || failed=`expr $failed + 1`
+# run fsinfo
+runcmd "Getting file system info" 'fsinfo allocation'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volume'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volumeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo sizeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo deviceinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo attributeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volume-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo size-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo device-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo attribute-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo quota-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo fullsize-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo objectid'|| failed=`expr $failed + 1`
+
+# put that file
+runcmd "Putting file" 'put tmpfile'|| failed=`expr $failed + 1`
+# get that file
+mv tmpfile tmpfile-old
+runcmd "Getting file" 'get tmpfile'|| failed=`expr $failed + 1`
+runcmd "Getting file EA info" 'eainfo tmpfile'|| failed=`expr $failed + 1`
+# remove that file
+runcmd "Removing file" 'rm tmpfile' || failed=`expr $failed + 1`
+# compare locally
+testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
+# put that file
+runcmd "Putting file with different name" 'put tmpfile tmpfilex' || failed=`expr $failed + 1`
+# get that file
+runcmd "Getting file again" 'get tmpfilex' || failed=`expr $failed + 1`
+# compare locally
+testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
+# remove that file
+runcmd "Removing file" 'rm tmpfilex'|| failed=`expr $failed + 1`
+
+runcmd "Lookup name" "lookup $DOMAIN\\$USERNAME" || failed=`expr $failed + 1`
+
+#Fails unless there are privilages
+#runcmd "Lookup privs of name" "privileges $DOMAIN\\$USERNAME" || failed=`expr $failed + 1`
+
+# do some simple operations using old protocol versions
+runcmd "List directory with LANMAN1" 'ls' -m LANMAN1 || failed=`expr $failed + 1`
+runcmd "List directory with LANMAN2" 'ls' -m LANMAN2 || failed=`expr $failed + 1`
+
+runcmd "Print current working directory" 'pwd'|| failed=`expr $failed + 1`
+
+testit "Test login with --machine-pass without kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k no || failed=`expr $failed + 1`
+
+testit "Test login with --machine-pass and kerberos" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --machine-pass -k yes || failed=`expr $failed + 1`
+
+(
+ echo "password=$PASSWORD"
+ echo "username=$USERNAME"
+ echo "domain=$DOMAIN"
+) > tmpauthfile
+
+testit "Test login with --authentication-file" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp --authentication-file=tmpauthfile || failed=`expr $failed + 1`
+
+PASSWD_FILE="tmppassfile"
+echo "$PASSWORD" > $PASSWD_FILE
+export PASSWD_FILE
+testit "Test login with PASSWD_FILE" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME" || failed=`expr $failed + 1`
+PASSWD_FILE=""
+export PASSWD_FILE
+unset PASSWD_FILE
+
+PASSWD="$PASSWORD"
+export PASSWD
+testit "Test login with PASSWD" $VALGRIND $smbclient -c 'ls' $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" -U"$USERNAME" || failed=`expr $failed + 1`
+
+oldUSER=$USER
+USER="$USERNAME"
+export USER
+testit "Test login with USER and PASSWD" $VALGRIND $smbclient -k no -c 'ls' $CONFIGURATION //$SERVER/tmp -W "$DOMAIN" || failed=`expr $failed + 1`
+PASSWD=
+export PASSWD
+unset PASSWD
+USER=$oldUSER
+export USER
+
+rm -f tmpfile tmpfile-old tmpfilex tmpauthfile tmppassfile
+exit $failed