summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-04-27 11:19:20 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-04-27 11:22:07 +1000
commit2a9a9454e8dc27e2da49bd513c1f8b3bad76bd25 (patch)
tree627f942d4f8cc0ee906c0e498f44724f5d1b3df7 /selftest
parente04bab4a19658009e53949b814a58d177966a9cd (diff)
downloadsamba-2a9a9454e8dc27e2da49bd513c1f8b3bad76bd25.tar.gz
samba-2a9a9454e8dc27e2da49bd513c1f8b3bad76bd25.tar.bz2
samba-2a9a9454e8dc27e2da49bd513c1f8b3bad76bd25.zip
selftest: Make bindir_path much less complex
There is no need to pass it as a function pointer, just put it in 'Samba.pm'. Andrew Bartlett
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/selftest.pl19
-rw-r--r--selftest/target/Samba.pm19
-rw-r--r--selftest/target/Samba3.pm42
-rw-r--r--selftest/target/Samba4.pm22
4 files changed, 51 insertions, 51 deletions
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 9f937f1655..c45ccb352e 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -468,19 +468,6 @@ if ($opt_binary_mapping) {
$ENV{BINARY_MAPPING} = $opt_binary_mapping;
-sub bindir_path($$) {
- my ($self, $path) = @_;
-
- if (defined($self->{binary_mapping}->{$path})) {
- $path = $self->{binary_mapping}->{$path};
- }
-
- my $valpath = "$self->{bindir}/$path$self->{exeext}";
-
- return $valpath if (-f $valpath);
- return $path;
-}
-
# After this many seconds, the server will self-terminate. All tests
# must terminate in this time, and testenv will only stay alive this
# long
@@ -496,18 +483,18 @@ if ($opt_target eq "samba") {
}
$testenv_default = "all";
require target::Samba;
- $target = new Samba($bindir, \%binary_mapping, \&bindir_path, $ldap, $srcdir, $exeext, $server_maxtime);
+ $target = new Samba($bindir, \%binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime);
} elsif ($opt_target eq "samba4") {
$testenv_default = "all";
require target::Samba4;
- $target = new Samba4($bindir, \%binary_mapping, \&bindir_path, $ldap, $srcdir, $exeext, $server_maxtime);
+ $target = new Samba4($bindir, \%binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime);
} elsif ($opt_target eq "samba3") {
if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....");
}
$testenv_default = "member";
require target::Samba3;
- $target = new Samba3($bindir, \%binary_mapping, \&bindir_path, $srcdir_abs, $exeext, $server_maxtime);
+ $target = new Samba3($bindir, \%binary_mapping, $srcdir_abs, $exeext, $server_maxtime);
} elsif ($opt_target eq "win") {
die("Windows tests will not run with socket wrapper enabled.")
if ($opt_socket_wrapper);
diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm
index fc7e68dfde..ec8ab2bec9 100644
--- a/selftest/target/Samba.pm
+++ b/selftest/target/Samba.pm
@@ -10,11 +10,11 @@ use target::Samba3;
use target::Samba4;
sub new($$$$$) {
- my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
+ my ($classname, $bindir, $binary_mapping,$ldap, $srcdir, $exeext, $server_maxtime) = @_;
my $self = {
- samba3 => new Samba3($bindir,$binary_mapping, $bindir_path, $srcdir, $exeext, $server_maxtime),
- samba4 => new Samba4($bindir,$binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime),
+ samba3 => new Samba3($bindir,$binary_mapping, $srcdir, $exeext, $server_maxtime),
+ samba4 => new Samba4($bindir,$binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime),
};
bless $self;
return $self;
@@ -42,4 +42,17 @@ sub setup_env($$$)
return $env;
}
+sub bindir_path($$) {
+ my ($object, $path) = @_;
+
+ if (defined($object->{binary_mapping}->{$path})) {
+ $path = $object->{binary_mapping}->{$path};
+ }
+
+ my $valpath = "$object->{bindir}/$path$object->{exeext}";
+
+ return $valpath if (-f $valpath);
+ return $path;
+}
+
1;
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index a829b09797..d9e62f40b0 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -9,14 +9,14 @@ use strict;
use Cwd qw(abs_path);
use FindBin qw($RealBin);
use POSIX;
+use target::Samba;
sub new($$) {
- my ($classname, $bindir, $binary_mapping, $bindir_path, $srcdir, $exeext, $server_maxtime) = @_;
+ my ($classname, $bindir, $binary_mapping, $srcdir, $exeext, $server_maxtime) = @_;
$exeext = "" unless defined($exeext);
my $self = { vars => {},
bindir => $bindir,
binary_mapping => $binary_mapping,
- bindir_path => $bindir_path,
srcdir => $srcdir,
exeext => $exeext,
server_maxtime => $server_maxtime
@@ -172,7 +172,7 @@ sub setup_member($$$)
$ret or return undef;
- my $net = $self->{bindir_path}->($self, "net");
+ my $net = Samba::bindir_path($self, "net");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "$net join $ret->{CONFIGURATION} $s3dcvars->{DOMAIN} member";
@@ -395,14 +395,14 @@ sub check_or_start($$$$) {
@optargs = split(/ /, $ENV{NMBD_OPTIONS});
}
- $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "nmbd");
+ $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "nmbd");
- my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
+ my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
if(defined($ENV{NMBD_VALGRIND})) {
@preargs = split(/ /, $ENV{NMBD_VALGRIND});
}
- exec(@preargs, $self->{bindir_path}->($self, "nmbd"), "-F", "--no-process-group", "-S", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
+ exec(@preargs, Samba::bindir_path($self, "nmbd"), "-F", "--no-process-group", "-S", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
}
write_pid($env_vars, "nmbd", $pid);
print "DONE\n";
@@ -438,14 +438,14 @@ sub check_or_start($$$$) {
@optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
}
- $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "winbindd");
+ $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "winbindd");
- my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
+ my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
if(defined($ENV{WINBINDD_VALGRIND})) {
@preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
}
- exec(@preargs, $self->{bindir_path}->($self, "winbindd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
+ exec(@preargs, Samba::bindir_path($self, "winbindd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
}
write_pid($env_vars, "winbindd", $pid);
print "DONE\n";
@@ -476,16 +476,16 @@ sub check_or_start($$$$) {
exit 0;
}
- $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "smbd");
+ $ENV{MAKE_TEST_BINARY} = Samba::bindir_path($self, "smbd");
my @optargs = ("-d0");
if (defined($ENV{SMBD_OPTIONS})) {
@optargs = split(/ /, $ENV{SMBD_OPTIONS});
}
- my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
+ my @preargs = (Samba::bindir_path($self, "timelimit"), $self->{server_maxtime});
if(defined($ENV{SMBD_VALGRIND})) {
@preargs = split(/ /,$ENV{SMBD_VALGRIND});
}
- exec(@preargs, $self->{bindir_path}->($self, "smbd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
+ exec(@preargs, Samba::bindir_path($self, "smbd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
}
write_pid($env_vars, "smbd", $pid);
print "DONE\n";
@@ -812,7 +812,7 @@ domusers:X:$gid_domusers:
$ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
$ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
- open(PWD, "|".$self->{bindir_path}->($self, "smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null");
+ open(PWD, "|".Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null");
print PWD "$password\n$password\n";
close(PWD) or die("Unable to set password for test account");
@@ -847,7 +847,7 @@ domusers:X:$gid_domusers:
$ret{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
$ret{NSS_WRAPPER_WINBIND_SO_PATH} = $ENV{NSS_WRAPPER_WINBIND_SO_PATH};
if (not defined($ret{NSS_WRAPPER_WINBIND_SO_PATH})) {
- $ret{NSS_WRAPPER_WINBIND_SO_PATH} = $self->{bindir_path}->($self, "default/nsswitch/libnss-winbind.so");
+ $ret{NSS_WRAPPER_WINBIND_SO_PATH} = Samba::bindir_path($self, "default/nsswitch/libnss-winbind.so");
}
$ret{LOCAL_PATH} = "$shrdir";
@@ -862,11 +862,11 @@ sub wait_for_start($$)
print "delaying for nbt name registration\n";
sleep(10);
# This will return quickly when things are up, but be slow if we need to wait for (eg) SSL init
- system($self->{bindir_path}->($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
- system($self->{bindir_path}->($self, "nmblookup3") ." $envvars->{CONFIGURATION} __SAMBA__");
- system($self->{bindir_path}->($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
- system($self->{bindir_path}->($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
- system($self->{bindir_path}->($self, "nmblookup3") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
+ system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
+ system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} __SAMBA__");
+ system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
+ system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
+ system(Samba::bindir_path($self, "nmblookup3") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
# make sure smbd is also up set
print "wait for smbd\n";
@@ -874,7 +874,7 @@ sub wait_for_start($$)
my $count = 0;
my $ret;
do {
- $ret = system($self->{bindir_path}->($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
+ $ret = system(Samba::bindir_path($self, "smbclient3") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
if ($ret != 0) {
sleep(2);
}
@@ -886,7 +886,7 @@ sub wait_for_start($$)
return 0;
}
# Ensure we have domain users mapped.
- $ret = system($self->{bindir_path}->($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
+ $ret = system(Samba::bindir_path($self, "net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
if ($ret != 0) {
return 1;
}
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 69d5c3bc68..22f38b859f 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -10,9 +10,10 @@ use Cwd qw(abs_path);
use FindBin qw($RealBin);
use POSIX;
use SocketWrapper;
+use target::Samba;
sub new($$$$$) {
- my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
+ my ($classname, $bindir, $binary_mapping, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
$exeext = "" unless defined($exeext);
my $self = {
@@ -20,7 +21,6 @@ sub new($$$$$) {
ldap => $ldap,
bindir => $bindir,
binary_mapping => $binary_mapping,
- bindir_path => $bindir_path,
srcdir => $srcdir,
exeext => $exeext,
server_maxtime => $server_maxtime
@@ -41,7 +41,7 @@ sub slapd_start($$)
{
my $count = 0;
my ($self, $env_vars) = @_;
- my $ldbsearch = $self->bindir_path($self, "ldbsearch");
+ my $ldbsearch = Samba::bindir_path($self, "ldbsearch");
my $uri = $env_vars->{LDAP_URI};
@@ -131,7 +131,7 @@ sub check_or_start($$)
if (defined($ENV{SAMBA_OPTIONS})) {
$optarg.= " $ENV{SAMBA_OPTIONS}";
}
- my $samba = $self->{bindir_path}->($self, "samba");
+ my $samba = Samba::bindir_path($self, "samba");
# allow selection of the process model using
# the environment varibale SAMBA_PROCESS_MODEL
@@ -179,7 +179,7 @@ sub wait_for_start($$)
# This will return quickly when things are up, but be slow if we
# need to wait for (eg) SSL init
- my $nmblookup = $self->{bindir_path}->($self, "nmblookup");
+ my $nmblookup = Samba::bindir_path($self, "nmblookup");
system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{SERVER}");
system("$nmblookup $testenv_vars->{CONFIGURATION} -U $testenv_vars->{SERVER_IP} $testenv_vars->{SERVER}");
system("$nmblookup $testenv_vars->{CONFIGURATION} $testenv_vars->{NETBIOSNAME}");
@@ -200,7 +200,7 @@ sub write_ldb_file($$$)
{
my ($self, $file, $ldif) = @_;
- my $ldbadd = $self->{bindir_path}->($self, "ldbadd");
+ my $ldbadd = Samba::bindir_path($self, "ldbadd");
open(LDIF, "|$ldbadd -H $file >/dev/null");
print LDIF $ldif;
return(close(LDIF));
@@ -889,7 +889,7 @@ sub provision_member($$$)
return undef;
}
- my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -941,7 +941,7 @@ sub provision_rpc_proxy($$$)
return undef;
}
- my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1001,7 +1001,7 @@ sub provision_vampire_dc($$$)
return undef;
}
- my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1173,7 +1173,7 @@ sub provision_rodc($$$)
return undef;
}
- my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1467,7 +1467,7 @@ sub setup_vampire_dc($$$)
# force replicated DC to update repsTo/repsFrom
# for vampired partitions
- my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
+ my $samba_tool = Samba::bindir_path($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
$cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";