Commit 691de48d authored by Bjorn Munch's avatar Bjorn Munch

merge 51767

parents 690ab227 bd20de01
...@@ -60,11 +60,12 @@ use My::Platform; ...@@ -60,11 +60,12 @@ use My::Platform;
my %running; my %running;
my $_verbose= 0; my $_verbose= 0;
my $start_exit= 0;
END { END {
# Kill any children still running # Kill any children still running
for my $proc (values %running){ for my $proc (values %running){
if ( $proc->is_child($$) ){ if ( $proc->is_child($$) and ! $start_exit){
#print "Killing: $proc\n"; #print "Killing: $proc\n";
if ($proc->wait_one(0)){ if ($proc->wait_one(0)){
$proc->kill(); $proc->kill();
...@@ -161,6 +162,11 @@ sub new { ...@@ -161,6 +162,11 @@ sub new {
push(@safe_args, "--"); push(@safe_args, "--");
push(@safe_args, $path); # The program safe_process should execute push(@safe_args, $path); # The program safe_process should execute
if ($start_exit) { # Bypass safe_process instead, start program directly
@safe_args= ();
$safe_path= $path;
}
push(@safe_args, @$$args); push(@safe_args, @$$args);
print "### safe_path: ", $safe_path, " ", join(" ", @safe_args), "\n" print "### safe_path: ", $safe_path, " ", join(" ", @safe_args), "\n"
...@@ -540,6 +546,13 @@ sub wait_all { ...@@ -540,6 +546,13 @@ sub wait_all {
} }
} }
#
# Set global flag to tell all safe_process to exit after starting child
#
sub start_exit {
$start_exit= 1;
}
# #
# Check if any process has exited, but don't wait. # Check if any process has exited, but don't wait.
......
...@@ -236,6 +236,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; }; ...@@ -236,6 +236,7 @@ sub check_timeout { return $opt_testcase_timeout * 6; };
my $opt_start; my $opt_start;
my $opt_start_dirty; my $opt_start_dirty;
my $opt_start_exit;
my $start_only; my $start_only;
my $opt_wait_all; my $opt_wait_all;
my $opt_repeat= 1; my $opt_repeat= 1;
...@@ -363,6 +364,12 @@ sub main { ...@@ -363,6 +364,12 @@ sub main {
mtr_report("Using parallel: $opt_parallel"); mtr_report("Using parallel: $opt_parallel");
} }
if ($opt_parallel > 1 && $opt_start_exit) {
mtr_warning("Parallel and --start-and-exit cannot be combined\n" .
"Setting parallel to 1");
$opt_parallel= 1;
}
# Create server socket on any free port # Create server socket on any free port
my $server = new IO::Socket::INET my $server = new IO::Socket::INET
( (
...@@ -402,6 +409,8 @@ sub main { ...@@ -402,6 +409,8 @@ sub main {
my $completed= run_test_server($server, $tests, $opt_parallel); my $completed= run_test_server($server, $tests, $opt_parallel);
exit(0) if $opt_start_exit;
# Send Ctrl-C to any children still running # Send Ctrl-C to any children still running
kill("INT", keys(%children)); kill("INT", keys(%children));
...@@ -928,6 +937,7 @@ sub command_line_setup { ...@@ -928,6 +937,7 @@ sub command_line_setup {
'verbose-restart' => \&report_option, 'verbose-restart' => \&report_option,
'sleep=i' => \$opt_sleep, 'sleep=i' => \$opt_sleep,
'start-dirty' => \$opt_start_dirty, 'start-dirty' => \$opt_start_dirty,
'start-and-exit' => \$opt_start_exit,
'start' => \$opt_start, 'start' => \$opt_start,
'wait-all' => \$opt_wait_all, 'wait-all' => \$opt_wait_all,
'print-testcases' => \&collect_option, 'print-testcases' => \&collect_option,
...@@ -1345,7 +1355,7 @@ sub command_line_setup { ...@@ -1345,7 +1355,7 @@ sub command_line_setup {
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Modified behavior with --start options # Modified behavior with --start options
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
if ($opt_start or $opt_start_dirty) { if ($opt_start or $opt_start_dirty or $opt_start_exit) {
collect_option ('quick-collect', 1); collect_option ('quick-collect', 1);
$start_only= 1; $start_only= 1;
} }
...@@ -3487,6 +3497,18 @@ sub run_testcase ($) { ...@@ -3487,6 +3497,18 @@ sub run_testcase ($) {
mtr_print ($mysqld->name() . " " . $mysqld->value('port') . mtr_print ($mysqld->name() . " " . $mysqld->value('port') .
" " . $mysqld->value('socket')); " " . $mysqld->value('socket'));
} }
if ( $opt_start_exit )
{
mtr_print("Server(s) started, not waiting for them to finish");
if (IS_WINDOWS)
{
POSIX::_exit(0); # exit hangs here in ActiveState Perl
}
else
{
exit(0);
}
}
mtr_print("Waiting for server(s) to exit..."); mtr_print("Waiting for server(s) to exit...");
if ( $opt_wait_all ) { if ( $opt_wait_all ) {
My::SafeProcess->wait_all(); My::SafeProcess->wait_all();
...@@ -4736,6 +4758,12 @@ sub stop_servers($$) { ...@@ -4736,6 +4758,12 @@ sub stop_servers($$) {
sub start_servers($) { sub start_servers($) {
my ($tinfo)= @_; my ($tinfo)= @_;
# Make sure the safe_process also exits from now on
# Could not be done before, as we don't want this for the bootstrap
if ($opt_start_exit) {
My::SafeProcess->start_exit();
}
# Start clusters # Start clusters
foreach my $cluster ( clusters() ) foreach my $cluster ( clusters() )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment