selftest Consolidate server wall clock time limits
[amitay/samba.git] / selftest / target / Samba.pm
1 #!/usr/bin/perl
2 # Bootstrap Samba and run a number of tests against it.
3 # Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later.
5
6 package Samba;
7
8 use strict;
9 use target::Samba3;
10 use target::Samba4;
11
12 sub new($$$$$) {
13         my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
14
15         my $self = {
16             samba3 => new Samba3($bindir,$binary_mapping, $bindir_path, $srcdir, $exeext, $server_maxtime),
17             samba4 => new Samba4($bindir,$binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime),
18         };
19         bless $self;
20         return $self;
21 }
22
23 sub setup_env($$$)
24 {
25         my ($self, $envname, $path) = @_;
26
27         $ENV{ENVNAME} = $envname;
28
29         my $env = $self->{samba4}->setup_env($envname, $path);
30         if (defined($env)) {
31             $env->{target} = $self->{samba4};
32         } else {
33                 $env = $self->{samba3}->setup_env($envname, $path);
34                 if (defined($env)) {
35                     $env->{target} = $self->{samba3};
36                 }
37         }
38         if (not defined $env) {
39                 warn("Samba can't provide environment '$envname'");
40                 return undef;
41         }
42         return $env;
43 }
44
45 1;