summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2016-11-30 14:18:46 +1300
committerAndrew Bartlett <abartlet@samba.org>2016-12-01 05:54:21 +0100
commit07df896a34bc0f776fe98ac16fc5dac38e494d92 (patch)
tree67ce323ffa04c599241874ef044a006d1c1c3974 /selftest
parente952a127d676c308eab7b9dd356a36766749ac06 (diff)
downloadsamba-07df896a34bc0f776fe98ac16fc5dac38e494d92.tar.gz
selftest: Rework child process cleanup
We now: - call gdb_backtrace on the stuck pid to determine why it is stuck - cleanup faster as we catch the process exit (by not waiting until 1 second after the exit for waitpid() to return -1) Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/target/Samba4.pm46
1 files changed, 34 insertions, 12 deletions
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 40cca9451ec..caf46b26c86 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1879,7 +1879,7 @@ sub provision_chgdcpass($$)
return $ret;
}
-sub teardown_env($$)
+sub teardown_env_terminate($$)
{
my ($self, $envvars) = @_;
my $pid;
@@ -1892,28 +1892,50 @@ sub teardown_env($$)
my $childpid;
# This should give it time to write out the gcov data
+ until ($count > 15) {
+ if (Samba::cleanup_child($pid, "samba") != 0) {
+ return;
+ }
+ sleep(1);
+ $count++;
+ }
+
+ # After 15 Seconds, work out why this thing is still alive
+ warn "server process $pid took more than $count seconds to exit, showing backtrace:\n";
+ system("$self->{srcdir}/selftest/gdb_backtrace $pid");
+
until ($count > 30) {
- if (Samba::cleanup_child($pid, "samba") == -1) {
- last;
+ if (Samba::cleanup_child($pid, "samba") != 0) {
+ return;
}
sleep(1);
$count++;
}
- if ($count > 30 || kill(0, $pid)) {
+ if (kill(0, $pid)) {
+ warn "server process $pid took more than $count seconds to exit, sending SIGTERM\n";
kill "TERM", $pid;
+ }
- until ($count > 40) {
- if (Samba::cleanup_child($pid, "samba") == -1) {
- last;
- }
- sleep(1);
- $count++;
+ until ($count > 40) {
+ if (Samba::cleanup_child($pid, "samba") != 0) {
+ return;
}
- # If it is still around, kill it
- warn "server process $pid took more than $count seconds to exit, killing\n";
+ sleep(1);
+ $count++;
+ }
+ # If it is still around, kill it
+ if (kill(0, $pid)) {
+ warn "server process $pid took more than $count seconds to exit, killing\n with SIGKILL\n";
kill 9, $pid;
}
+ return;
+}
+
+sub teardown_env($$)
+{
+ my ($self, $envvars) = @_;
+ teardown_env_terminate($self, $envvars);
$self->slapd_stop($envvars) if ($self->{ldap});