summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-01-30 08:25:27 +0100
committerStefan Metzmacher <metze@samba.org>2009-01-30 09:36:53 +0100
commit52a49b448e4a9ccd3044b47a9efaf15f30fbd032 (patch)
tree92a8525252789111ab76d907ca1c25fdd5cb320c /selftest
parent4e0a61970120e10a6309251a97e660697818fa8a (diff)
downloadsamba-52a49b448e4a9ccd3044b47a9efaf15f30fbd032.tar.gz
samba-52a49b448e4a9ccd3044b47a9efaf15f30fbd032.tar.bz2
samba-52a49b448e4a9ccd3044b47a9efaf15f30fbd032.zip
selftest: allow environment options
We support "local" and "client" (default) now. We can decide if we want to run a client against the server (with a special client.conf) or if we want to run tests localy on the server with the same config as the server. metze
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/selftest.pl58
-rw-r--r--selftest/target/Samba4.pm11
2 files changed, 42 insertions, 27 deletions
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 97cf697179..7d40db5371 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -572,16 +572,6 @@ sub write_clientconf($$)
if (defined($vars->{REALM})) {
print CF "\trealm = $vars->{REALM}\n";
}
- if (defined($vars->{NCALRPCDIR})) {
- print CF "\tncalrpc dir = $vars->{NCALRPCDIR}\n";
- }
- if (defined($vars->{PIDDIR})) {
- print CF "\tpid directory = $vars->{PIDDIR}\n";
- }
- if (defined($vars->{WINBINDD_SOCKET_DIR})) {
- print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n";
- print CF "\twinbindd:socket dir = $vars->{WINBINDD_SOCKET_DIR}\n";
- }
if ($opt_socket_wrapper) {
print CF "\tinterfaces = $interfaces\n";
}
@@ -706,6 +696,17 @@ $| = 1;
my %running_envs = ();
+sub get_running_env($)
+{
+ my ($name) = @_;
+
+ my $envname = $name;
+
+ $envname =~ s/:.*//;
+
+ return $running_envs{$envname};
+}
+
my @exported_envvars = (
# domain stuff
"DOMAIN",
@@ -743,13 +744,22 @@ $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
sub setup_env($)
{
- my ($envname) = @_;
+ my ($name) = @_;
+
+ my $testenv_vars = undef;
+
+ my $envname = $name;
+ my $option = $name;
+
+ $envname =~ s/:.*//;
+ $option =~ s/^[^:]*://;
+
+ $option = "client" if $option eq "";
- my $testenv_vars;
if ($envname eq "none") {
- $testenv_vars = {};
- } elsif (defined($running_envs{$envname})) {
- $testenv_vars = $running_envs{$envname};
+ $testenv_vars = \{};
+ } elsif (defined(get_running_env($envname))) {
+ $testenv_vars = get_running_env($envname);
if (not $target->check_env($testenv_vars)) {
$testenv_vars = undef;
}
@@ -761,8 +771,16 @@ sub setup_env($)
$running_envs{$envname} = $testenv_vars;
- SocketWrapper::set_default_iface(6);
- write_clientconf($conffile, $testenv_vars);
+ if ($option eq "local") {
+ SocketWrapper::set_default_iface($testenv_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
+ $ENV{SMB_CONF_PATH} = $testenv_vars->{SERVERCONFFILE};
+ } elsif ($option eq "client") {
+ SocketWrapper::set_default_iface(6);
+ write_clientconf($conffile, $testenv_vars);
+ $ENV{SMB_CONF_PATH} = $conffile;
+ } else {
+ die("Unknown option[$option] for envname[$envname]");
+ }
foreach (@exported_envvars) {
if (defined($testenv_vars->{$_})) {
@@ -792,21 +810,21 @@ sub getlog_env($)
{
my ($envname) = @_;
return "" if ($envname eq "none");
- return $target->getlog_env($running_envs{$envname});
+ return $target->getlog_env(get_running_env($envname));
}
sub check_env($)
{
my ($envname) = @_;
return 1 if ($envname eq "none");
- return $target->check_env($running_envs{$envname});
+ return $target->check_env(get_running_env($envname));
}
sub teardown_env($)
{
my ($envname) = @_;
return if ($envname eq "none");
- $target->teardown_env($running_envs{$envname});
+ $target->teardown_env(get_running_env($envname));
delete $running_envs{$envname};
}
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 97f9878828..208824d6b2 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -751,10 +751,14 @@ nogroup:x:65534:nobody
WINBINDD_SOCKET_DIR => $winbindd_socket_dir,
NCALRPCDIR => $ncalrpcdir,
LOCKDIR => $lockdir,
+ SERVERCONFFILE => $conffile,
CONFIGURATION => $configuration,
SOCKET_WRAPPER_DEFAULT_IFACE => $swiface,
NSS_WRAPPER_PASSWD => $nsswrap_passwd,
NSS_WRAPPER_GROUP => $nsswrap_group,
+ SMBD_TEST_FIFO => "$prefix/smbd_test.fifo",
+ SMBD_TEST_LOG => "$prefix/smbd_test.log",
+ SMBD_TEST_LOG_POS => 0,
};
if (defined($self->{ldap})) {
@@ -812,10 +816,6 @@ sub provision_member($$$)
system($cmd) == 0 or die("Join failed\n$cmd");
- $ret->{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo";
- $ret->{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
- $ret->{SMBD_TEST_LOG_POS} = 0;
-
$ret->{DC_SERVER} = $dcvars->{SERVER};
$ret->{DC_SERVER_IP} = $dcvars->{SERVER_IP};
$ret->{DC_NETBIOSNAME} = $dcvars->{NETBIOSNAME};
@@ -841,9 +841,6 @@ sub provision_dc($$)
$self->add_wins_config("$prefix/private") or
die("Unable to add wins configuration");
- $ret->{SMBD_TEST_FIFO} = "$prefix/server_test.fifo";
- $ret->{SMBD_TEST_LOG} = "$prefix/server_test.log";
- $ret->{SMBD_TEST_LOG_POS} = 0;
return $ret;
}