summaryrefslogtreecommitdiff
path: root/source4/script
diff options
context:
space:
mode:
Diffstat (limited to 'source4/script')
-rw-r--r--source4/script/tests/README13
-rw-r--r--source4/script/tests/Samba4.pm45
-rw-r--r--source4/script/tests/TODO4
-rw-r--r--source4/script/tests/mktestmember.sh85
-rwxr-xr-xsource4/script/tests/test_member.sh10
5 files changed, 148 insertions, 9 deletions
diff --git a/source4/script/tests/README b/source4/script/tests/README
index bf7ff1842b..1eb7e7943c 100644
--- a/source4/script/tests/README
+++ b/source4/script/tests/README
@@ -1,4 +1,13 @@
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.
+bunch of tests all at once.
+The following environments are currently available:
+
+ - none: No server set up
+ - dc: Domain controller set up. The following environment variables will
+ be set:
+ * USERNAME
+ * PASSWORD
+ * DOMAIN
+ * REALM
+ * SERVER
diff --git a/source4/script/tests/Samba4.pm b/source4/script/tests/Samba4.pm
index 299bfb97e2..95eaf7f67e 100644
--- a/source4/script/tests/Samba4.pm
+++ b/source4/script/tests/Samba4.pm
@@ -11,7 +11,7 @@ use POSIX;
sub new($$$$) {
my ($classname, $bindir, $ldap, $setupdir) = @_;
- my $self = { ldap => $ldap, bindir => $bindir, setupdir => $setupdir };
+ my $self = { vars => {}, ldap => $ldap, bindir => $bindir, setupdir => $setupdir };
bless $self;
return $self;
}
@@ -135,7 +135,24 @@ sub wait_for_start($$)
system("bin/nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER} $testenv_vars->{NETBIOSNAME}");
}
-sub provision($$)
+sub provision_member($$$)
+{
+ my ($self, $prefix, $dcvars) = @_;
+ my %ret = ();
+ print "PROVISIONING...";
+ open(IN, "$RealBin/mktestmember.sh $prefix $dcvars->{DOMAIN} $dcvars->{USERNAME} $dcvars->{PASSWORD}|") or die("Unable to setup");
+ while (<IN>) {
+ die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/);
+ $ret{$1} = $2;
+ }
+ close(IN);
+
+ $ret{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo";
+ $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
+ return \%ret;
+}
+
+sub provision_dc($$)
{
my ($self, $prefix) = @_;
my %ret = ();
@@ -186,22 +203,42 @@ sub setup_env($$$)
if ($envname eq "dc") {
return $self->setup_dc("$path/dc");
+ } elsif ($envname eq "member") {
+ if (not defined($self->{vars}->{dc})) {
+ $self->setup_dc("$path/dc");
+ }
+ return $self->setup_member("$path/member", $self->{vars}->{dc});
} else {
- die("Samba4 can't provide environment $envname");
+ die("Samba4 can't provide environment '$envname'");
}
}
+sub setup_member($$$$)
+{
+ my ($self, $path, $dc_vars) = @_;
+
+ my $env = $self->provision_member($path, $dc_vars);
+
+ $self->check_or_start($env, ($ENV{SMBD_MAX_TIME} or 5400));
+
+ $self->wait_for_start($env);
+
+ return $env;
+}
+
sub setup_dc($$)
{
my ($self, $path) = @_;
- my $env = $self->provision($path);
+ my $env = $self->provision_dc($path);
$self->check_or_start($env,
($ENV{SMBD_MAX_TIME} or 5400));
$self->wait_for_start($env);
+ $self->{vars}->{dc} = $env;
+
return $env;
}
diff --git a/source4/script/tests/TODO b/source4/script/tests/TODO
index 4d327ce1ea..42f90188ed 100644
--- a/source4/script/tests/TODO
+++ b/source4/script/tests/TODO
@@ -1,5 +1,3 @@
- warn about unexpected successes
-- support for environments
- better way to detect that smbd has finished initialization
-- allow tests to specify what parameters they need
- - UNC / DCERPC binding strings
+- move ldap-specific code into mktestdc.sh
diff --git a/source4/script/tests/mktestmember.sh b/source4/script/tests/mktestmember.sh
new file mode 100644
index 0000000000..b2d35d7204
--- /dev/null
+++ b/source4/script/tests/mktestmember.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+if [ $# -lt 4 ]
+then
+ echo "$0 PREFIX DOMAIN USERNAME PASSWORD"
+ exit 1
+fi
+
+PREFIX=$1
+DOMAIN=$2
+DC_USERNAME=$3
+DC_PASSWORD=$4
+shift 4
+USERNAME=administrator
+PASSWORD=humbolt
+
+SRCDIR=`pwd`
+oldpwd=`dirname $0`/../..
+mkdir -p $PREFIX
+cd $PREFIX
+PREFIX_ABS=`pwd`
+ETCDIR=$PREFIX_ABS/etc
+NCALRPCDIR=$PREFIX_ABS/ncalrpc
+PIDDIR=$PREFIX_ABS/pid
+PRIVATEDIR=$PREFIX_ABS/private
+LOCKDIR=$PREFIX_ABS/lockdir
+WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket
+CONFFILE=$ETCDIR/smb.conf
+TMPDIR=$PREFIX_ABS/tmp
+NETBIOSNAME=localmember
+SMBD_LOGLEVEL=1
+
+mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR
+
+cat >$CONFFILE<<EOF
+[global]
+ netbios name = $NETBIOSNAME
+ workgroup = $DOMAIN
+ private dir = $PRIVATEDIR
+ pid directory = $PIDDIR
+ ncalrpc dir = $NCALRPCDIR
+ lock dir = $LOCKDIR
+ setup directory = $SRCDIR/setup
+ js include = $SRCDIR/scripting/libjs
+ winbindd socket directory = $WINBINDD_SOCKET_DIR
+ name resolve order = bcast
+ interfaces = 127.0.0.5/8
+ panic action = $SRCDIR/script/gdb_backtrace %PID% %PROG%
+ wins support = yes
+ server role = domain member
+ max xmit = 32K
+ server max protocol = SMB2
+ notify:inotify = false
+ ldb:nosync = true
+ 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
+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 >&2
+
+$srcdir/bin/net join member $DOMAIN -U$DC_USERNAME%$DC_PASSWORD >&2 || {
+ echo "Join failed"
+ exit $?
+}
+
+echo "PREFIX_ABS=$PREFIX_ABS"
+echo "PIDDIR=$PIDDIR"
+echo "SERVER=$SERVER"
+echo "NETBIOSNAME=$NETBIOSNAME"
+echo "DOMAIN=$DOMAIN"
+echo "USERNAME=$USERNAME"
+echo "REALM=$REALM"
+echo "PASSWORD=$PASSWORD"
+echo "SRCDIR=$SRCDIR"
+echo "PREFIX=$PREFIX"
+echo "CONFFILE=$CONFFILE"
+echo "WINBINDD_SOCKET_DIR=$WINBINDD_SOCKET_DIR"
+echo "NCALRPCDIR=$NCALRPCDIR"
+echo "CONFIGURATION=$CONFIGURATION"
diff --git a/source4/script/tests/test_member.sh b/source4/script/tests/test_member.sh
new file mode 100755
index 0000000000..798da60929
--- /dev/null
+++ b/source4/script/tests/test_member.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# add tests to this list as they start passing, so we test
+# that they stay passing
+ncacn_np_tests="RPC-ECHO"
+
+incdir=`dirname $0`
+. $incdir/test_functions.sh
+
+plantest "RPC-ECHO against member server" member $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncacn_np:"\$SERVER" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"