wmi-1.3.16 from opsview.com

This commit is contained in:
Are Casilla
2019-02-16 00:16:52 +01:00
parent 163fdd3d1b
commit 17b3af2911
2146 changed files with 678824 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
This directory contains test scripts that are useful for running a
bunch of tests all at once. I expect it will eventually be hooked into
a "make test" framework.
+448
View File
@@ -0,0 +1,448 @@
#!/bin/sh
if [ $# -lt 1 ]
then
echo "$0 PREFIX"
exit 1
fi
PREFIX=$1
if test -z "$TLS_ENABLED"; then
TLS_ENABLED=false
fi
if test -z "$SHARE_BACKEND"; then
SHARE_BACKEND=classic
fi
if test -z "$SMBD_LOGLEVEL"; then
SMBD_LOGLEVEL=1
fi
DOMAIN=SAMBADOMAIN
USERNAME=administrator
REALM=SAMBA.EXAMPLE.COM
DNSNAME="samba.example.com"
BASEDN="dc=samba,dc=example,dc=com"
PASSWORD=penguin
AUTH="-U$USERNAME%$PASSWORD"
SRCDIR=`pwd`
ROOT=$USER
SERVER=localhost
NETBIOSNAME=localtest
if test -z "$ROOT"; then
ROOT=$LOGNAME
fi
if test -z "$ROOT"; then
ROOT=`whoami`
fi
oldpwd=`pwd`
srcdir=`dirname $0`/../..
mkdir -p $PREFIX || exit $?
cd $PREFIX
PREFIX_ABS=`pwd`
export PREFIX_ABS
cd $oldpwd
TEST_DATA_PREFIX=$PREFIX_ABS
export TEST_DATA_PREFIX
TMPDIR=$PREFIX_ABS/tmp
ETCDIR=$PREFIX_ABS/etc
PIDDIR=$PREFIX_ABS/pid
CONFFILE=$ETCDIR/smb.conf
KRB5_CONFIG=$ETCDIR/krb5.conf
PRIVATEDIR=$PREFIX_ABS/private
NCALRPCDIR=$PREFIX_ABS/ncalrpc
LOCKDIR=$PREFIX_ABS/lockdir
TLSDIR=$PRIVATEDIR/tls
DHFILE=$TLSDIR/dhparms.pem
CAFILE=$TLSDIR/ca.pem
CERTFILE=$TLSDIR/cert.pem
KEYFILE=$TLSDIR/key.pem
WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket
CONFIGURATION="--configfile=$CONFFILE"
LDAPDIR=$PREFIX_ABS/ldap
SLAPD_CONF=$LDAPDIR/slapd.conf
export CONFIGURATION
export CONFFILE
export SLAPD_CONF
export PIDDIR
export AUTH
export SERVER
export NETBIOSNAME
rm -rf $PREFIX/*
mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $TLSDIR $LDAPDIR/db $LDAPDIR/db/bdb-logs $LDAPDIR/db/tmp
if [ -z "$VALGRIND" ]; then
nativeiconv="true"
else
nativeiconv="false"
fi
cat >$CONFFILE<<EOF
[global]
iconv:native = $nativeiconv
netbios name = $NETBIOSNAME
netbios aliases = $SERVER
workgroup = $DOMAIN
realm = $REALM
private dir = $PRIVATEDIR
pid directory = $PIDDIR
ncalrpc dir = $NCALRPCDIR
lock dir = $LOCKDIR
share backend = $SHARE_BACKEND
setup directory = $SRCDIR/setup
js include = $SRCDIR/scripting/libjs
winbindd socket directory = $WINBINDD_SOCKET_DIR
name resolve order = bcast
interfaces = 127.0.0.1/8
tls enabled = $TLS_ENABLED
tls dh params file = $DHFILE
panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
wins support = yes
server role = pdc
max xmit = 32K
server max protocol = SMB2
notify:inotify = false
ldb:nosync = true
torture:subunitdir = $SRCDIR/bin/torture
torture:basedir = $TEST_DATA_PREFIX
system:anonymous = true
#We don't want to pass our self-tests if the PAC code is wrong
gensec:require_pac = true
log level = $SMBD_LOGLEVEL
[tmp]
path = $TMPDIR
read only = no
ntvfs handler = posix
posix:sharedelay = 100000
posix:eadb = $LOCKDIR/eadb.tdb
[cifs]
read only = no
ntvfs handler = cifs
cifs:server = $SERVER
cifs:user = $USERNAME
cifs:password = $PASSWORD
cifs:domain = $DOMAIN
cifs:share = tmp
[simple]
path = $TMPDIR
read only = no
ntvfs handler = simple
[cifsposixtestshare]
read only = no
ntvfs handler = cifsposix
path = $TMPDIR
EOF
## Override default srahes_config.ldb file
rm -f $PRIVATEDIR/share.ldb
cat >$PRIVATEDIR/share.ldif<<EOF
### Shares basedn
dn: @INDEXLIST
@IDXATTR: name
dn: @ATTRIBUTES
cn: CASE_INSENSITIVE
dc: CASE_INSENSITIVE
name: CASE_INSENSITIVE
dn: CASE_INSENSITIVE
objectClass: CASE_INSENSITIVE
dn: CN=Shares
objectClass: top
objectClass: organizationalUnit
cn: Shares
### Default IPC$ Share
dn: CN=IPC$,CN=Shares
objectClass: top
objectClass: share
cn: IPC$
name: IPC$
type: IPC
path: /tmp
comment: Remote IPC
max-connections: -1
available: True
readonly: True
browseable: False
ntvfs-handler: default
### Default ADMIN$ Share
dn: CN=ADMIN$,CN=Shares
objectClass: top
objectClass: share
cn: ADMIN$
name: ADMIN$
type: DISK
path: /tmp
comment: Remote Admin
max-connections: -1
available: True
readonly: True
browseable: False
ntvfs-handler: default
dn: CN=tmp,CN=Shares
objectClass: top
objectClass: share
cn: tmp
name: tmp
type: DISK
path: $TMPDIR
comment: Temp Dir for Tests
readonly: False
ntvfs-handler: posix
posix-sharedelay: 100000
posix-eadb: $LOCKDIR/eadb.tdb
dn: CN=cifs,CN=Shares
objectClass: top
objectClass: share
cn: cifs
name: cifs
type: DISK
readonly: False
ntvfs-handler: cifs
cifs-server: $SERVER
cifs-user: $USERNAME
cifs-password: $PASSWORD
cifs-domain: $DOMAIN
cifs-share: tmp
EOF
$srcdir/bin/ldbadd -H $PRIVATEDIR/share.ldb < $PRIVATEDIR/share.ldif >/dev/null || exit 1
cat >$KRB5_CONFIG<<EOF
[libdefaults]
default_realm = SAMBA.EXAMPLE.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
forwardable = yes
[realms]
SAMBA.EXAMPLE.COM = {
kdc = 127.0.0.1:88
admin_server = 127.0.0.1:88
default_domain = samba.example.com
}
[domain_realm]
.samba.example.com = SAMBA.EXAMPLE.COM
EOF
export KRB5_CONFIG
cat >$DHFILE<<EOF
-----BEGIN DH PARAMETERS-----
MGYCYQC/eWD2xkb7uELmqLi+ygPMKyVcpHUo2yCluwnbPutEueuxrG/Cys8j8wLO
svCN/jYNyR2NszOmg7ZWcOC/4z/4pWDVPUZr8qrkhj5MRKJc52MncfaDglvEdJrv
YX70obsCAQI=
-----END DH PARAMETERS-----
EOF
cat >$CAFILE<<EOF
-----BEGIN CERTIFICATE-----
MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
jAAwgYgCgYC3WJ7DNQAVnqiJxhf6Tq4pqNyUIlioDFNnkJZ6ycElhblyDb3vaagO
9c+saw3cl/4KGWBZK46HtimRApE6ZriV7yHSB4afVjhnHZvlQVccAuTKJatBpIeb
kenOX0boUVXrWWj6VVnseab+5nA+uPZQQHinRLEVhUn72I14YdKJOQIDAQABoyUw
IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
BQOBgQA5IVkBXU2S4i3dSSM9KmdKJinok1IOGNLZYQSyzduuie9vTmGXCQiQppWb
oSjZaf/Zn8La8THvm4QfmwruPkTEL956BRyN9hHYwHWZsebJr7DvSrF1Zugd0jFs
DZZFfDUSinYEqApdYzMka/GYTSk1Fa31G5TVD56mIdxmVAdC+A==
-----END CERTIFICATE-----
EOF
cat >$CERTFILE<<EOF
-----BEGIN CERTIFICATE-----
MIICYTCCAcygAwIBAgIE5M7SRDALBgkqhkiG9w0BAQUwZTEdMBsGA1UEChMUU2Ft
YmEgQWRtaW5pc3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1
dG9nZW5lcmF0ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMB4XDTA2MDgw
NDA0MzY1MloXDTA4MDcwNDA0MzY1MlowZTEdMBsGA1UEChMUU2FtYmEgQWRtaW5p
c3RyYXRpb24xNDAyBgNVBAsTK1NhbWJhIC0gdGVtcG9yYXJ5IGF1dG9nZW5lcmF0
ZWQgY2VydGlmaWNhdGUxDjAMBgNVBAMTBVNhbWJhMIGcMAsGCSqGSIb3DQEBAQOB
jAAwgYgCgYDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpcol3+
S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H6H+p
PqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQABoyUw
IzAMBgNVHRMBAf8EAjAAMBMGA1UdJQQMMAoGCCsGAQUFBwMBMAsGCSqGSIb3DQEB
BQOBgQAmkN6XxvDnoMkGcWLCTwzxGfNNSVcYr7TtL2aJh285Xw9zaxcm/SAZBFyG
LYOChvh6hPU7joMdDwGfbiLrBnMag+BtGlmPLWwp/Kt1wNmrRhduyTQFhN3PP6fz
nBr9vVny2FewB2gHmelaPS//tXdxivSXKz3NFqqXLDJjq7P8wA==
-----END CERTIFICATE-----
EOF
cat >$KEYFILE<<EOF
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDKg6pAwCHUMA1DfHDmWhZfd+F0C+9Jxcqvpw9ii9En3E1uflpc
ol3+S9/6I/uaTmJHZre+DF3dTzb/UOZo0Zem8N+IzzkgoGkFafjXuT3BL5UPY2/H
6H+pPqVIRLOmrWImai359YyoKhFyo37Y6HPeU8QcZ+u2rS9geapIWfeuowIDAQAB
AoGAAqDLzFRR/BF1kpsiUfL4WFvTarCe9duhwj7ORc6fs785qAXuwUYAJ0Uvzmy6
HqoGv3t3RfmeHDmjcpPHsbOKnsOQn2MgmthidQlPBMWtQMff5zdoYNUFiPS0XQBq
szNW4PRjaA9KkLQVTwnzdXGkBSkn/nGxkaVu7OR3vJOBoo0CQQDO4upypesnbe6p
9/xqfZ2uim8IwV1fLlFClV7WlCaER8tsQF4lEi0XSzRdXGUD/dilpY88Nb+xok/X
8Z8OvgAXAkEA+pcLsx1gN7kxnARxv54jdzQjC31uesJgMKQXjJ0h75aUZwTNHmZQ
vPxi6u62YiObrN5oivkixwFNncT9MxTxVQJBAMaWUm2SjlLe10UX4Zdm1MEB6OsC
kVoX37CGKO7YbtBzCfTzJGt5Mwc1DSLA2cYnGJqIfSFShptALlwedot0HikCQAJu
jNKEKnbf+TdGY8Q0SKvTebOW2Aeg80YFkaTvsXCdyXrmdQcifw4WdO9KucJiDhSz
Y9hVapz7ykEJtFtWjLECQQDIlfc63I5ZpXfg4/nN4IJXUW6AmPVOYIA5215itgki
cSlMYli1H9MEXH0pQMGv5Qyd0OYIx2DDg96mZ+aFvqSG
-----END RSA PRIVATE KEY-----
EOF
cat >$SLAPD_CONF <<EOF
loglevel 0
include $LDAPDIR/ad.schema
pidfile $PIDDIR/slapd.pid
argsfile $LDAPDIR/slapd.args
sasl-realm $DNSNAME
access to * by * write
allow update_anon
authz-regexp
uid=([^,]*),cn=$DNSNAME,cn=digest-md5,cn=auth
ldap:///$BASEDN??sub?(samAccountName=\$1)
authz-regexp
uid=([^,]*),cn=([^,]*),cn=digest-md5,cn=auth
ldap:///$BASEDN??sub?(samAccountName=\$1)
include $LDAPDIR/modules.conf
defaultsearchbase "$BASEDN"
backend bdb
database bdb
suffix "$BASEDN"
rootdn "cn=Manager,$BASEDN"
rootpw $PASSWORD
directory $LDAPDIR/db
index objectClass eq
index samAccountName eq
index name eq
index objectSid eq
index objectCategory eq
index member eq
index uidNumber eq
index gidNumber eq
index unixName eq
index privilege eq
index nCName eq pres
index lDAPDisplayName eq
index subClassOf eq
index dnsRoot eq
index nETBIOSName eq pres
overlay syncprov
syncprov-checkpoint 100 10
syncprov-sessionlog 100
EOF
cat > $LDAPDIR/db/DB_CONFIG <<EOF
#
# Set the database in memory cache size.
#
set_cachesize 0 524288 0
#
# Set database flags (this is a test environment, we don't need to fsync()).
#
set_flags DB_TXN_NOSYNC
#
# Set log values.
#
set_lg_regionmax 104857
set_lg_max 1048576
set_lg_bsize 209715
set_lg_dir $LDAPDIR/db/bdb-logs
#
# Set temporary file creation directory.
#
set_tmp_dir $LDAPDIR/db/tmp
EOF
PROVISION_OPTIONS="$CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1"
PROVISION_OPTIONS="$PROVISION_OPTIONS --quiet --domain $DOMAIN --realm $REALM"
PROVISION_OPTIONS="$PROVISION_OPTIONS --adminpass $PASSWORD --root=$ROOT"
PROVISION_OPTIONS="$PROVISION_OPTIONS --simple-bind-dn=cn=Manager,$BASEDN --password=$PASSWORD --root=$ROOT"
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS
LDAPI="ldapi://$LDAPDIR/ldapi"
LDAPI_ESCAPE="ldapi://"`echo $LDAPDIR/ldapi | sed 's|/|%2F|g'`
export LDAPI
export LDAPI_ESCAPE
#This uses the provision we just did, to read out the schema
$srcdir/bin/ad2oLschema $CONFIGURATION -H $PRIVATEDIR/sam.ldb -I $srcdir/setup/schema-map-openldap-2.3 -O $LDAPDIR/ad.schema
#Now create an LDAP baseDN
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-base
OLDPATH=$PATH
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
export PATH
MODCONF=$LDAPDIR/modules.conf
rm -f $MODCONF
touch $MODCONF
slaptest -u -f $SLAPD_CONF > /dev/null 2>&1 || {
echo "enabling slapd modules"
cat > $MODCONF <<EOF
modulepath /usr/lib/ldap
moduleload back_bdb
EOF
}
if slaptest -u -f $SLAPD_CONF; then
slapadd -f $SLAPD_CONF < $PRIVATEDIR/$DNSNAME.ldif || {
echo "slapadd failed"
}
slaptest -f $SLAPD_CONF || {
echo "slaptest after database load failed"
}
fi
PATH=$OLDPATH
export PATH
cat >$PRIVATEDIR/wins_config.ldif<<EOF
dn: name=TORTURE_6,CN=PARTNERS
objectClass: wreplPartner
name: TORTURE_6
address: 127.0.0.6
pullInterval: 0
pushChangeCount: 0
type: 0x3
EOF
$srcdir/bin/ldbadd -H $PRIVATEDIR/wins_config.ldb < $PRIVATEDIR/wins_config.ldif >/dev/null || exit 1
@@ -0,0 +1,5 @@
#!/bin/sh
SHARE_BACKEND="ldb"
. `dirname $0`/mktestsetup.sh
+153
View File
@@ -0,0 +1,153 @@
#!/bin/sh
# Bootstrap Samba and run a number of tests against it.
if [ $# -lt 1 ]
then
echo "$0 PREFIX TESTS"
exit
fi
ARG0=$0
ARG1=$1
ARG2=$2
ARG3=$3
if [ -z "$TORTURE_MAXTIME" ]; then
TORTURE_MAXTIME=1200
fi
# disable rpc validation when using valgrind - its way too slow
if [ -z "$VALGRIND" ]; then
VALIDATE="validate";
else
VALIDATE="";
fi
OLD_PWD=`pwd`
PREFIX=$ARG1
PREFIX=`echo $PREFIX | sed s+//+/+`
export PREFIX
# allow selection of the test lists
TESTS=$ARG2
if [ $TESTS = "all" ]; then
TLS_ENABLED="yes"
else
TLS_ENABLED="no"
fi
export TLS_ENABLED
LD_LDB_MODULE_PATH=$OLD_PWD/bin/modules/ldb
export LD_LDB_MODULE_PATH
LD_SAMBA_MODULE_PATH=$OLD_PWD/bin/modules
export LD_SAMBA_MODULE_PATH
LD_LIBRARY_PATH=$OLD_PWD/bin/shared:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
PKG_CONFIG_PATH=$OLD_PWD/bin/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH
incdir=`dirname $ARG0`
echo -n "PROVISIONING..."
. $incdir/mktestsetup.sh $PREFIX || exit 1
echo "DONE"
PATH=bin:$PATH
export PATH
DO_SOCKET_WRAPPER=$ARG3
if [ x"$DO_SOCKET_WRAPPER" = x"SOCKET_WRAPPER" ];then
SOCKET_WRAPPER_DIR="$PREFIX/w"
export SOCKET_WRAPPER_DIR
echo "SOCKET_WRAPPER_DIR=$SOCKET_WRAPPER_DIR"
else
echo "NOT USING SOCKET_WRAPPER"
fi
incdir=`dirname $ARG0`
. $incdir/test_functions.sh
#Start slapd before smbd
if [ x"$TEST_LDAP" = x"yes" ]; then
slapd_start || exit 1;
echo -n "LDAP PROVISIONING..."
$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI || {
echo "LDAP PROVISIONING failed: $srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS --ldap-backend=$LDAPI"
exit 1;
}
#LDAP is slow
TORTURE_MAXTIME=`expr $TORTURE_MAXTIME '*' 2`
fi
SMBD_TEST_FIFO="$PREFIX/smbd_test.fifo"
export SMBD_TEST_FIFO
SMBD_TEST_LOG="$PREFIX/smbd_test.log"
export SMBD_TEST_LOG
SOCKET_WRAPPER_DEFAULT_IFACE=1
export SOCKET_WRAPPER_DEFAULT_IFACE
smbd_check_or_start
SOCKET_WRAPPER_DEFAULT_IFACE=6
export SOCKET_WRAPPER_DEFAULT_IFACE
TORTURE_INTERFACES='127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8'
TORTURE_OPTIONS="--option=interfaces=$TORTURE_INTERFACES $CONFIGURATION"
# ensure any one smbtorture call doesn't run too long
TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$TORTURE_MAXTIME"
TORTURE_OPTIONS="$TORTURE_OPTIONS --target=samba4"
export TORTURE_OPTIONS
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
fi
START=`date`
(
# give time for nbt server to register its names
echo delaying for nbt name registration
sleep 4
# This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
bin/nmblookup $CONFIGURATION $SERVER
bin/nmblookup $CONFIGURATION -U $SERVER $SERVER
bin/nmblookup $CONFIGURATION $SERVER
bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
bin/nmblookup $CONFIGURATION $NETBIOSNAME
bin/nmblookup $CONFIGURATION -U $SERVER $NETBIOSNAME
# start off with 0 failures
failed=0
export failed
totalfailed=0
export totalfailed
. script/tests/tests_$TESTS.sh
exit $totalfailed
) 9>$SMBD_TEST_FIFO
failed=$?
kill `cat $PIDDIR/smbd.pid`
if [ "$TEST_LDAP"x = "yesx" ]; then
kill `cat $PIDDIR/slapd.pid`
fi
END=`date`
echo "START: $START ($ARG0)";
echo "END: $END ($ARG0)";
# if there were any valgrind failures, show them
count=`find $PREFIX -name 'valgrind.log*' | wc -l`
if [ "$count" != 0 ]; then
for f in $PREFIX/valgrind.log*; do
if [ -s $f ] && grep -v DWARF2.CFI.reader $f > /dev/null; then
echo "VALGRIND FAILURE";
failed=`expr $failed + 1`
cat $f
fi
done
fi
teststatus $ARG0 $failed
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_binding_string.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0;
for I in "ncacn_np:$server" \
"ncacn_ip_tcp:$server" \
"ncacn_np:$server[rpcecho]" \
"ncacn_np:$server[/pipe/rpcecho]" \
"ncacn_np:$server[/pipe/rpcecho,sign,seal]" \
"ncacn_np:$server[,sign]" \
"ncacn_ip_tcp:$server[,sign]" \
"ncalrpc:" \
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:$server" \
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$server"
do
testit "$I" bin/smbtorture $TORTURE_OPTIONS "$I" -U"$username"%"$password" -W $domain --option=torture:quick=yes RPC-ECHO "$*" || failed=`expr $failed + 1`
done
testok $0 $failed
+79
View File
@@ -0,0 +1,79 @@
#!/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
DD=bin/cifsdd
SHARE=tmp
DEBUGLEVEL=1
failed=0
failtest() {
failed=`expr $failed + 1`
}
runcopy() {
message="$1"
shift
testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
"$@"
}
compare() {
cmp "$1" "$2"
}
incdir=`dirname $0`
. $incdir/test_functions.sh
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 || failtest
compare $sourcepath $destpath || failtest
# Check whether we can do a round trip
runcopy "Testing local -> remote copy" \
if=$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
runcopy "Testing remote -> local copy" \
if=//$SERVER/$SHARE/$sourcepath of=$destpath bs=$bs || failtest
compare $sourcepath $destpath || failtest
# Check that copying within the remote server works
runcopy "Testing local -> remote copy" \
if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$sourcepath bs=$bs || failtest
runcopy "Testing remote -> remote copy" \
if=//$SERVER/$SHARE/$sourcepath of=//$SERVER/$SHARE/$destpath bs=$bs || failtest
runcopy "Testing remote -> local copy" \
if=//$SERVER/$SHARE/$destpath of=$destpath bs=$bs || failtest
compare $sourcepath $destpath || failtest
done
rm -f $sourcepath $destpath
testok $0 $failed
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_echo.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
incdir=`dirname $0`
. $incdir/test_functions.sh
transports="ncacn_np ncacn_ip_tcp"
if [ $server = "localhost" ]; then
transports="ncalrpc $transports"
fi
if [ $server = "localtest" ]; then
transports="ncalrpc $transports"
fi
failed=0
for transport in $transports; do
for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do
for ntlmoptions in \
"--option=socket:testnonblock=True --option=torture:quick=yes"; do
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
done
done
done
for transport in $transports; do
for bindoptions in sign seal; do
for ntlmoptions in \
"--option=ntlmssp_client:ntlm2=yes --option=torture:quick=yes" \
"--option=ntlmssp_client:ntlm2=no --option=torture:quick=yes" \
"--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:128bit=no --option=torture:quick=yes" \
"--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:128bit=no --option=torture:quick=yes" \
"--option=ntlmssp_client:ntlm2=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
"--option=ntlmssp_client:ntlm2=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
"--option=clientntlmv2auth=yes --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes" \
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
; do
name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
done
done
done
name="RPC-ECHO on ncacn_np over smb2"
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server[smb2]" -U"$username"%"$password" -W $domain RPC-ECHO "$*" || failed=`expr $failed + 1`
testok $0 $failed
+38
View File
@@ -0,0 +1,38 @@
#!/bin/sh
# test some simple EJS operations
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_ejs.sh DOMAIN USERNAME PASSWORD
EOF
exit 1;
fi
DOMAIN="$1"
USERNAME="$2"
PASSWORD="$3"
incdir=`dirname $0`
. $incdir/test_functions.sh
SCRIPTDIR=../testprogs/ejs
DATADIR=../testdata
PATH=bin:$PATH
export PATH
testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION || failed=`expr $failed + 1`
for f in samr.js echo.js; do
testit "$f" $SCRIPTDIR/$f $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
done
testit "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser || failed=`expr $failed + 1`
testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION || failed=`expr $failed + 1`
testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ || failed=`expr $failed + 1`
testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
testok $0 $failed
+215
View File
@@ -0,0 +1,215 @@
#!/bin/sh
smbd_check_or_start() {
if [ -n "$SMBD_TEST_FIFO" ];then
if [ -p "$SMBD_TEST_FIFO" ];then
return 0;
fi
if [ -n "$SOCKET_WRAPPER_DIR" ];then
if [ -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
else
mkdir -p $SOCKET_WRAPPER_DIR
fi
fi
rm -f $SMBD_TEST_FIFO
mkfifo $SMBD_TEST_FIFO
rm -f $SMBD_TEST_LOG
echo -n "STARTING SMBD..."
((
if [ -z "$SMBD_MAXTIME" ]; then
SMBD_MAXTIME=5400
fi
$SMBD_VALGRIND $SRCDIR/bin/smbd --maximum-runtime=$SMBD_MAXTIME -s $CONFFILE -M single -i --leak-report-full < $SMBD_TEST_FIFO > $SMBD_TEST_LOG 2>&1;
ret=$?;
rm -f $SMBD_TEST_FIFO;
if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
fi
if [ x"$ret" = x"0" ];then
echo "smbd exits with status $ret";
echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
elif [ x"$ret" = x"137" ];then
echo "smbd got SIGXCPU and exits with status $ret!"
echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
else
echo "smbd failed with status $ret!"
echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
fi
exit $ret;
) || exit $? &) 2>/dev/null || exit $?
echo "DONE"
fi
return 0;
}
smbd_check_only() {
if [ -n "$SMBD_TEST_FIFO" ];then
if [ -p "$SMBD_TEST_FIFO" ];then
return 0;
fi
return 1;
fi
return 0;
}
smbd_have_test_log() {
if [ -n "$SMBD_TEST_LOG" ];then
if [ -r "$SMBD_TEST_LOG" ];then
return 0;
fi
fi
return 1;
}
slapd_start() {
OLDPATH=$PATH
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
export PATH
# running slapd in the background means it stays in the same process group, so it can be
# killed by timelimit
slapd -d0 -f $SLAPD_CONF -h $LDAPI_ESCAPE &
PATH=$OLDPATH
export PATH
return $?;
}
testit() {
if [ -z "$PREFIX" ]; then
PREFIX=test_prefix
mkdir -p $PREFIX
fi
name=$1
shift 1
cmdline="$*"
SMBD_IS_UP="no"
shname=`echo $name | \
sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
UNIQUE_PID=`/bin/sh -c 'echo $$'`
TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
if [ -n "$SMBD_TEST_LOG" -a -z "$smbd_log_size" ]; then
smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "--==--==--==--==--==--==--==--==--==--==--"
echo "Running test $name (level 0 stdout)"
echo "--==--==--==--==--==--==--==--==--==--==--"
date
echo "Testing $name"
else
nf="`expr $failed + $totalfailed`";
if [ "$nf" = "0" ]; then
echo "Testing $name"
else
echo "Testing $name ($nf tests failed so far)"
fi
fi
smbd_check_only && SMBD_IS_UP="yes"
if [ x"$SMBD_IS_UP" != x"yes" ];then
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "SMBD is down! Skipping: $cmdline"
echo "=========================================="
echo "TEST SKIPPED: $name (reason SMBD is down)"
echo "=========================================="
else
echo "TEST SKIPPED: $name (reason SMBD is down)"
fi
return 1
fi
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
export SOCKET_WRAPPER_PCAP_FILE
fi
( $cmdline > $TEST_LOG 2>&1 )
status=$?
# show any additional output from smbd that has happened in this test
smbd_have_test_log && {
new_log_size=`wc -l < $SMBD_TEST_LOG`;
test "$new_log_size" = "$smbd_log_size" || {
echo "SMBD OUTPUT:";
incr_log_size=`expr $new_log_size - $smbd_log_size`;
tail -$incr_log_size $SMBD_TEST_LOG;
smbd_log_size=$new_log_size;
}
}
if [ x"$status" != x"0" ]; then
echo "TEST OUTPUT:"
cat $TEST_LOG;
rm -f $TEST_LOG;
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
echo "TEST PCAP: $TEST_PCAP"
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "=========================================="
echo "TEST FAILED: $name (status $status)"
echo "=========================================="
else
echo "TEST FAILED: $cmdline (status $status)"
fi
trap "" EXIT
return 1;
fi
rm -f $TEST_LOG;
if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
echo "TEST PCAP: $TEST_PCAP"
else
rm -f $TEST_PCAP;
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "ALL OK: $cmdline"
echo "=========================================="
echo "TEST PASSED: $name"
echo "=========================================="
fi
trap "" EXIT
return 0;
}
testok() {
name=`basename $1`
failed=$2
if [ x"$failed" = x"0" ];then
:
else
echo "$failed TESTS FAILED or SKIPPED ($name)";
fi
exit $failed
}
teststatus() {
name=`basename $1`
failed=$2
echo "TEST STATUS: $failed failures";
test x"$failed" = x"0" || {
cat <<EOF
************************
*** TESTSUITE FAILED ***
************************
EOF
}
exit $failed
}
if [ -z "$VALGRIND" ]; then
MALLOC_CHECK_=2
export MALLOC_CHECK_
fi
# initialise the local failed variable to zero when starting each of the tests
failed=0
+99
View File
@@ -0,0 +1,99 @@
#!/bin/sh
# test some simple LDAP and CLDAP operations
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_ldap.sh SERVER USERNAME PASSWORD
EOF
exit 1;
fi
# see if we support ldaps
if grep HAVE_LIBGNUTLS.1 include/config.h > /dev/null &&
test -n "$CONFFILE" && grep tls.enabled.=yes $CONFFILE > /dev/null; then
PROTOCOLS="ldap ldaps"
else
PROTOCOLS="ldap"
fi
SERVER="$1"
USERNAME="$2"
PASSWORD="$3"
incdir=`dirname $0`
. $incdir/test_functions.sh
for p in $PROTOCOLS; do
for options in "" "--option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD --option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD"; do
echo "TESTING PROTOCOL $p with options $options"
testit "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
echo "Getting defaultNamingContext"
BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
echo "BASEDN is $BASEDN"
testit "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
testit "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
nentries=`bin/ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
echo "Found $nentries entries"
if [ $nentries -lt 10 ]; then
echo "Should have found at least 10 entries"
failed=`expr $failed + 1`
fi
echo "Check rootDSE for Controls"
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
if [ $nentries -lt 4 ]; then
echo "Should have found at least 4 entries"
failed=`expr $failed + 1`
fi
echo "Test Paged Results Control"
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
if [ $nentries -lt 1 ]; then
echo "Paged Results Control test returned 0 items"
failed=`expr $failed + 1`
fi
echo "Test Server Sort Control"
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
if [ $nentries -lt 1 ]; then
echo "Server Sort Control test returned 0 items"
failed=`expr $failed + 1`
fi
echo "Test Extended DN Control"
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
if [ $nentries -lt 1 ]; then
echo "Extended DN Control test returned 0 items"
failed=`expr $failed + 1`
fi
echo "Test Attribute Scope Query Control"
nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
if [ $nentries -lt 1 ]; then
echo "Attribute Scope Query test returned 0 items"
failed=`expr $failed + 1`
fi
done
done
testit "CLDAP" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ LDAP-CLDAP || failed=`expr $failed + 1`
# only do the ldb tests when not in quick mode - they are quite slow, and ldb
# is now pretty well tested by the rest of the quick tests anyway
test "$TORTURE_QUICK" = "yes" || {
LDBDIR=lib/ldb
export LDBDIR
testit "ldb tests" $LDBDIR/tests/test-tdb.sh || failed=`expr $failed + 1`
}
SCRIPTDIR=../testprogs/ejs
testit "ejs ldap test" $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD || failed=`expr $failed + 1`
testok $0 $failed
+39
View File
@@ -0,0 +1,39 @@
#!/bin/sh
local_tests="LOCAL-REPLACE LOCAL-TALLOC LOCAL-STRLIST"
local_tests="$local_tests LOCAL-IDTREE LOCAL-EVENT"
local_tests="$local_tests LOCAL-SOCKET LOCAL-MESSAGING LOCAL-IRPC"
local_tests="$local_tests LOCAL-NDR LOCAL-BINDING LOCAL-FILE LOCAL-REGISTRY"
local_tests="$local_tests LOCAL-SDDL LOCAL-PAC LOCAL-DBSPEED"
local_tests="$local_tests LOCAL-NTLMSSP LOCAL-CRYPTO-MD4"
local_tests="$local_tests LOCAL-CRYPTO-MD5 LOCAL-CRYPTO-HMACMD5"
local_tests="$local_tests LOCAL-CRYPTO-SHA1 LOCAL-CRYPTO-HMACSHA1"
local_tests="$local_tests LOCAL-RESOLVE LOCAL-TORTURE"
if [ `uname` = "Linux" ]; then
# testing against the system iconv only makes sense for our 'reference' iconv
# behaviour
local_tests="$local_tests LOCAL-ICONV"
fi
if [ $# -lt 0 ]; then
cat <<EOF
Usage: test_local.sh
EOF
exit 1;
fi
incdir=`dirname $0`
. $incdir/test_functions.sh
# the local tests doesn't need smbd
SMBD_TEST_FIFO=""
export SMBD_TEST_FIFO
failed=0
for t in $local_tests; do
name="$t"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*" || failed=`expr $failed + 1`
done
testok $0 $failed
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
# test some NBT/WINS operations
if [ $# -lt 1 ]; then
cat <<EOF
Usage: test_nbt.sh SERVER
EOF
exit 1;
fi
SERVER="$1"
incdir=`dirname $0`
. $incdir/test_functions.sh
SCRIPTDIR=../testprogs/ejs
PATH=bin:$PATH
export PATH
testit "nmblookup -U $SERVER $SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER $SERVER || failed=`expr $failed + 1`
testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER || failed=`expr $failed + 1`
NBT_TESTS="NBT-REGISTER NBT-WINS"
NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION"
# if [ "$TORTURE_QUICK"x != "yes"x ]; then
# NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED"
# fi
NBT_TESTS="$NBT_TESTS NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC"
for f in $NBT_TESTS; do
testit "$f" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ $f || failed=`expr $failed + 1`
done
testok $0 $failed
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
# add tests to this list as they start passing, so we test
# that they stay passing
ncacn_np_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-BIND NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
ncalrpc_tests="NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
ncacn_ip_tcp_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-LOOKUPPDC NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES NET-API-CREATEUSER NET-API-DELETEUSER"
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
for bindoptions in seal,padcheck $VALIDATE bigendian; do
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
case $transport in
ncalrpc) tests=$ncalrpc_tests ;;
ncacn_np) tests=$ncacn_np_tests ;;
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
done
done
done
testok $0 $failed
+20
View File
@@ -0,0 +1,20 @@
#!/bin/sh
if [ ! -n "$PERL" ]
then
PERL=perl
fi
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
if $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then
for f in pidl/tests/*.pl; do
testit "$f" $PERL $f || failed=`expr $failed + 1`
done
else
echo "Skipping pidl tests - Test::More not installed"
fi
testok $0 $failed
+77
View File
@@ -0,0 +1,77 @@
#!/bin/sh
# this runs the file serving tests that are expected to pass with the
# current posix ntvfs backend
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_posix.sh UNC USERNAME PASSWORD <first> <smbtorture args>
EOF
exit 1;
fi
unc="$1"
username="$2"
password="$3"
start="$4"
shift 4
ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
#
# please don't remove tests here, when you want them to be skipped!
# just add them to the skipped line below
# this should be the complete list smbtorture offers as BASE-* tests
#
base="BASE-ATTR BASE-CHARSET BASE-CHKPATH BASE-DEFER_OPEN BASE-DELAYWRITE BASE-DELETE"
base="$base BASE-DENY1 BASE-DENY2 BASE-DENY3 BASE-DENYDOS BASE-DIR1 BASE-DIR2"
base="$base BASE-DISCONNECT BASE-FDPASS BASE-LOCK "
base="$base BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1"
base="$base BASE-NTDENY2 BASE-OPEN BASE-OPENATTR BASE-PROPERTIES BASE-RENAME BASE-RW1"
base="$base BASE-SECLEAK BASE-TCON BASE-TCONDEV BASE-TRANS2 BASE-UNLINK BASE-VUID"
base="$base BASE-XCOPY"
#
# please don't remove tests here, when you want them to be skipped!
# just add them to the skipped line below
# this should be the complete list smbtorture offers as RAW-* tests
#
raw="RAW-CHKPATH RAW-CLOSE RAW-COMPOSITE RAW-CONTEXT RAW-EAS"
raw="$raw RAW-IOCTL RAW-LOCK RAW-MKDIR RAW-MUX RAW-NOTIFY RAW-OPEN RAW-OPLOCK"
raw="$raw RAW-QFILEINFO RAW-QFSINFO RAW-READ RAW-RENAME RAW-SEARCH RAW-SEEK"
raw="$raw RAW-SFILEINFO RAW-SFILEINFO-BUG RAW-STREAMS RAW-UNLINK RAW-WRITE"
smb2="SMB2-CONNECT SMB2-GETINFO SMB2-SETINFO SMB2-FIND"
tests="$base $raw $smb2"
#
# please add tests you want to be skipped here!
#
skipped="BASE-CHARSET BASE-DEFER_OPEN BASE-DELAYWRITE RAW-COMPOSITE RAW-OPLOCK RAW-ACLS"
echo "WARNING: Skipping tests $skipped"
failed=0
for t in $tests; do
if [ ! -z "$start" -a "$start" != $t ]; then
continue;
fi
skip=0
for s in $skipped; do
if [ x"$s" = x"$t" ]; then
skip=1;
break;
fi
done
if [ $skip = 1 ]; then
continue;
fi
start=""
name="$t"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
done
testok $0 $failed
+39
View File
@@ -0,0 +1,39 @@
#!/bin/sh
# run a quick set of filesystem tests
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_quick.sh UNC USERNAME PASSWORD <first> <smbtorture args>
EOF
exit 1;
fi
unc="$1"
username="$2"
password="$3"
start="$4"
shift 4
ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
tests="BASE-UNLINK BASE-ATTR BASE-DELETE"
tests="$tests BASE-TCON BASE-OPEN"
tests="$tests BASE-CHKPATH RAW-QFSINFO RAW-QFILEINFO RAW-SFILEINFO"
tests="$tests RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE"
tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME"
tests="$tests RAW-EAS RAW-STREAMS"
failed=0
for t in $tests; do
if [ ! -z "$start" -a "$start" != $t ]; then
continue;
fi
start=""
name="$t"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
done
testok $0 $failed
+58
View File
@@ -0,0 +1,58 @@
#!/bin/sh
# add tests to this list as they start passing, so we test
# that they stay passing
ncacn_np_tests="RPC-SPOOLSS RPC-SRVSVC RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
ncalrpc_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON"
slow_ncacn_np_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
slow_ncalrpc_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
slow_ncacn_ip_tcp_tests="RPC-SAMLOGON RPC-SAMR RPC-SAMR-USERS RPC-SAMR-PASSWORDS"
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_rpc.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
for bindoptions in seal,padcheck $VALIDATE bigendian; do
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
case $transport in
ncalrpc) tests=$ncalrpc_tests ;;
ncacn_np) tests=$ncacn_np_tests ;;
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
done
done
done
for bindoptions in connect $VALIDATE ; do
for transport in ncalrpc; do
case $transport in
ncalrpc) tests=$slow_ncalrpc_tests ;;
ncacn_np) tests=$slow_ncacn_np_tests ;;
ncacn_ip_tcp) tests=$slow_ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
done
done
done
testok $0 $failed
+40
View File
@@ -0,0 +1,40 @@
#!/bin/sh
# add tests to this list as they start passing, so we test
# that they stay passing
ncacn_np_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO RPC-SCHANNEL RPC-NETLOGON RPC-UNIXINFO"
ncacn_ip_tcp_tests="RPC-ALTERCONTEXT RPC-JOIN RPC-ECHO"
ncalrpc_tests="RPC-ECHO"
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_rpc_quick.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
for bindoptions in seal,padcheck $VALIDATE bigendian; do
for transport in ncalrpc ncacn_np ncacn_ip_tcp; do
case $transport in
ncalrpc) tests=$ncalrpc_tests ;;
ncacn_np) tests=$ncacn_np_tests ;;
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" || failed=`expr $failed + 1`
done
done
done
testok $0 $failed
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
PREFIX=$1
if [ -z "$PREFIX" ]
then
echo "Usage: test_s3upgrade.sh <prefix>"
exit 1
fi
mkdir -p $PREFIX
rm -f $PREFIX/*
$VALGRIND bin/smbscript ../testprogs/ejs/samba3sam
$VALGRIND bin/smbscript ../testdata/samba3/verify ../testdata/samba3
$VALGRIND bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
+54
View File
@@ -0,0 +1,54 @@
#!/bin/sh
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_session_key.sh SERVER USERNAME PASSWORD DOMAIN NETBIOSNAME
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
netbios_name="$5"
shift 5
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
transport="ncacn_np"
for bindoptions in bigendian seal; do
for keyexchange in "yes" "no"; do
for ntlm2 in "yes" "no"; do
for lm_key in "yes" "no"; do
for ntlmoptions in \
"-k no --option=usespnego=yes" \
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no" \
"-k no --option=usespnego=yes --option=ntlmssp_client:56bit=yes" \
"-k no --option=usespnego=yes --option=ntlmssp_client:56bit=no" \
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes" \
"-k no --option=usespnego=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=no" \
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes" \
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no" \
"-k no --option=usespnego=yes --option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:56bit=yes" \
"-k no --option=usespnego=no --option=clientntlmv2auth=yes" \
"-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes" \
"-k no --option=usespnego=no"; do
name="RPC-SECRETS on $transport with $bindoptions with NTLM2:$ntlm2 KEYEX:$keyexchange LM_KEY:$lm_key $ntlmoptions"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" --option=ntlmssp_client:keyexchange=$keyexchange --option=ntlmssp_client:ntlm2=$ntlm2 --option=ntlmssp_client:lm_key=$lm_key $ntlmoptions -U"$username"%"$password" -W $domain --option=gensec:target_hostname=$netbios_name RPC-SECRETS "$*" || failed=`expr $failed + 1`
done
done
done
done
name="RPC-SECRETS on $transport with $bindoptions with Kerberos"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
name="RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
done
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login, use target principal"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" || failed=`expr $failed + 1`
testok $0 $failed
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
# run a quick set of filesystem tests
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_simple.sh UNC USERNAME PASSWORD <first> <smbtorture args>
EOF
exit 1;
fi
unc="$1"
username="$2"
password="$3"
start="$4"
shift 4
ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
tests="BASE-RW1"
failed=0
for t in $tests; do
if [ ! -z "$start" -a "$start" != $t ]; then
continue;
fi
start=""
name="$t"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
done
testok $0 $failed
+90
View File
@@ -0,0 +1,90 @@
#!/bin/sh
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
runcmd() {
name="$1"
shift
testit "$name" $VALGRIND bin/smbclient $CONFIGURATION //$SERVER/tmp -W "$DOMAIN "-U"$USERNAME"%"$PASSWORD" $@
}
incdir=`dirname $0`
. $incdir/test_functions.sh
# Generate random file
cat >tmpfile<<EOF
foo
bar
bloe
blah
EOF
# put that file
echo mput tmpfile | runcmd "MPutting file" || failed=`expr $failed + 1`
# check file info
echo altname tmpfile | runcmd "Getting alternative name" || failed=`expr $failed + 1`
# run allinfo on that file
echo allinfo tmpfile | runcmd "Checking info on file" || failed=`expr $failed + 1`
# get that file
mv tmpfile tmpfile-old
echo mget tmpfile | runcmd "MGetting file" || failed=`expr $failed + 1`
# remove that file
echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
# compare locally
testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
# create directory
echo mkdir bla | runcmd "Creating directory" || failed=`expr $failed + 1`
# cd to directory
echo cd bla | runcmd "Changing directory" || failed=`expr $failed + 1`
# cd to top level directory
echo cd .. | runcmd "Going back" || failed=`expr $failed + 1`
# remove directory
echo rmdir bla | runcmd "Removing directory" || failed=`expr $failed + 1`
# enable recurse, create nested directory
echo "recurse; echo mkdir bla/bloe; exit" | runcmd "Creating nested directory" || failed=`expr $failed + 1`
# remove parent directory
echo rmdir bla/bloe | runcmd "Removing directory" || failed=`expr $failed + 1`
# remove child directory
echo rmdir bla | runcmd "Removing directory" || failed=`expr $failed + 1`
# run fsinfo
echo fsinfo objectid | runcmd "Getting file system info" || failed=`expr $failed + 1`
# put that file
echo put tmpfile | runcmd "Putting file" || failed=`expr $failed + 1`
# get that file
mv tmpfile tmpfile-old
echo get tmpfile | runcmd "Getting file" || failed=`expr $failed + 1`
# remove that file
echo rm tmpfile | runcmd "Removing file" || failed=`expr $failed + 1`
# compare locally
testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
# put that file
echo put tmpfile tmpfilex | runcmd "Putting file with different name" || failed=`expr $failed + 1`
# get that file
echo get tmpfilex | runcmd "Getting file again" || failed=`expr $failed + 1`
# compare locally
testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
# remove that file
echo rm tmpfilex | runcmd "Removing file" || failed=`expr $failed + 1`
# do some simple operations using old protocol versions
echo ls | runcmd "List directory with LANMAN1" -m LANMAN1 || failed=`expr $failed + 1`
echo ls | runcmd "List directory with LANMAN2" -m LANMAN2 || failed=`expr $failed + 1`
rm -f tmpfile tmpfile-old tmpfilex
testok $0 $failed
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
if [ $# -ne 0 ]; then
cat <<EOF
Usage: test_swig.sh
EOF
exit 1;
fi
incdir=`dirname $0`
. $incdir/test_functions.sh
failed=0
export PYTHONPATH=lib/tdb/swig:lib/ldb/swig:scripting/swig:$PYTHONPATH
export LD_LIBRARY_PATH=bin:$LD_LIBRARY_PATH
echo Testing tdb wrappers
scripting/swig/torture/torture_tdb.py || failed=`expr $failed + 1`
echo Testing ldb wrappers
scripting/swig/torture/torture_ldb.py || failed=`expr $failed + 1`
testok $0 $failed
+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh
# tests that should pass against a w2k3 DC, as administrator
# add tests to this list as they start passing, so we test
# that they stay passing
ncacn_np_tests="RPC-SCHANNEL RPC-DSSETUP RPC-EPMAPPER RPC-SAMR RPC-WKSSVC RPC-SRVSVC RPC-EVENTLOG RPC-NETLOGON RPC-LSA RPC-SAMLOGON RPC-SAMSYNC RPC-MULTIBIND RPC-WINREG"
ncacn_ip_tcp_tests="RPC-SCHANNEL RPC-EPMAPPER RPC-SAMR RPC-NETLOGON RPC-LSA RPC-SAMLOGON RPC-SAMSYNC RPC-MULTIBIND"
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_w2k3.sh SERVER USERNAME PASSWORD DOMAIN REALM
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
realm="$5"
shift 5
incdir=`dirname $0`
. $incdir/test_functions.sh
OPTIONS="-U$username%$password -W $domain --option realm=$realm"
failed=0
name="RPC-SPOOLSS on ncacn_np"
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server" $OPTIONS RPC-SPOOLSS "$*" || failed=`expr $failed + 1`
for bindoptions in padcheck connect sign seal ntlm,sign ntlm,seal $VALIDATE bigendian; do
for transport in ncacn_ip_tcp ncacn_np; do
case $transport in
ncacn_np) tests=$ncacn_np_tests ;;
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
name="$t on $transport with $bindoptions"
testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $OPTIONS $t "$*" || failed=`expr $failed + 1`
done
done
done
name="RPC-DRSUAPI on ncacn_ip_tcp with seal"
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal]" $OPTIONS RPC-DRSUAPI "$*" || failed=`expr $failed + 1`
name="RPC-DRSUAPI on ncacn_ip_tcp with seal,bigendian"
testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal,bigendian]" $OPTIONS RPC-DRSUAPI "$*" || failed=`expr $failed + 1`
testok $0 $failed
+52
View File
@@ -0,0 +1,52 @@
#!/bin/sh
# this runs the file serving tests that are expected to pass with win2003
if [ $# -lt 3 ]; then
cat <<EOF
Usage: test_w2k3_file.sh UNC USERNAME PASSWORD <first> <smbtorture args>
EOF
exit 1;
fi
unc="$1"
username="$2"
password="$3"
start="$4"
shift 4
ADDARGS="$*"
incdir=`dirname $0`
. $incdir/test_functions.sh
tests="BASE-FDPASS BASE-LOCK "
tests="$tests BASE-UNLINK BASE-ATTR"
tests="$tests BASE-DIR1 BASE-DIR2 BASE-VUID"
tests="$tests BASE-TCON BASE-TCONDEV BASE-RW1"
tests="$tests BASE-DENY3 BASE-XCOPY BASE-OPEN BASE-DENYDOS"
tests="$tests BASE-DELETE BASE-PROPERTIES BASE-MANGLE"
tests="$tests BASE-CHKPATH BASE-SECLEAK BASE-TRANS2"
tests="$tests BASE-NTDENY1 BASE-NTDENY2 BASE-RENAME BASE-OPENATTR"
tests="$tests RAW-QFILEINFO RAW-SFILEINFO-BUG RAW-SFILEINFO"
tests="$tests RAW-LOCK RAW-MKDIR RAW-SEEK RAW-CONTEXT RAW-MUX RAW-OPEN RAW-WRITE"
tests="$tests RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-CHKPATH RAW-RENAME"
tests="$tests RAW-EAS RAW-STREAMS RAW-OPLOCK RAW-NOTIFY BASE-DELAYWRITE"
# slowest tests last
tests="$tests BASE-DENY1 BASE-DENY2"
# these tests are known to fail against windows
fail="RAW-SEARCH RAW-ACLS RAW-QFSINFO"
echo "Skipping tests expected to fail: $fail"
failed=0
for t in $tests; do
if [ ! -z "$start" -a "$start" != $t ]; then
continue;
fi
start=""
name="$t"
testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t || failed=`expr $failed + 1`
done
testok $0 $failed
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
# A shell script to connect to a windows host over telnet,
# setup for a smbtorture test,
# run the test,
# and remove the previously configured directory and share.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
# Index variable to count the total number of tests which fail.
all_errs=0
export SMBTORTURE_REMOTE_HOST=`perl -I$WINTEST_DIR $WINTEST_DIR/vm_get_ip.pl`
if [ -z $SMBTORTURE_REMOTE_HOST ]; then
# Restore snapshot to ensure VM is in a known state, then exit.
restore_snapshot "Test failed to get the IP address of the windows host."
exit 1
fi
$WINTEST_DIR/wintest_base.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|| all_errs=`expr $all_errs + $?`
$WINTEST_DIR/wintest_raw.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|| all_errs=`expr $all_errs + $?`
$WINTEST_DIR/wintest_rpc.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|| all_errs=`expr $all_errs + $?`
$WINTEST_DIR/wintest_net.sh $SMBTORTURE_REMOTE_HOST $SMBTORTURE_USERNAME \
$SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP \
|| all_errs=`expr $all_errs + $?`
$WINTEST_DIR/wintest_client.sh || all_errs=`expr $all_errs + $?`
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
$SRCDIR/script/tests/test_ejs.sh $DOMAIN $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_ldap.sh $SERVER $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_nbt.sh $SERVER || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_quick.sh //$SERVER/cifs $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_rpc.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_session_key.sh $SERVER $USERNAME $PASSWORD $DOMAIN $NETBIOSNAME || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_binding_string.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_echo.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_posix.sh //$SERVER/tmp $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_local.sh || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_pidl.sh || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_smbclient.sh $SERVER $USERNAME $PASSWORD $DOMAIN $PREFIX || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_cifsdd.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_simple.sh //$SERVER/simple $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
$SRCDIR/script/tests/test_smbclient.sh $SERVER $USERNAME $PASSWORD $DOMAIN $PREFIX || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_cifsdd.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
$SRCDIR/script/tests/test_net.sh $SERVER $USERNAME $PASSWORD $DOMAIN || failed=`expr $failed + $?`
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes"
export TORTURE_OPTIONS
TORTURE_QUICK="yes"
export TORTURE_QUICK
$SRCDIR/script/tests/test_ejs.sh $DOMAIN $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_ldap.sh $SERVER $USERNAME $PASSWORD || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_nbt.sh $SERVER || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_quick.sh //$SERVER/cifs $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
$SRCDIR/script/tests/test_rpc_quick.sh $SERVER $USERNAME $PASSWORD $DOMAIN || totalfailed=`expr $totalfailed + $?`
#$SRCDIR/script/tests/test_cifsposix.sh //$SERVER/cifsposixtestshare $USERNAME $PASSWORD "" || totalfailed=`expr $totalfailed + $?`
+34
View File
@@ -0,0 +1,34 @@
#!/bin/sh
if [ `whoami` != "root" ]; then
echo "Windows tests will not run without root privilages."
exit 1
fi
if [ "$DO_SOCKET_WRAPPER" = SOCKET_WRAPPER ]; then
echo "Windows tests will not run with socket wrapper enabled."
exit 1
fi
if [ ! $WINTESTCONF ]; then
echo "Environment variable WINTESTCONF has not been defined."
echo "Windows tests will not run unconfigured."
exit 1
fi
if [ ! -r $WINTESTCONF ]; then
echo "$WINTESTCONF could not be read."
exit 1
fi
export WINTEST_DIR=$SRCDIR/script/tests/win
export TMPDIR=$TMPDIR
export NETBIOSNAME=$NETBIOSNAME
. $WINTESTCONF
$SRCDIR/script/tests/test_win.sh
status=$?
echo "$0 exits with status $status"
exit $status
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
xterm -e 'echo -e "Welcome to the Samba4 Test environment\n\
This matches the client environment used in make test\n\
smbd is pid `cat $PIDDIR/smbd.pid`\n\
\n\
Some useful environment variables:\n\
AUTH=$AUTH\n\
TORTURE_OPTIONS=$TORTURE_OPTIONS\n\
CONFIGURATION=$CONFIGURATION\n\
SERVER=$SERVER\n\
NETBIOSNAME=$NETBIOSNAME" && bash'
+121
View File
@@ -0,0 +1,121 @@
This framework uses a VMware Server hosted Windows guest VM to test the
behaviour of Windows -> Samba and Samba -> Windows interactions. To setup a
Windows host for testing, vm_setup.tar.gz contain some scripts which create
an administrative user account, and enable and start the installed telnet
service on the Windows host. Optionally, the hostname and workgroup name can
also be set. vm_setup.tar.gz is currently located in the SOC/bnh branch of
Samba's SVN repository.
PREREQUISITES
To use these scripts, VMware Server needs to be running with a Windows guest
VM installed, IP addressed, and VMware tools needs to be installed and running
on the guest VM. The Windows OS I used to test with was Windows Server 2003,
but I think this should work with any version of Windows that has the
Microsoft telnet service installed. The VMware Server versions I used for
testing was 1.0.0 build-27828, and 1.0.0 build-28343.
PLEASE NOTE: Due to problems with my original revert_snapshot() code, the initial
setup now requires that the VM configuration setting 'When Powering Off' is
manually set to 'Revert to snapshot' (snapshot.action="autoRevert" in the
guest's .vmx file). This should not be a permanent change, but the original
revert_snapshot() code I wrote no longer works and i'm not sure why.
On the machine that these scripts are running on (this need not be the same
machine as the VMware host), the VMware perl scripting api needs to be
installed, as well as the vix-perl api. These come with the VMware Server
console package.
After unzipping this file, the libraries are installed by extracting the
VMware-vix-e.x.p-<revision number>.tar.gz and
VMware-VmPerlAPI-e.x.p-<revision number>.tar.gz archives, and running the
vmware-install.pl scripts inside their respective directories.
On Slackware 10.2, I encountered a problem in that when I tried to use the vix
api libraries, I would get the following error:
SSLLoadSharedLibrary: Failed to load library /<client program directory>/libcrypto.so.0.9.7:/<client program directory>/libcrypto.so.0.9.7: cannot open a shared object file: No such file or directory.
The fix found on the VMware knowledge base (search http://kb.vmware.com for
Doc ID: 1837104) states that it's a known problem with the scripting libraries,
and can be resolved by installing VMware Server on the host, which properly
sets up the SSL module loader. This is what I would suggest if you encounter
this, as it solved the problem for me (I don't have VMware Server actually
running on that host though).
INSTALLATION
To use these scripts, modify initial_setup.conf to match your environment. The
GUEST_HOSTNAME, GUEST_WORKGROUP, HOST_SERVER_NAME, HOST_SERVER_PORT,
HOST_USERNAME, and HOST_PASSWORD variables are optional, and are commented out
in this release.
Running initial_setup.sh will:
* Get the IP address of the Windows guest VM.
* Take a snapshot of the pristine Windows guest.
* Copy the windows scripts from the windows-scripts directory on the unix host
to the directory on the Windows guest specified by the
GUEST_SCRIPT_PATH option. This path will be created on the guest if
it does not already exist.
* Execute win_setup.wsf on the Windows guest in order to create the
administrator account specified by GUEST_USERNAME and GUEST_PASSWORD,
enable and start the telnet service, and set the GUEST_HOSTNAME and
GUEST_WORKGROUP if configured.
* If these operations are successful so far, another snapshot is taken at this
point. This is the snapshot which is restored if the tests encounter
problems they are unable to recover from.
These operations leave the Windows guest in a state such that it can be
remotely administered with telnet. Specifically, this will allow us to use
'make wintest' in Samba 4 to perform smbtorture tests against a Windows host,
and perform tests from a Windows client to a Samba server.
INTEGRATING WITH THE BUILD FARM
Follow the standard steps to add a host to the build farm. The major
difference is that we will need to run these tests as root. To run the
Windows tests in the build farm, a .fns file will need to be created for
your new host that exports a WINTESTCONF environment variable pointing to a
config file used by 'make wintest'. An example of this config file can be
found at source/script/tests/win/test_win.conf in the Samba 4 source tree.
I've also included the bnhtest.fns file that I'm using for my build farm host
below, as an example. It was modified from generic.fns.
action_test_windows() {
do_make wintest
w_status=$?
echo "WINTEST STATUS: $w_status"
return $w_status;
}
per_run_hook
system=`uname`
export WINTESTCONF="/home/build/win/test_win.conf"
for compiler in gcc cc icc; do
# arrgh, "which" gives no err code on solaris
path=`which $compiler`
if [ -x "$path" ]; then
if $compiler -v 2>&1 | grep gcc.version > /dev/null; then
isgcc=1
CFLAGS="-Wall"
export CFLAGS
else
CFLAGS=""
export CFLAGS
isgcc=0
fi
if [ $compiler = gcc -o $isgcc = 0 ]; then
# only attempt samba4 if we have perl
if which perl > /dev/null; then
test_tree samba4 source $compiler configure build install test_windows test
fi
fi
fi
done
+359
View File
@@ -0,0 +1,359 @@
#!/usr/bin/perl -w
# A perl object to provide a simple, unified method of handling some
# VMware Server VM management functions using the perl and VIX API's.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
# VMware Perl API
use VMware::VmPerl;
use VMware::VmPerl::VM;
use VMware::VmPerl::ConnectParams;
# VMware C bindings
use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
# Create a class to abstract from the Vix and VMPerl APIs.
{ package VMHost;
my $perl_vm = VMware::VmPerl::VM::new();
my $perl_vm_credentials;
my $vix_vm;
my $vix_vm_host;
my $err_code = 0;
my $err_str = "";
my $hostname;
my $port;
my $username;
my $password;
my $vm_cfg_path;
my $guest_admin_username;
my $guest_admin_password;
sub error {
my $old_err_code = $err_code;
my $old_err_str = $err_str;
$err_code = 0;
$err_str = "";
return ($old_err_code, $old_err_str);
}
# Power on the guest if it isn't already running.
# Returns 0 when the guest is already running, and
# if not, it waits until it is started.
sub start_guest {
my $vm_power_state = $perl_vm->get_execution_state();
if (!defined($vm_power_state)) {
($err_code, $err_str) = $perl_vm->get_last_error();
return ($err_code);
}
if ($vm_power_state == VMware::VmPerl::VM_EXECUTION_STATE_OFF
|| $vm_power_state ==
VMware::VmPerl::VM_EXECUTION_STATE_SUSPENDED)
{
if (!$perl_vm->start()) {
($err_code, $err_str) =
$perl_vm->get_last_error();
return ($err_code);
}
while ($perl_vm->get_tools_last_active() == 0) {
sleep(60);
}
}
return ($err_code);
}
sub host_connect {
# When called as a method, the first parameter passed is the
# name of the method. Called locally, this function will lose
# the first parameter.
shift @_;
($hostname, $port, $username, $password, $vm_cfg_path,
$guest_admin_username, $guest_admin_password) = @_;
# Connect to host using vmperl api.
$perl_vm_credentials =
VMware::VmPerl::ConnectParams::new($hostname, $port,
$username, $password);
if (!$perl_vm->connect($perl_vm_credentials, $vm_cfg_path)) {
($err_code, $err_str) = $perl_vm->get_last_error();
undef $perl_vm;
return ($err_code);
}
# Connect to host using vix api.
($err_code, $vix_vm_host) =
VMware::Vix::Simple::HostConnect(
VMware::Vix::Simple::VIX_API_VERSION,
VMware::Vix::Simple::VIX_SERVICEPROVIDER_VMWARE_SERVER,
$hostname, $port, $username, $password,
0, VMware::Vix::Simple::VIX_INVALID_HANDLE);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str =
VMware::Vix::Simple::GetErrorText($err_code);
undef $perl_vm;
undef $vix_vm;
undef $vix_vm_host;
return ($err_code);
}
# Power on our guest os if it isn't already running.
$err_code = start_guest();
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Starting guest power after connect " .
"failed: " . $old_err_str;
undef $perl_vm;
undef $vix_vm;
undef $vix_vm_host;
return ($err_code);
}
# Open VM.
($err_code, $vix_vm) =
VMware::Vix::Simple::VMOpen($vix_vm_host, $vm_cfg_path);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str =
VMware::Vix::Simple::GetErrorText($err_code);
undef $perl_vm;
undef $vix_vm;
undef $vix_vm_host;
return ($err_code);
}
# Login to $vix_vm guest OS.
$err_code = VMware::Vix::Simple::VMLoginInGuest($vix_vm,
$guest_admin_username, $guest_admin_password,
0);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str =
VMware::Vix::Simple::GetErrorText($err_code);
undef $perl_vm;
undef $vix_vm;
undef $vix_vm_host;
return ($err_code);
}
return ($err_code);
}
sub host_disconnect {
undef $perl_vm;
$perl_vm = VMware::VmPerl::VM::new();
if (!$perl_vm) {
$err_code = 1;
$err_str = "Error creating new VmPerl object";
}
undef $vix_vm;
VMware::Vix::Simple::HostDisconnect($vix_vm_host);
VMware::Vix::Simple::ReleaseHandle($vix_vm_host);
return ($err_code);
}
sub host_reconnect {
$err_code = host_disconnect();
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Disconnecting from host failed: " .
$old_err_str;
return ($err_code);
}
$err_code = host_connect(NULL, $hostname, $port, $username,
$password, $vm_cfg_path, $guest_admin_username,
$guest_admin_password);
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Re-connecting to host failed: " .
$old_err_str;
return ($err_code);
}
return ($err_code);
}
sub create_snapshot {
my $snapshot;
($err_code, $snapshot) =
VMware::Vix::Simple::VMCreateSnapshot($vix_vm,
"Snapshot", "Created by vm_setup.pl", 0,
VMware::Vix::Simple::VIX_INVALID_HANDLE);
VMware::Vix::Simple::ReleaseHandle($snapshot);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str =
VMware::Vix::Simple::GetErrorText($err_code);
return $err_code;
}
$err_code = host_reconnect();
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Reconnecting to host after creating " .
"snapshot: " . $old_err_str;
return ($err_code);
}
return ($err_code);
}
sub revert_snapshot {
# Because of problems with VMRevertToSnapshot(), we have to
# rely on the guest having set 'Revert to Snapshot' following
# a power-off event.
$err_code = VMware::Vix::Simple::VMPowerOff($vix_vm, 0);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str =
VMware::Vix::Simple::GetErrorText($err_code);
return $err_code;
}
# host_reconnect() will power-on a guest in a non-running state.
$err_code = host_reconnect();
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Reconnecting to host after reverting " .
"snapshot: " . $old_err_str;
return ($err_code);
}
return ($err_code);
}
# $dest_path must exist. It doesn't get created.
sub copy_files_to_guest {
shift @_;
my (%files) = @_;
my $src_file;
my $dest_file;
foreach $src_file (keys(%files)) {
$dest_file = $files{$src_file};
$err_code =
VMware::Vix::Simple::VMCopyFileFromHostToGuest(
$vix_vm, $src_file, $dest_file, 0,
VMware::Vix::Simple::VIX_INVALID_HANDLE);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str = "Copying $src_file: " .
VMware::Vix::Simple::GetErrorText(
$err_code);
return $err_code;
}
}
return $err_code;
}
sub copy_to_guest {
# Read parameters $src_path, $dest_path.
shift @_;
my ($src_path, $dest_dir) = @_;
my $len = length($dest_dir);
my $idx = rindex($dest_dir, '\\');
if ($idx != ($len - 1)) {
$err_code = -1;
$err_str = "Destination $dest_dir must be a " .
"directory path";
return ($err_code);
}
# Create the directory $dest_path on the guest VM filesystem.
my $cmd = "cmd.exe ";
my $cmd_args = "/C MKDIR " . $dest_dir;
$err_code = run_on_guest(NULL, $cmd, $cmd_args);
if ( $err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Creating directory $dest_dir on host: " .
$old_err_str;
return ($err_code);
}
# If $src_filepath specifies a file, create it in $dest_path
# and keep the same name.
# If $src_path is a directory, create the files it contains in
# $dest_path, keeping the same names.
$len = length($src_path);
my %files;
$idx = rindex($src_path, '/');
if ($idx == ($len - 1)) {
# $src_path is a directory.
if (!opendir (DIR_HANDLE, $src_path)) {
$err_code = -1;
$err_str = "Error opening directory $src_path";
return $err_code;
}
foreach $file (readdir DIR_HANDLE) {
my $src_file = $src_path . $file;
if (!opendir(DIR_HANDLE2, $src_file)) {
# We aren't interested in subdirs.
my $dest_path = $dest_dir . $file;
$files{$src_file} = $dest_path;
} else {
closedir(DIR_HANDLE2);
}
}
} else {
# Strip if preceeding path from $src_path.
my $src_file = substr($src_path, ($idx + 1), $len);
my $dest_path = $dest_dir . $src_file;
# Add $src_path => $dest_path to %files.
$files{$src_path} = $dest_path;
}
$err_code = copy_files_to_guest(NULL, %files);
if ($err_code != 0) {
my $old_err_str = $err_str;
$err_str = "Copying files to host after " .
"populating %files: " . $old_err_str;
return ($err_code);
}
return ($err_code);
}
sub run_on_guest {
# Read parameters $cmd, $cmd_args.
shift @_;
my ($cmd, $cmd_args) = @_;
$err_code = VMware::Vix::Simple::VMRunProgramInGuest($vix_vm,
$cmd, $cmd_args, 0,
VMware::Vix::Simple::VIX_INVALID_HANDLE);
if ($err_code != VMware::Vix::Simple::VIX_OK) {
$err_str = VMware::Vix::Simple::GetErrorText(
$err_code);
return ($err_code);
}
return ($err_code);
}
sub get_guest_ip {
my $guest_ip = $perl_vm->get_guest_info('ip');
if (!defined($guest_ip)) {
($err_code, $err_str) = $perl_vm->get_last_error();
return NULL;
}
if (!($guest_ip)) {
$err_code = 1;
$err_str = "Guest did not set the 'ip' variable";
return NULL;
}
return $guest_ip;
}
sub DESTROY {
host_disconnect();
undef $perl_vm;
undef $vix_vm_host;
}
}
return TRUE;
+521
View File
@@ -0,0 +1,521 @@
# A library of commonly used functions written in expect.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
# This function maps a drive letter to a share point.
proc map_share { remote_prompt share_drive sharepoint username domain password } {
set default_err_str "Unknown error in function map_share"
set err_str $default_err_str
set cmd "net use $share_drive $sharepoint $password /USER:$username@$domain\r\n"
send $cmd
expect {
"The command completed successfully." {
expect_prompt $remote_prompt
set err_str "OK"
} \
"The local device name is already in use." {
expect_prompt $remote_prompt
set err_str "The device name $share_drive is already in use"
} \
"The network name cannot be found." {
expect_prompt $remote_prompt
set err_str "Sharepoint $sharepoint could not be found"
} \
timeout {
set err_str "Function map_share timed out while mapping $share_drive to $sharepoint"
}
}
return $err_str
}
# This function unmaps a drive letter from a share point.
proc unmap_share { remote_prompt share_drive } {
set default_err_str "Unknown error in function unmap_share"
set err_str $default_err_str
set cmd "net use $share_drive /DELETE\r\n"
send $cmd
expect {
"was deleted successfully." {
expect_prompt $remote_prompt
set err_str "OK"
} \
"NET HELPMSG 2250" {
expect_prompt $remote_prompt
set err_str "The network connection could not be found while unmapping $share_drive"
} \
timeout {
set err_str "Function unmap_share timed out while unmapping $share_drive"
}
}
return $err_str
}
# This function uses xcopy to copy a text file from one location on the
# remote windows host to another.
proc xcopy_file { remote_prompt in_filename out_filename xcopy_options } {
set default_err_str "Unknown error in function xcopy_file"
set err_str $default_err_str
set cmd "xcopy $in_filename $out_filename $xcopy_options\r\n"
send $cmd
expect {
"(F = file, D = directory)? " {
set cmd "F\r\n"
send $cmd
expect {
"1 File(s) copied\r\n\r\n" {
expect_prompt $remote_prompt
set err_str "OK"
} \
"0 File(s) copied\r\n\r\n" {
expect_prompt $remote_prompt
set err_str $default_err_str
} \
timeout {
set err_str "Function xcopy_file has timed out while copying $in_filename"
}
}
} \
"1 File(s) copied\r\n\r\n" {
expect_prompt $remote_prompt
set err_str "OK"
} \
"0 File(s) copied\r\n\r\n" {
expect_prompt $remote_prompt
set err_str $default_err_str
} \
timeout {
set err_str "Function xcopy_file timed out while copying $in_filename"
}
}
return $err_str
}
# This function creates a temporary file on the remote windows host.
# The file contents are populated by a recursive directory listing of
# the windows %HOMEDRIVE%.
proc create_tmp_file { remote_prompt filename } {
set default_err_str "Unknown error in function create_tmp_file"
set err_str $default_err_str
set cmd "dir %HOMEDRIVE%\\ /S > $filename\r\n"
send $cmd
expect {
$remote_prompt {
set err_str "OK"
} \
timeout {
set err_str "Function create_tmp_file timed out while creating $filename"
}
}
return $err_str
}
# This function compares two files on the remote windows host.
proc compare_files { remote_prompt file1 file2 } {
set default_err_str "Unknown error in function compare_files"
set err_str $default_err_str
set cmd "fc $file1 $file2\r\n"
send $cmd
expect {
"FC: no differences encountered\r\n\r\n\r\n" {
expect_prompt $remote_prompt
set err_str "OK"
} \
"\*\*\*\*\* $file1" {
expect_prompt $remote_prompt
set err_str "Files $file1 and $file2 differ"
} \
"\*\*\*\*\* $file2" {
expect_prompt $remote_prompt
set err_str "Files $file1 and $file2 differ"
} \
timeout {
set err_str "Function compare_files timed out while comparing files $file1 and $file2"
}
}
return $err_str
}
# This function deletes a file on the remote windows host.
proc delete_file { remote_prompt filename } {
set default_err_str "Unknown error in function delete_file"
set err_str $default_err_str
set cmd "del $filename\r\n"
send $cmd
expect {
"Could Not" {
expect_prompt $remote_prompt
set err_str $default_err_str
} \
$remote_prompt {
set err_str "OK"
} \
timeout {
set err_str "Function delete_file timed oout while deleting $filename"
}
}
return $err_str
}
# This function copies a text file over telnet from the local unix host
# to the remote windows host.
proc copy_file { remote_prompt in_filename out_filename } {
set default_err_str "Unknown error in function copy_file"
set err_str $default_err_str
# The octal ASCII code for Control-Z is 032.
set CTRLZ \032
# Open local file and read contents.
set in_file [open $in_filename r]
set in_data [read $in_file]
# Initiate copy on remote host.
set cmd "copy con $out_filename\r\n"
send $cmd
# Separate $in_data into lines and send to remote host.
set out_data [split $in_data "\n"]
foreach out_line $out_data {
send $out_line
# We might as well do a unix -> windows line conversion.
send "\r\n"
# Are we overwriting an existing file?
# If so, exit so we can handle it.
expect {
"(Yes/No/All)" {
send "NO\r\n"
expect_prompt $remote_prompt
set err_str "File exists"
} \
$out_line {
set err_str "OK"
} \
timeout {
set err_str "Function copy_file timed out while copying $in_filename"
}
}
if { $err_str != "OK" } {
return $err_str
} else {
set err_str $default_err_str
}
}
# ^Z\r to complete the transfer.
send $CTRLZ
send "\r"
expect {
"file(s) copied." {
set err_str [expect_prompt $remote_prompt]
} \
$remote_prompt {
set err_str $default_err_str
} \
timeout {
expect_prompt $remote_prompt
set err_str "Function copy_file timed out while finishing copy of $in_filename"
}
}
return $err_str
}
# This function waits for the command prompt and reports an error on
# timeout.
proc expect_prompt { remote_prompt } {
set default_err_str "Unknown error occurred while waiting for the command prompt"
set err_str $default_err_str
expect {
$remote_prompt {
set err_str "OK"
} \
timeout {
set err_str "Timeout occurred while waiting for the command prompt"
}
}
return $err_str
}
# This function will create a telnet login shell to $remote_host as $username.
# If expected dialogue is not recieved, return with a specific error if one
# is recognized. Otherwise return a generic error indicating the function
# name.
proc telnet_login { remote_prompt remote_host username password } {
set default_err_str "Unknown error in function telnet_login"
set err_str $default_err_str
set cmd "telnet $remote_host\r"
send $cmd
expect {
"login: " {
set err_str "OK"
} \
"Connection refused" {
set err_str "Connection refused"
} \
"No route to host" {
set err_str "No route to host"
} \
timeout {
set err_str "Function telnet_login timed out while waiting for the login prompt"
}
}
if { $err_str != "OK" } {
# Return because something unexpected happened.
return $err_str
} else {
# Reset err_str
set err_str $default_err_str
}
set cmd "$username\r"
send $cmd
expect {
"password: " {
set err_str "OK"
} \
timeout {
set err_str "Function telnet_login timed out while waiting for the password prompt"
}
}
if { $err_str != "OK" } {
return $err_str
} else {
set err_str $default_err_str
}
set cmd "$password\r"
send $cmd
expect {
$remote_prompt {
set err_str "OK"
} \
"Login Failed" {
set err_str "Telnet login failed"
} \
timeout {
set err_str "Function telnet_login timed out while waiting for the command prompt"
}
}
return $err_str
}
proc create_directory { remote_prompt sharepath } {
set default_err_str "Unknown error in function create_directory"
set err_str $default_err_str
set cmd "mkdir $sharepath\r\n"
send $cmd
expect {
"already exists" {
expect_prompt $remote_prompt
set err_str "Directory already exists"
} \
$remote_prompt {
set err_str "OK"
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached starting create_directory."
}
}
return $err_str
}
proc delete_directory { remote_prompt sharepath } {
set default_err_str "Unknown error in function delete_directory"
set err_str $default_err_str
set cmd "rmdir /S /Q $sharepath\r\n"
send $cmd
expect {
"Access is denied." {
expect_prompt $remote_prompt
set err_str "Directory access is denied"
} \
$remote_prompt {
set err_str "OK"
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached in delete_directory"
}
}
return $err_str
}
proc create_share { remote_prompt username sharepath sharename } {
set default_err_str "Unknown error in function create_share"
set err_str $default_err_str
set cmd "net share $sharename=$sharepath /GRANT:$username,FULL\r\n"
send $cmd
expect {
"was shared successfully." {
set err_str [expect_prompt $remote_prompt]
} \
"NET HELPMSG 2118." {
expect_prompt $remote_prompt
set err_str "The name has already been shared"
} \
$remote_prompt {
set err_str $default_err_str
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached in create_share"
}
}
return $err_str
}
proc delete_share { remote_prompt sharename } {
set default_err_str "Unknown error in function delete_share"
set err_str $default_err_str
set cmd "net share $sharename /DELETE\r\n"
send $cmd
expect {
"was deleted successfully." {
set err_str [expect_prompt $remote_prompt]
} \
"does not exist." {
expect_prompt $remote_prompt
set err_str "The share does not exist"
} \
$remote_prompt {
set err_str $default_err_str
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached in delete_share"
}
}
return $err_str
}
proc delete_hosts_entry { remote_prompt hosts_file_path backup_hosts_filename } {
set default_err_str "Unknown error in function delete_hosts_entry"
set err_str $default_err_str
set cmd "cd $hosts_file_path\r\n"
send $cmd
expect {
"." {
expect_prompt $remote_prompt
set err_str $default_err_str
} \
$remote_prompt {
set err_str "OK"
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached in delete_hosts_entry"
}
}
if { $err_str != "OK" } {
return $err_str
} else {
set err_str $default_err_str
}
set cmd "move /Y $backup_hosts_filename hosts\r\n"
send $cmd
expect {
"1 file(s) moved." {
set err_str [expect_prompt $remote_prompt]
} \
"cannot find the file specified." {
expect_prompt $remote_prompt
set err_str "File not found"
} \
$remote_prompt {
set err_str $default_err_str
} \
timeout {
expect_prompt $remote_prompt
set err_str "Function delete_hosts_entry timed out while renaming $backup_hosts_filename"
}
}
return $err_str
}
proc create_hosts_entry { remote_prompt hosts_file_path hostname ip \
backup_hosts_filename } {
set default_err_str "Unknown error in function create_hosts_entry"
set err_str $default_err_str
set cmd "cd $hosts_file_path\r\n"
send $cmd
expect {
"." {
expect_prompt $remote_prompt
set err_str $default_err_str
} \
$remote_prompt {
set err_str "OK"
} \
timeout {
expect_prompt $remote_prompt
set err_str "Timeout reached in create_hosts_entry"
}
}
if { $err_str != "OK" } {
return $err_str
} else {
set err_str $default_err_str
}
set cmd "copy /Y hosts $backup_hosts_filename\r\n"
send $cmd
expect {
"1 file(s) copied." {
set err_str [expect_prompt $remote_prompt]
} \
"cannot find the file specified." {
expect_prompt $remote_prompt
set err_str "File not found."
} \
$remote_prompt {
set err_str $default_err_str
} \
timeout {
expect_prompt $remote_prompt
set err_str "Function create_hosts_entry timed out while copying hosts file"
}
}
if { $err_str != "OK" } {
return $err_str
} else {
set err_str $default_err_str
}
set cmd "echo $ip $hostname #smbtorture host. >> hosts\r\n"
send $cmd
expect {
$remote_prompt {
set err_str "OK"
} \
timeout {
expect_prompt $remote_prompt
set err_str "Function create_hosts timed out while updating hosts file"
}
}
return $err_str
}
@@ -0,0 +1,64 @@
# perl needs to know to look in $WINTEST_DIR for VMHost.pm.
export PERLLIB=$WINTEST_DIR
# Command prompt that we are expecting on the windows host.
export SMBTORTURE_REMOTE_PROMPT=">"
# The username and password we will be testing with.
# This user will need admin rights on the remote windows host.
export SMBTORTURE_USERNAME="tortureuser"
export SMBTORTURE_PASSWORD="torturepass"
# The name of the workgroup we will be using on the remote windows host.
export SMBTORTURE_WORKGROUP="SMBTEST"
# The name of and path to the windows share we'll be testing against.
export SMBTORTURE_REMOTE_SHARE_NAME="smbtorture_share"
export SMBTORTURE_REMOTE_SHARE_PATH="%HOMEDRIVE%\smbtorture_shared_dir"
# Default timeout for the expect scripts to wait for a response from the remote.
export SMBTORTURE_EXPECT_TIMEOUT=30
# Path to the local smbtorture binary.
export SMBTORTURE_BIN_PATH="bin/smbtorture"
# Local system hostname and ip address we'll be adding to the remote's
# hosts file.
export SMBTORTURE_LOCAL_HOSTNAME=$NETBIOSNAME
export SMBTORTURE_LOCAL_IP="192.168.100.12"
# Filename of the windows hosts' unedited hosts file.
export REMOTE_BACKUP_HOSTS_FILENAME="hosts.smbtorture"
export REMOTE_HOSTS_FILE_PATH="%SYSTEMROOT%\\system32\\drivers\\etc"
# These coincide with the parameters mktestsetup.sh uses to setup smbd.
export SMBTORTURE_LOCAL_USERNAME="administrator"
export SMBTORTURE_LOCAL_PASSWORD="penguin"
export SMBTORTURE_LOCAL_DOMAIN="SAMBADOMAIN"
# This is the name of the samba share the windows vm will connect to.
export SMBTORTURE_LOCAL_SHARE_NAME="TMP"
# This is the drive letter which will be used to mount a share on the windows vm.
export SMBTORTURE_REMOTE_DRIVE_LETTER="X:"
# This is the name of the file which will be created on the windows vm
# and used for samba server tests.
export SMBTORTURE_TMP_FILENAME="smbtorture.tmp"
# The path to the vmware image config file local to the vmware server.
export VM_CFG_PATH="/var/lib/vmware/Virtual Machines/Win2k3-BuildFarm/Win2k3-BuildFarm.vmx"
# In order to copy files and execute programs on the guest vm,
# we need administrator-level credentials to log in with.
export GUEST_ADMIN_USERNAME="administrator"
export GUEST_ADMIN_PASSWORD="adminpass"
# These parameters are optional. If not specified, the script tries to access
# a local vmware server as the executing user.
# logged-in user running the script are used.
export HOST_SERVER_NAME="vmhost"
export HOST_SERVER_PORT=902
export HOST_USERNAME="vmuser"
export HOST_PASSWORD="vmpass"
@@ -0,0 +1,48 @@
#!/usr/bin/perl -w
# A perl script to connect to a VMware server and get the IP address of a VM.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
use VMHost;
sub check_error {
my $vm = VMHost;
my $custom_err_str = "";
($vm, $custom_err_str) = @_;
my ($err_code, $err_str) = $vm->error;
if ($err_code != 0) {
undef $vm;
die $custom_err_str . "Returned $err_code: $err_str.\n";
}
}
# Read in parameters from environment.
my $vm_cfg_path = $ENV{'VM_CFG_PATH'};
my $host_server_name = $ENV{'HOST_SERVER_NAME'};
my $host_server_port = $ENV{'HOST_SERVER_PORT'};
if (!defined($host_server_port)) {
$host_server_port = 902;
}
my $host_username = $ENV{'HOST_USERNAME'};
my $host_password = $ENV{'HOST_PASSWORD'};
my $guest_admin_username = $ENV{'GUEST_ADMIN_USERNAME'};
my $guest_admin_password = $ENV{'GUEST_ADMIN_PASSWORD'};
my $vm = VMHost;
$vm->host_connect($host_server_name, $host_server_port, $host_username,
$host_password, $vm_cfg_path, $guest_admin_username,
$guest_admin_password);
check_error($vm, "Error in \$vm->host_connect().\n");
my $guest_ip = $vm->get_guest_ip();
check_error($vm, "Error in \$vm->get_guest_ip().\n");
print $guest_ip;
undef $vm;
exit 0;
@@ -0,0 +1,46 @@
#!/usr/bin/perl -w
# A perl script to connect to a VMware server and revert a VM snapshot.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
use VMHost;
sub check_error {
my $vm = VMHost;
my $custom_err_str = "";
($vm, $custom_err_str) = @_;
my ($err_code, $err_str) = $vm->error;
if ($err_code != 0) {
undef $vm;
die $custom_err_str . "Returned $err_code: $err_str.\n";
}
}
# Read in parameters from environment.
my $vm_cfg_path = $ENV{'VM_CFG_PATH'};
my $host_server_name = $ENV{'HOST_SERVER_NAME'};
my $host_server_port = $ENV{'HOST_SERVER_PORT'};
if (!defined($host_server_port)) {
$host_server_port = 902;
}
my $host_username = $ENV{'HOST_USERNAME'};
my $host_password = $ENV{'HOST_PASSWORD'};
my $guest_admin_username = $ENV{'GUEST_ADMIN_USERNAME'};
my $guest_admin_password = $ENV{'GUEST_ADMIN_PASSWORD'};
my $vm = VMHost;
$vm->host_connect($host_server_name, $host_server_port, $host_username,
$host_password, $vm_cfg_path, $guest_admin_username,
$guest_admin_password);
check_error($vm, "Error in \$vm->host_connect().\n");
$vm->revert_snapshot();
check_error($vm, "Error in \$vm->revert_snapshot().\n");
undef $vm;
exit 0;
+59
View File
@@ -0,0 +1,59 @@
#!/bin/sh
. script/tests/test_functions.sh
. script/tests/win/wintest_functions.sh
# This variable is defined in the per-hosts .fns file.
. $WINTESTCONF
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
base_tests="BASE-UNLINK BASE-ATTR BASE-DELETE BASE-TCON BASE-OPEN BASE-CHKPATH"
all_errs=0
for t in $base_tests; do
test_name="$t / WINDOWS SERVER"
echo -e "\n$test_name SETUP PHASE"
setup_share_test
if [ $err_rtn -ne 0 ]; then
# If test setup fails, load VM snapshot and skip test.
restore_snapshot "\n$test_name setup failed, skipping test."
else
echo -e "\n$test_name setup completed successfully."
old_errs=$all_errs
testit "$test_name" $SMBTORTURE_BIN_PATH \
-U $username%$password \
-W $domain //$server/$SMBTORTURE_REMOTE_SHARE_NAME \
$t || all_errs=`expr $all_errs + 1`
if [ $old_errs -lt $all_errs ]; then
restore_snapshot "\n$test_name failed."
else
echo -e "\n$test_name CLEANUP PHASE"
remove_share_test
if [ $err_rtn -ne 0 ]; then
# If cleanup fails, restore VM snapshot.
restore_snapshot "\n$test_name removal failed."
else
echo -e "\n$test_name removal completed successfully."
fi
fi
fi
done
testok $0 $all_errs
@@ -0,0 +1,95 @@
# An expect script to create a temporary file, map a share, copy the file to the share,
# and compare the contents of the two files.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
proc run_test { remote_prompt tmp_filename share_drive host_drive buildhost_ip buildhost_share username domain password } {
# Create the temp file on the windows host and connect to the samba share.
set host_tmpfile "$host_drive\\$tmp_filename"
set err_str [create_tmp_file $remote_prompt $host_tmpfile]
if { $err_str != "OK" } {
return $err_str
}
set buildhost_sharepoint "\\\\$buildhost_ip\\$buildhost_share"
set err_str [map_share $remote_prompt $share_drive $buildhost_sharepoint $username $domain $password]
if { $err_str != "OK" } {
return $err_str
}
# Copy the temp file to the share and compare its contents with the original.
set share_tmpfile "$share_drive\\$tmp_filename"
set xcopy_options ""
set err_str [xcopy_file $remote_prompt $host_tmpfile $share_tmpfile $xcopy_options]
if { $err_str != "OK" } {
return $err_str
}
set err_str [compare_files $remote_prompt $host_tmpfile $share_tmpfile]
if { $err_str != "OK" } {
return $err_str
}
# Remove files and unmap share.
set err_str [delete_file $remote_prompt $share_tmpfile]
if { $err_str != "OK" } {
return $err_str
}
set err_str [delete_file $remote_prompt $host_tmpfile]
if { $err_str != "OK" } {
return $err_str
}
set err_str [unmap_share $remote_prompt $share_drive]
if {$err_str != "OK" } {
return $err_str
}
return $err_str
}
# Read parameters.
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
set remote_host $env(SMBTORTURE_REMOTE_HOST)
set username $env(SMBTORTURE_USERNAME)
set password $env(SMBTORTURE_PASSWORD)
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
set tmp_filename $env(SMBTORTURE_TMP_FILENAME)
set share_drive $env(SMBTORTURE_REMOTE_DRIVE_LETTER)
set host_drive "%HOMEDRIVE%"
set buildhost_ip $env(SMBTORTURE_LOCAL_IP)
set buildhost_share $env(SMBTORTURE_LOCAL_SHARE_NAME)
set buildhost_username $env(SMBTORTURE_LOCAL_USERNAME)
set buildhost_domain $env(SMBTORTURE_LOCAL_DOMAIN)
set buildhost_password $env(SMBTORTURE_LOCAL_PASSWORD)
set err_val [spawn $env(SHELL)]
if {$err_val == 0} {
puts stderr "Expect failed while spawning a shell process."
exit $err_val
}
set err_str [telnet_login $remote_prompt $remote_host $username $password]
if {$err_str != "OK"} {
puts stderr "\nFunction telnet_login failed during Samba server testing."
puts stderr "Error was: $err_str."
exit 1
}
set err_str [run_test $remote_prompt $tmp_filename $share_drive $host_drive $buildhost_ip $buildhost_share $buildhost_username $buildhost_domain $buildhost_password]
if {$err_str != "OK"} {
puts stderr "\nFunction run_test failed during Samba server testing."
puts stderr "Error was: $err_str."
# Log off from the telnet server.
send "exit\r\n"
exit 1
}
# Log off from the telnet server.
send "exit\r\n"
exit 0
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
. script/tests/test_functions.sh
. script/tests/win/wintest_functions.sh
# This variable is defined in the per-hosts .fns file.
. $WINTESTCONF
test_name="WINDOWS CLIENT / SAMBA SERVER SHARE"
cat $WINTEST_DIR/common.exp > $TMPDIR/client_test.exp
cat $WINTEST_DIR/wintest_client.exp >> $TMPDIR/client_test.exp
testit "$test_name" \
expect $TMPDIR/client_test.exp || all_errs=`expr $all_errs + 1`
if [ $all_errs > 0 ]; then
# Restore snapshot to ensure VM is in a known state.
restore_snapshot "\n$test_name failed."
echo "Snapshot restored."
fi
rm -f $TMPDIR/client_test.exp
testok $0 $all_errs
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
# Setup the windows environment.
# This was the best way I could figure out including library files
# for the moment.
# I was finding that "cat common.exp wintest_setup.exp | expect -f -"
# fails to run, but exits with 0 status something like 1% of the time.
setup_share_test()
{
echo -e "\nSetting up windows environment."
cat $WINTEST_DIR/common.exp > $TMPDIR/setup.exp
cat $WINTEST_DIR/wintest_setup.exp >> $TMPDIR/setup.exp
expect $TMPDIR/setup.exp
err_rtn=$?
rm -f $TMPDIR/setup.exp
}
# Clean up the windows environment after the test has run or failed.
remove_share_test()
{
echo -e "\nCleaning up windows environment."
cat $WINTEST_DIR/common.exp > $TMPDIR/remove.exp
cat $WINTEST_DIR/wintest_remove.exp >> $TMPDIR/remove.exp
expect $TMPDIR/remove.exp
err_rtn=$?
rm -f $TMPDIR/remove.exp
}
restore_snapshot()
{
echo -e $1
vmrun revertToSnapshot "$VM_CFG_PATH"
echo "Snapshot restored."
}
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
. script/tests/test_functions.sh
. script/tests/win/wintest_functions.sh
# This variable is defined in the per-hosts .fns file.
. $WINTESTCONF
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
ncacn_np_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-RPCCONN-BIND NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
#These tests fail on ncacn_np: NET-API-LOOKUPPDC NET-API-CREATEUSER NET-API-DELETEUSER
ncalrpc_tests="NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
#These tests fail on ncalrpc: NET-API-CREATEUSER NET-API-DELETEUSER
ncacn_ip_tcp_tests="NET-API-LOOKUP NET-API-LOOKUPHOST NET-API-RPCCONN-SRV NET-API-RPCCONN-DC NET-API-RPCCONN-DCINFO NET-API-LISTSHARES"
#These tests fail on ncacn_ip_tcp: NET-API-LOOKUPPDC NET-API-CREATEUSER NET-API-DELETEUSER
bind_options="seal,padcheck bigendian"
test_type="ncalrpc ncacn_np ncacn_ip_tcp"
all_errs=0
for o in $bind_options; do
for transport in $test_type; do
case $transport in
ncalrpc) net_test=$ncalrpc_tests ;;
ncacn_np) net_test=$ncacn_np_tests ;;
ncacn_ip_tcp) net_test=$ncacn_ip_tcp_tests ;;
esac
for t in $net_test; do
test_name="$t on $transport with $o"
old_errs=$all_errs
testit "$test_name" $SMBTORTURE_BIN_PATH \
-U $username%$password \
-W $domain \
$transport:$server[$o] \
$t || all_errs=`expr $all_errs + 1`
if [ $old_errs -lt $all_errs ]; then
restore_snapshot "\n$test_name failed."
fi
done
done
done
testok $0 $all_errs
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
. script/tests/test_functions.sh
. script/tests/win/wintest_functions.sh
# This variable is defined in the per-hosts .fns file.
. $WINTESTCONF
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_net.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
raw_tests="RAW-QFILEINFO RAW-SFILEINFO RAW-MKDIR RAW-SEEK RAW-OPEN RAW-WRITE RAW-UNLINK RAW-READ RAW-CLOSE RAW-IOCTL RAW-RENAME RAW-EAS RAW-STREAMS"
# This test fails: RAW-QFSINFO
all_errs=0
for t in $raw_tests; do
test_name="$t / WINDOWS SERVER"
echo -e "\n$test_name SETUP PHASE"
setup_share_test
if [ $err_rtn -ne 0 ]; then
# If test setup fails, load VM snapshot and skip test.
restore_snapshot "\n$test_name setup failed, skipping test."
else
echo -e "\n$test_name setup completed successfully."
old_errs=$all_errs
testit "$test_name" $SMBTORTURE_BIN_PATH \
-U $username%$password \
-W $domain //$server/$SMBTORTURE_REMOTE_SHARE_NAME \
$t || all_errs=`expr $all_errs + 1`
if [ $old_errs -lt $all_errs ]; then
restore_snapshot "\n$test_name failed."
else
echo -e "\n$test_name CLEANUP PHASE"
remove_share_test
if [ $err_rtn -ne 0 ]; then
# If cleanup fails, restore VM snapshot.
restore_snapshot "\n$test_name removal failed."
else
echo -e "\n$test_name removal completed successfully."
fi
fi
fi
done
testok $0 $all_errs
@@ -0,0 +1,71 @@
# An expect script to remove a directory and share which was
# previously setup for an smbtorture test.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
proc remove_test { remote_prompt sharepath sharename hosts_file_path \
backup_hosts_filename } {
set err_str [delete_share $remote_prompt $sharename]
if { $err_str != "OK" } {
puts stderr "Error in function delete_share: $err_str."
puts stderr "Function remove_test will continue."
}
set err_str [delete_directory $remote_prompt $sharepath]
if { $err_str != "OK" } {
puts stderr "Error in function delete_directory: $err_str."
puts stderr "Function remove_test will continue."
}
# Overwrite the current hosts file with the backup we made during setup.
set err_str [delete_hosts_entry $remote_prompt $hosts_file_path \
$backup_hosts_filename]
if { $err_str != "OK" } {
puts stderr "Error in function delete_hosts_entry: $err_str."
puts stderr "Function remove_test will continue."
}
return $err_str
}
# read parameters
set remote_host $env(SMBTORTURE_REMOTE_HOST)
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
set username $env(SMBTORTURE_USERNAME)
set password $env(SMBTORTURE_PASSWORD)
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
set sharepath $env(SMBTORTURE_REMOTE_SHARE_PATH)
set sharename $env(SMBTORTURE_REMOTE_SHARE_NAME)
set backup_hosts_filename $env(REMOTE_BACKUP_HOSTS_FILENAME)
set hosts_file_path $env(REMOTE_HOSTS_FILE_PATH)
set err_val [spawn $env(SHELL)]
if {$err_val == 0} {
puts stderr "Expect failed while spawning a shell process."
exit $err_val
}
set err_str [telnet_login $remote_prompt $remote_host $username $password]
if {$err_str != "OK"} {
puts stderr "\nFunction telnet_login failed during cleanup."
puts stderr "Error was: $err_str."
exit 1
}
set err_str [remove_test $remote_prompt $sharepath $sharename \
$hosts_file_path $backup_hosts_filename]
if {$err_str != "OK"} {
puts stderr "\nFunction remove_test failed."
puts stderr "Error was: $err_str."
# Log off from the telnet server.
send "exit\r\n"
exit 1
}
# Log off from the telnet server.
send "exit\r\n"
exit 0
+63
View File
@@ -0,0 +1,63 @@
#!/bin/sh
. script/tests/test_functions.sh
. script/tests/win/wintest_functions.sh
# This variable is defined in the per-hosts .fns file.
. $WINTESTCONF
if [ $# -lt 4 ]; then
cat <<EOF
Usage: test_rpc.sh SERVER USERNAME PASSWORD DOMAIN
EOF
exit 1;
fi
server="$1"
username="$2"
password="$3"
domain="$4"
shift 4
ncacn_np_tests="RPC-SRVSVC RPC-UNIXINFO RPC-ECHO RPC-DSSETUP RPC-ALTERCONTEXT RPC-MULTIBIND"
# These tests fail on ncacn_np: RPC-SPOOLSS RPC-SCHANNEL RPC-JOIN RPC-LSA
# RPC-NETLOGON
ncalrpc_tests="RPC-UNIXINFO RPC-ECHO"
# These tests fail on ncalrpc: RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP
# RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON
ncacn_ip_tcp_tests="RPC-UNIXINFO RPC-ECHO"
# These tests fail on ncacn_ip_tcp: RPC-SCHANNEL RPC-JOIN RPC-LSA RPC-DSSETUP
# RPC-ALTERCONTEXT RPC-MULTIBIND RPC-NETLOGON
bind_options="seal,padcheck bigendian"
test_type="ncalrpc ncacn_np ncacn_ip_tcp"
all_errs=0
for o in $bind_options; do
for transport in $test_type; do
case $transport in
ncalrpc) rpc_test=$ncalrpc_tests ;;
ncacn_np) rpc_test=$ncacn_np_tests ;;
ncacn_ip_tcp) rpc_test=$ncacn_ip_tcp_tests ;;
esac
for t in $rpc_test; do
test_name="$t on $transport with $o"
old_errs=$all_errs
testit "$test_name" $SMBTORTURE_BIN_PATH \
-U $username%$password \
-W $domain \
$transport:$server[$o] \
$t || all_errs=`expr $all_errs + 1`
if [ $old_errs -lt $all_errs ]; then
restore_snapshot "\n$test_name failed."
fi
done
done
done
testok $0 $all_errs
@@ -0,0 +1,104 @@
# An expect script to setup a directory and share for an smbtorture test.
# Copyright Brad Henry <brad@samba.org> 2006
# Released under the GNU GPL v2 or later.
proc setup_test { remote_prompt sharepath sharename username local_hostname \
local_ip hosts_file_path backup_hosts_filename } {
# If creating the directory fails, remove, then
# re-create the directory.
set err_str [create_directory $remote_prompt $sharepath]
if { $err_str != "OK" } {
if { $err_str != "Directory already exists" } {
puts stderr "\nUnexpected error occured in setup_test.\n"
puts stderr "Function create_directory returned $err_str."
} else {
puts stdout "\nDirectory $sharepath exists."
}
puts stdout "Re-creating directory $sharepath."
set err_str [delete_directory $remote_prompt $sharepath]
if { $err_str != "OK" } {
return $err_str
}
set err_str [create_directory $remote_prompt $sharepath]
if { $err_str != "OK" } {
return $err_str
}
}
# If creating the share fails, remove, then
# re-create the share.
set err_str [create_share $remote_prompt $username $sharepath \
$sharename]
if { $err_str != "OK" } {
if { $err_str != "The name has already been shared" } {
puts stderr "\nUnexpected error occured in setup_test."
puts stderr "Function create_share returned $err_str."
} else {
puts stdout "\nShare $sharename exists."
}
puts stdout "Re-creating share $sharename."
set err_str [delete_share $remote_prompt $sharename]
if { $err_str != "OK" } {
return $err_str
}
set err_str [create_share $remote_prompt $username $sharepath \
$sharename]
if { $err_str != "OK" } {
return $err_str
}
}
# Add a hosts file entry on the windows machine for the smbtorture host.
set err_str [create_hosts_entry $remote_prompt $hosts_file_path \
$local_hostname $local_ip $backup_hosts_filename]
return $err_str
}
# Read parameters.
set remote_host $env(SMBTORTURE_REMOTE_HOST)
set remote_prompt $env(SMBTORTURE_REMOTE_PROMPT)
set username $env(SMBTORTURE_USERNAME)
set password $env(SMBTORTURE_PASSWORD)
set timeout $env(SMBTORTURE_EXPECT_TIMEOUT)
set sharepath $env(SMBTORTURE_REMOTE_SHARE_PATH)
set sharename $env(SMBTORTURE_REMOTE_SHARE_NAME)
set local_hostname $env(SMBTORTURE_LOCAL_HOSTNAME)
set local_ip $env(SMBTORTURE_LOCAL_IP)
set backup_hosts_filename $env(REMOTE_BACKUP_HOSTS_FILENAME)
set hosts_file_path $env(REMOTE_HOSTS_FILE_PATH)
set err_val [spawn $env(SHELL)]
if {$err_val == 0} {
puts stderr "Expect failed while spawning a shell process."
exit $err_val
}
set err_str [telnet_login $remote_prompt $remote_host $username $password]
if {$err_str != "OK"} {
puts stderr "\nFunction telnet_login failed during setup."
puts stderr "Error was: $err_str."
exit 1
}
set err_str [setup_test $remote_prompt $sharepath $sharename $username \
$local_hostname $local_ip $hosts_file_path \
$backup_hosts_filename]
if {$err_str != "OK"} {
puts stderr "\nFunction setup_test failed during setup."
puts stderr "Error was: $err_str."
# Log off from the telnet server.
send "exit\r\n"
exit 1
}
# Log off from the telnet server.
send "exit\r\n"
exit 0