diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-15 12:27:30 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-04-16 11:43:04 +0200 |
commit | 831955ddf2d2d11b27318d8960d44c6ae9da624f (patch) | |
tree | e34bd6b0d8a6708d8b487a0ab7f2c3171b5e410e /selftest | |
parent | 82fdad8a4c1e45d171a75b133eff8f9768edd682 (diff) | |
download | samba-831955ddf2d2d11b27318d8960d44c6ae9da624f.tar.gz samba-831955ddf2d2d11b27318d8960d44c6ae9da624f.tar.xz 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')
-rwxr-xr-x | selftest/selftest.pl | 35 | ||||
-rw-r--r-- | selftest/selftesthelpers.py | 4 | ||||
-rw-r--r-- | selftest/target/Samba3.pm | 60 | ||||
-rw-r--r-- | selftest/target/Samba4.pm | 32 | ||||
-rwxr-xr-x | selftest/test_samba4.pl | 2 |
5 files changed, 71 insertions, 62 deletions
diff --git a/selftest/selftest.pl b/selftest/selftest.pl index fbb36a2d58..4d7186a6dc 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -156,7 +156,7 @@ my $opt_testenv = 0; my $opt_list = 0; my $ldap = undef; my $opt_resetup_env = undef; -my $opt_bindir = undef; +my $opt_binary_mapping = ""; my $opt_load_list = undef; my @testlists = (); @@ -314,7 +314,6 @@ Target Specific: --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that failed --socket-wrapper enable socket wrapper - --bindir=PATH path to target binaries Samba4 Specific: --ldap=openldap|fedora-ds back samba onto specified ldap server @@ -351,10 +350,10 @@ my $result = GetOptions ( 'list' => \$opt_list, 'ldap:s' => \$ldap, 'resetup-environment' => \$opt_resetup_env, - 'bindir:s' => \$opt_bindir, 'image=s' => \$opt_image, 'testlist=s' => \@testlists, 'load-list=s' => \$opt_load_list, + 'binary-mapping=s' => \$opt_binary_mapping ); exit(1) if (not $result); @@ -377,7 +376,7 @@ unless (defined($ENV{VALGRIND})) { # make all our python scripts unbuffered $ENV{PYTHONUNBUFFERED} = 1; -my $bindir = ($opt_bindir or "$builddir/bin"); +my $bindir = "$builddir/bin"; my $bindir_abs = abs_path($bindir); # Backwards compatibility: @@ -462,17 +461,41 @@ if ($opt_socket_wrapper) { my $target; my $testenv_default = "none"; +my %binary_mapping = {}; +if ($opt_binary_mapping) { + my @binmapping_list = split(/,/, $opt_binary_mapping); + foreach my $mapping (@binmapping_list) { + my ($bin, $map) = split(/\:/, $mapping); + $binary_mapping{$bin} = $map; + } +} + +$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; +} + if ($opt_target eq "samba4") { $testenv_default = "all"; require target::Samba4; - $target = new Samba4($bindir, $ldap, $srcdir, $exeext); + $target = new Samba4($bindir, \%binary_mapping, \&bindir_path, $ldap, $srcdir, $exeext); } 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, $srcdir_abs); + $target = new Samba3($bindir, \%binary_mapping, \&bindir_path, $srcdir_abs, $exeext); } elsif ($opt_target eq "win") { die("Windows tests will not run with socket wrapper enabled.") if ($opt_socket_wrapper); diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py index 781c8ccb9a..5b6c5a5349 100644 --- a/selftest/selftesthelpers.py +++ b/selftest/selftesthelpers.py @@ -22,10 +22,10 @@ import os import subprocess def srcdir(): - return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) + return os.path.normpath(os.getenv("SRCDIR", os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))) def source4dir(): - return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../source4")) + return os.path.normpath(os.path.join(srcdir(), "source4")) def bindir(): return os.path.normpath(os.path.join(os.getenv("BUILDDIR", "."), "bin")) 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}\""; diff --git a/selftest/test_samba4.pl b/selftest/test_samba4.pl index 416bf1d1db..5bf3913855 100755 --- a/selftest/test_samba4.pl +++ b/selftest/test_samba4.pl @@ -6,7 +6,7 @@ use lib $RealBin; use lib "$RealBin/target"; use Samba4; -my $s = new Samba4("bin", undef, $RealBin."/../setup"); +my $s = new Samba4("bin", undef, undef, undef, $RealBin."/../setup"); ok($s); |