mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
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
This commit is contained in:
parent
e04bab4a19
commit
2a9a9454e8
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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}\"";
|
||||
|
Loading…
Reference in New Issue
Block a user