selftest Consolidate server wall clock time limits
authorAndrew Bartlett <abartlet@samba.org>
Tue, 19 Apr 2011 03:50:40 +0000 (13:50 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 19 Apr 2011 07:03:07 +0000 (09:03 +0200)
This helps ensure that we don't have the Samba3 servers stop before
the full make test is finished.

Andrew Bartlett

Autobuild-User: Andrew Bartlett <abartlet@samba.org>
Autobuild-Date: Tue Apr 19 09:03:07 CEST 2011 on sn-devel-104

selftest/selftest.pl
selftest/target/Samba.pm
selftest/target/Samba3.pm
selftest/target/Samba4.pm

index aa22a57c796d89669e798d11fb9b53455b6c40b9..9f937f16556c82ec054f21f3ee33487154f69bb7 100755 (executable)
@@ -481,24 +481,33 @@ sub bindir_path($$) {
        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
+
+my $server_maxtime = 7500;
+if (defined($ENV{SMBD_MAXTIME}) and $ENV{SMBD_MAXTIME} ne "") {
+    $server_maxtime = $ENV{SMBD_MAXTIME};
+}
+
 if ($opt_target eq "samba") {
        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 = "all";
        require target::Samba;
-       $target = new Samba($bindir, \%binary_mapping, \&bindir_path, $ldap, $srcdir, $exeext);
+       $target = new Samba($bindir, \%binary_mapping, \&bindir_path, $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);
+       $target = new Samba4($bindir, \%binary_mapping, \&bindir_path, $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);
+       $target = new Samba3($bindir, \%binary_mapping, \&bindir_path, $srcdir_abs, $exeext, $server_maxtime);
 } elsif ($opt_target eq "win") {
        die("Windows tests will not run with socket wrapper enabled.") 
                if ($opt_socket_wrapper);
index 703d0b5e62635a2fda978ac0d75422811cdf070d..fc7e68dfde7c49942d13f719a2b30348ece7e3c6 100644 (file)
@@ -10,11 +10,11 @@ use target::Samba3;
 use target::Samba4;
 
 sub new($$$$$) {
-       my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext) = @_;
+       my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
 
        my $self = {
-           samba3 => new Samba3($bindir,$binary_mapping, $bindir_path, $srcdir, $exeext),
-           samba4 => new Samba4($bindir,$binary_mapping, $bindir_path, $ldap, $srcdir, $exeext),
+           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),
        };
        bless $self;
        return $self;
index eff61452a259c50c211eb4258c83dcf6f975bdfa..3c0dd0918a36ffd5630b8d45f9e8f2a4b4cfbdad 100644 (file)
@@ -11,14 +11,15 @@ use FindBin qw($RealBin);
 use POSIX;
 
 sub new($$) {
-       my ($classname, $bindir, $binary_mapping, $bindir_path, $srcdir, $exeext) = @_;
+       my ($classname, $bindir, $binary_mapping, $bindir_path, $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
+                    exeext => $exeext,
+                    server_maxtime => $server_maxtime
        };
        bless $self;
        return $self;
@@ -136,7 +137,6 @@ sub setup_s3dc($$)
        $vars or return undef;
 
        $self->check_or_start($vars,
-                             ($ENV{SMBD_MAXTIME} or 2700),
                               "yes", "yes", "yes");
 
        if (not $self->wait_for_start($vars)) {
@@ -180,9 +180,7 @@ sub setup_member($$$)
 
        system($cmd) == 0 or die("Join failed\n$cmd");
 
-       $self->check_or_start($ret,
-                             ($ENV{SMBD_MAXTIME} or 2700),
-                              "yes", "yes", "yes");
+       $self->check_or_start($ret, "yes", "yes", "yes");
 
        if (not $self->wait_for_start($ret)) {
               return undef;
@@ -216,9 +214,7 @@ sub setup_secshare($$)
 
        $vars or return undef;
 
-       $self->check_or_start($vars,
-                             ($ENV{SMBD_MAXTIME} or 2700),
-                              "yes", "no", "yes");
+       $self->check_or_start($vars, "yes", "no", "yes");
 
        if (not $self->wait_for_start($vars)) {
               return undef;
@@ -248,9 +244,7 @@ sub setup_secserver($$$)
 
        $ret or return undef;
 
-       $self->check_or_start($ret,
-                             ($ENV{SMBD_MAXTIME} or 2700),
-                              "yes", "no", "yes");
+       $self->check_or_start($ret, "yes", "no", "yes");
 
        if (not $self->wait_for_start($ret)) {
               return undef;
@@ -330,9 +324,7 @@ $ret->{USERNAME} = KTEST\\Administrator
        system("cp $self->{srcdir}/source3/selftest/ktest-krb5_ccache-3 $prefix/krb5_ccache-3");
        chmod 0600, "$prefix/krb5_ccache-3";
 
-       $self->check_or_start($ret,
-                             ($ENV{SMBD_MAXTIME} or 2700),
-                              "yes", "no", "yes");
+       $self->check_or_start($ret, "yes", "no", "yes");
 
        if (not $self->wait_for_start($ret)) {
               return undef;
@@ -369,8 +361,8 @@ sub read_pid($$)
        return $pid;
 }
 
-sub check_or_start($$$$$) {
-       my ($self, $env_vars, $maxtime, $nmbd, $winbindd, $smbd) = @_;
+sub check_or_start($$$$) {
+       my ($self, $env_vars, $nmbd, $winbindd, $smbd) = @_;
 
        unlink($env_vars->{NMBD_TEST_LOG});
        print "STARTING NMBD...";
@@ -394,7 +386,7 @@ sub check_or_start($$$$$) {
                                print("Skip nmbd received signal $signame");
                                exit 0;
                        };
-                       sleep($maxtime);
+                       sleep($self->{server_maxtime});
                        exit 0;
                }
 
@@ -405,7 +397,7 @@ sub check_or_start($$$$$) {
 
                $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "nmbd");
 
-               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
+               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
                if(defined($ENV{NMBD_VALGRIND})) { 
                        @preargs = split(/ /, $ENV{NMBD_VALGRIND});
                }
@@ -437,7 +429,7 @@ sub check_or_start($$$$$) {
                                print("Skip winbindd received signal $signame");
                                exit 0;
                        };
-                       sleep($maxtime);
+                       sleep($self->{server_maxtime});
                        exit 0;
                }
 
@@ -448,7 +440,7 @@ sub check_or_start($$$$$) {
 
                $ENV{MAKE_TEST_BINARY} = $self->{bindir_path}->($self, "winbindd");
 
-               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
+               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
                if(defined($ENV{WINBINDD_VALGRIND})) {
                        @preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
                }
@@ -480,7 +472,7 @@ sub check_or_start($$$$$) {
                                print("Skip smbd received signal $signame");
                                exit 0;
                        };
-                       sleep($maxtime);
+                       sleep($self->{server_maxtime});
                        exit 0;
                }
 
@@ -489,7 +481,7 @@ sub check_or_start($$$$$) {
                if (defined($ENV{SMBD_OPTIONS})) {
                        @optargs = split(/ /, $ENV{SMBD_OPTIONS});
                }
-               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $maxtime);
+               my @preargs = ($self->{bindir_path}->($self, "timelimit"), $self->{server_maxtime});
                if(defined($ENV{SMBD_VALGRIND})) {
                        @preargs = split(/ /,$ENV{SMBD_VALGRIND});
                }
index 602a134982ef1e7ee3e01fb89b510a3f4af83085..69d5c3bc68631487679ce8d8c6de42ca8f68577c 100644 (file)
@@ -12,7 +12,7 @@ use POSIX;
 use SocketWrapper;
 
 sub new($$$$$) {
-       my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext) = @_;
+       my ($classname, $bindir, $binary_mapping, $bindir_path, $ldap, $srcdir, $exeext, $server_maxtime) = @_;
        $exeext = "" unless defined($exeext);
 
        my $self = {
@@ -22,7 +22,8 @@ sub new($$$$$) {
                binary_mapping => $binary_mapping,
                bindir_path => $bindir_path,
                srcdir => $srcdir,
-               exeext => $exeext
+               exeext => $exeext,
+               server_maxtime => $server_maxtime
        };
        bless $self;
        return $self;
@@ -82,9 +83,9 @@ sub slapd_stop($$)
        return 1;
 }
 
-sub check_or_start($$$)
+sub check_or_start($$)
 {
-       my ($self, $env_vars, $max_time) = @_;
+       my ($self, $env_vars) = @_;
        return 0 if ( -p $env_vars->{SAMBA_TEST_FIFO});
 
        unlink($env_vars->{SAMBA_TEST_FIFO});
@@ -126,9 +127,7 @@ sub check_or_start($$$)
                }
 
                my $optarg = "";
-               if (defined($max_time)) {
-                       $optarg = "--maximum-runtime=$max_time ";
-               }
+               $optarg = "--maximum-runtime=$self->{server_maxtime}";
                if (defined($ENV{SAMBA_OPTIONS})) {
                        $optarg.= " $ENV{SAMBA_OPTIONS}";
                }
@@ -1363,7 +1362,7 @@ sub setup_member($$$)
        my $env = $self->provision_member($path, $dc_vars);
 
        if (defined $env) {
-               $self->check_or_start($env, ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1380,7 +1379,7 @@ sub setup_rpc_proxy($$$)
        my $env = $self->provision_rpc_proxy($path, $dc_vars);
 
        if (defined $env) {
-               $self->check_or_start($env, ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1395,8 +1394,7 @@ sub setup_dc($$)
 
        my $env = $self->provision_dc($path);
        if (defined $env) {
-               $self->check_or_start($env,
-                       ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1411,8 +1409,7 @@ sub setup_fl2000dc($$)
 
        my $env = $self->provision_fl2000dc($path);
        if (defined $env) {
-               $self->check_or_start($env,
-                       ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1429,8 +1426,7 @@ sub setup_fl2003dc($$)
        my $env = $self->provision_fl2003dc($path);
 
        if (defined $env) {
-               $self->check_or_start($env,
-                       ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1446,8 +1442,7 @@ sub setup_fl2008r2dc($$)
        my $env = $self->provision_fl2008r2dc($path);
 
        if (defined $env) {
-               $self->check_or_start($env,
-                       ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1464,8 +1459,7 @@ sub setup_vampire_dc($$$)
        my $env = $self->provision_vampire_dc($path, $dc_vars);
 
        if (defined $env) {
-               $self->check_or_start($env,
-                       ($ENV{SMBD_MAXTIME} or 7500));
+               $self->check_or_start($env);
 
                $self->wait_for_start($env);
 
@@ -1518,8 +1512,7 @@ sub setup_rodc($$$)
                return undef;
        }
 
-       $self->check_or_start($env,
-               ($ENV{SMBD_MAXTIME} or 7500));
+       $self->check_or_start($env);
 
        $self->wait_for_start($env);