summaryrefslogtreecommitdiff
path: root/selftest/target
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-04-15 12:27:30 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-04-16 11:43:04 +0200
commit831955ddf2d2d11b27318d8960d44c6ae9da624f (patch)
treee34bd6b0d8a6708d8b487a0ab7f2c3171b5e410e /selftest/target
parent82fdad8a4c1e45d171a75b133eff8f9768edd682 (diff)
downloadsamba-831955ddf2d2d11b27318d8960d44c6ae9da624f.tar.gz
samba-831955ddf2d2d11b27318d8960d44c6ae9da624f.tar.bz2
samba-831955ddf2d2d11b27318d8960d44c6ae9da624f.zip
selftest: Provide a single bindir_path function across all targets
This will allow a mapping to be made between things like smbtorture4 -> smbtorture that is correct for the different build environments. Andrew Bartlett
Diffstat (limited to 'selftest/target')
-rw-r--r--selftest/target/Samba3.pm60
-rw-r--r--selftest/target/Samba4.pm32
2 files changed, 39 insertions, 53 deletions
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index d2082f5b91..75ede8739a 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -10,23 +10,15 @@ use Cwd qw(abs_path);
use FindBin qw($RealBin);
use POSIX;
-sub binpath($$)
-{
- my ($self, $binary) = @_;
-
- if (defined($self->{bindir})) {
- my $path = "$self->{bindir}/$binary";
- -f $path or die("File $path doesn't exist");
- return $path;
- }
-
- return $binary;
-}
-
sub new($$) {
- my ($classname, $bindir, $srcdir) = @_;
- my $self = { bindir => $bindir,
- srcdir => $srcdir
+ my ($classname, $bindir, $binary_mapping, $bindir_path, $srcdir, $exeext) = @_;
+ $exeext = "" unless defined($exeext);
+ my $self = { vars => {},
+ bindir => $bindir,
+ binary_mapping => $binary_mapping,
+ bindir_path => $bindir_path,
+ srcdir => $srcdir,
+ exeext => $exeext
};
bless $self;
return $self;
@@ -180,7 +172,7 @@ sub setup_member($$$)
$ret or return undef;
- my $net = $self->binpath("net");
+ my $net = $self->{bindir_path}->($self, "net");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "$net join $ret->{CONFIGURATION} $dcvars->{DOMAIN} member";
@@ -411,14 +403,14 @@ sub check_or_start($$$$$) {
@optargs = split(/ /, $ENV{NMBD_OPTIONS});
}
- $ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
+ $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "nmbd");
- my @preargs = ($self->binpath("timelimit"), $maxtime);
+ my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
if(defined($ENV{NMBD_VALGRIND})) {
@preargs = split(/ /, $ENV{NMBD_VALGRIND});
}
- exec(@preargs, $self->binpath("nmbd"), "-F", "--no-process-group", "-S", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start nmbd: $!");
+ exec(@preargs, $self->{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";
@@ -454,14 +446,14 @@ sub check_or_start($$$$$) {
@optargs = split(/ /, $ENV{WINBINDD_OPTIONS});
}
- $ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd");
+ $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "winbindd");
- my @preargs = ($self->binpath("timelimit"), $maxtime);
+ my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
if(defined($ENV{WINBINDD_VALGRIND})) {
@preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
}
- exec(@preargs, $self->binpath("winbindd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start winbindd: $!");
+ exec(@preargs, $self->{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";
@@ -492,16 +484,16 @@ sub check_or_start($$$$$) {
exit 0;
}
- $ENV{MAKE_TEST_BINARY} = $self->binpath("smbd");
+ $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "smbd");
my @optargs = ("-d0");
if (defined($ENV{SMBD_OPTIONS})) {
@optargs = split(/ /, $ENV{SMBD_OPTIONS});
}
- my @preargs = ($self->binpath("timelimit"), $maxtime);
+ my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
if(defined($ENV{SMBD_VALGRIND})) {
@preargs = split(/ /,$ENV{SMBD_VALGRIND});
}
- exec(@preargs, $self->binpath("smbd"), "-F", "--no-process-group", "-s", $env_vars->{SERVERCONFFILE}, @optargs) or die("Unable to start smbd: $!");
+ exec(@preargs, $self->{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";
@@ -824,7 +816,7 @@ domusers:X:$gid_domusers:
$ENV{NSS_WRAPPER_PASSWD} = $nss_wrapper_passwd;
$ENV{NSS_WRAPPER_GROUP} = $nss_wrapper_group;
- open(PWD, "|".$self->binpath("smbpasswd")." -c $conffile -L -s -a $unix_name >/dev/null");
+ open(PWD, "|".$self->{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");
@@ -871,11 +863,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->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
- system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} __SAMBA__");
- system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
- system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
- system($self->binpath("nmblookup") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
+ system($self->{bindir_path}->($self, "nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} __SAMBA__");
+ system($self->{bindir_path}->($self, "nmblookup") ." $envvars->{CONFIGURATION} __SAMBA__");
+ system($self->{bindir_path}->($self, "nmblookup") ." $envvars->{CONFIGURATION} -U 127.255.255.255 __SAMBA__");
+ system($self->{bindir_path}->($self, "nmblookup") ." $envvars->{CONFIGURATION} -U $envvars->{SERVER_IP} $envvars->{SERVER}");
+ system($self->{bindir_path}->($self, "nmblookup") ." $envvars->{CONFIGURATION} $envvars->{SERVER}");
# make sure smbd is also up set
print "wait for smbd\n";
@@ -883,7 +875,7 @@ sub wait_for_start($$)
my $count = 0;
my $ret;
do {
- $ret = system($self->binpath("smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
+ $ret = system($self->{bindir_path}->($self, "smbclient") ." $envvars->{CONFIGURATION} -L $envvars->{SERVER} -U% -p 139");
if ($ret != 0) {
sleep(2);
}
@@ -895,7 +887,7 @@ sub wait_for_start($$)
return 0;
}
# Ensure we have domain users mapped.
- $ret = system($self->binpath("net") ." $envvars->{CONFIGURATION} groupmap add rid=513 unixgroup=domusers type=domain");
+ $ret = system($self->{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 07dcf36206..6f7807473d 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -12,12 +12,15 @@ use POSIX;
use SocketWrapper;
sub new($$$$$) {
- my ($classname, $bindir, $ldap, $srcdir, $exeext) = @_;
+ my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext) = @_;
$exeext = "" unless defined($exeext);
+
my $self = {
vars => {},
ldap => $ldap,
bindir => $bindir,
+ binary_mapping => $binary_mapping,
+ bindir_path => $bindir_path,
srcdir => $srcdir,
exeext => $exeext
};
@@ -25,15 +28,6 @@ sub new($$$$$) {
return $self;
}
-sub bindir_path($$) {
- my ($self, $path) = @_;
-
- my $valpath = "$self->{bindir}/$path$self->{exeext}";
-
- return $valpath if (-f $valpath);
- return $path;
-}
-
sub scriptdir_path($$) {
my ($self, $path) = @_;
return "$self->{srcdir}/source4/scripting/$path";
@@ -46,7 +40,7 @@ sub slapd_start($$)
{
my $count = 0;
my ($self, $env_vars) = @_;
- my $ldbsearch = $self->bindir_path("ldbsearch");
+ my $ldbsearch = $self->bindir_path($self, "ldbsearch");
my $uri = $env_vars->{LDAP_URI};
@@ -138,7 +132,7 @@ sub check_or_start($$$)
if (defined($ENV{SAMBA_OPTIONS})) {
$optarg.= " $ENV{SAMBA_OPTIONS}";
}
- my $samba = $self->bindir_path("samba");
+ my $samba = $self->{bindir_path}->($self, "samba");
# allow selection of the process model using
# the environment varibale SAMBA_PROCESS_MODEL
@@ -186,7 +180,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("nmblookup");
+ my $nmblookup = $self->{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}");
@@ -207,7 +201,7 @@ sub write_ldb_file($$$)
{
my ($self, $file, $ldif) = @_;
- my $ldbadd = $self->bindir_path("ldbadd");
+ my $ldbadd = $self->{bindir_path}->($self, "ldbadd");
open(LDIF, "|$ldbadd -H $file >/dev/null");
print LDIF $ldif;
return(close(LDIF));
@@ -895,7 +889,7 @@ sub provision_member($$$)
return undef;
}
- my $samba_tool = $self->bindir_path("samba-tool");
+ my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -950,7 +944,7 @@ sub provision_rpc_proxy($$$)
return undef;
}
- my $samba_tool = $self->bindir_path("samba-tool");
+ my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1013,7 +1007,7 @@ sub provision_vampire_dc($$$)
return undef;
}
- my $samba_tool = $self->bindir_path("samba-tool");
+ my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1192,7 +1186,7 @@ sub provision_rodc($$$)
return undef;
}
- my $samba_tool = $self->bindir_path("samba-tool");
+ my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$ret->{SOCKET_WRAPPER_DEFAULT_IFACE}\" ";
$cmd .= "KRB5_CONFIG=\"$ret->{KRB5_CONFIG}\" ";
@@ -1498,7 +1492,7 @@ sub setup_vampire_dc($$$)
# force replicated DC to update repsTo/repsFrom
# for vampired partitions
- my $samba_tool = $self->bindir_path("samba-tool");
+ my $samba_tool = $self->{bindir_path}->($self, "samba-tool");
my $cmd = "";
$cmd .= "SOCKET_WRAPPER_DEFAULT_IFACE=\"$env->{SOCKET_WRAPPER_DEFAULT_IFACE}\"";
$cmd .= " KRB5_CONFIG=\"$env->{KRB5_CONFIG}\"";