@@ -3961,32 +3961,32 @@ ($$)
3961
3961
}
3962
3962
3963
3963
my $test = $tinfo -> {suite }-> start_test($tinfo );
3964
- # Set to a list of processes we have to keep waiting ( expectedly died servers)
3965
- my % keep_waiting_proc = () ;
3964
+ # Set only when we have to keep waiting after expectedly died server
3965
+ my $ keep_waiting_proc = 0 ;
3966
3966
my $print_timeout = start_timer($print_freq * 60);
3967
3967
3968
3968
while (1)
3969
3969
{
3970
3970
my $proc ;
3971
- if (scalar ( keys ( % keep_waiting_proc)) > 0 )
3971
+ if ($ keep_waiting_proc )
3972
3972
{
3973
3973
# Any other process exited?
3974
3974
$proc = My::SafeProcess-> check_any();
3975
3975
if ($proc )
3976
3976
{
3977
3977
mtr_verbose (" Found exited process $proc " );
3978
- $keep_waiting_proc {$proc } = 1;
3979
3978
}
3980
3979
else
3981
3980
{
3981
+ $proc = $keep_waiting_proc ;
3982
3982
# Also check if timer has expired, if so cancel waiting
3983
3983
if ( has_expired($test_timeout ) )
3984
3984
{
3985
- % keep_waiting_proc = () ;
3985
+ $ keep_waiting_proc = 0 ;
3986
3986
}
3987
3987
}
3988
3988
}
3989
- if (scalar ( keys ( %keep_waiting_proc )) == 0 )
3989
+ if (! $keep_waiting_proc )
3990
3990
{
3991
3991
if ($test_timeout > $print_timeout )
3992
3992
{
@@ -4003,148 +4003,137 @@ ($$)
4003
4003
else
4004
4004
{
4005
4005
$proc = My::SafeProcess-> wait_any_timeout($test_timeout );
4006
- $keep_waiting_proc {$proc } = 1;
4007
4006
}
4008
4007
}
4009
4008
4010
- if (scalar (keys (%keep_waiting_proc )) == 0)
4009
+ # Will be restored if we need to keep waiting
4010
+ $keep_waiting_proc = 0;
4011
+
4012
+ unless ( defined $proc )
4011
4013
{
4012
4014
mtr_error(" wait_any failed" );
4013
4015
}
4014
- mtr_verbose(" Got " . join ( " , " , keys ( %keep_waiting_proc )) );
4016
+ mtr_verbose(" Got $proc " );
4015
4017
4016
4018
mark_time_used(' test' );
4017
- my $expected_exit = 1;
4018
- foreach $proc (keys (%keep_waiting_proc )) {
4019
- # ----------------------------------------------------
4020
- # Was it the test program that exited
4021
- # ----------------------------------------------------
4022
- if ($proc eq $test )
4023
- {
4024
- my $res = $test -> exit_status();
4019
+ # ----------------------------------------------------
4020
+ # Was it the test program that exited
4021
+ # ----------------------------------------------------
4022
+ if ($proc eq $test )
4023
+ {
4024
+ my $res = $test -> exit_status();
4025
4025
4026
- if (($res == 0 or $res == 62) and $opt_warnings and check_warnings($tinfo ) )
4027
- {
4028
- # If test case suceeded, but it has produced unexpected
4029
- # warnings, continue with $res == 1;
4030
- # but if the test was skipped, it should remain skipped
4031
- $res = 1 if $res == 0;
4032
- resfile_output($tinfo -> {' warnings' }) if $opt_resfile ;
4033
- }
4026
+ if (($res == 0 or $res == 62) and $opt_warnings and check_warnings($tinfo ) )
4027
+ {
4028
+ # If test case suceeded, but it has produced unexpected
4029
+ # warnings, continue with $res == 1;
4030
+ # but if the test was skipped, it should remain skipped
4031
+ $res = 1 if $res == 0;
4032
+ resfile_output($tinfo -> {' warnings' }) if $opt_resfile ;
4033
+ }
4034
4034
4035
- if ( $res == 0 )
4036
- {
4037
- my $check_res ;
4038
- if ( $opt_check_testcases and
4039
- $check_res = check_testcase($tinfo , " after" ))
4040
- {
4041
- if ($check_res == 1) {
4042
- # Test case had sideeffects, not fatal error, just continue
4043
- if ($opt_warnings ) {
4044
- # Checking error logs for warnings, so need to stop server
4045
- # gracefully so that memory leaks etc. can be properly detected.
4046
- stop_servers(reverse all_servers());
4047
- check_warnings_post_shutdown($server_socket );
4048
- # Even if we got warnings here, we should not fail this
4049
- # particular test, as the warnings may be caused by an earlier
4050
- # test.
4051
- } else {
4052
- # Not checking warnings, so can do a hard shutdown.
4053
- stop_all_servers($opt_shutdown_timeout );
4054
- }
4055
- mtr_report(" Resuming tests...\n " );
4056
- resfile_output($tinfo -> {' check' }) if $opt_resfile ;
4057
- }
4058
- else {
4059
- # Test case check failed fatally, probably a server crashed
4060
- report_failure_and_restart($tinfo );
4061
- return 1;
4035
+ if ( $res == 0 )
4036
+ {
4037
+ my $check_res ;
4038
+ if ( $opt_check_testcases and
4039
+ $check_res = check_testcase($tinfo , " after" ))
4040
+ {
4041
+ if ($check_res == 1) {
4042
+ # Test case had sideeffects, not fatal error, just continue
4043
+ if ($opt_warnings ) {
4044
+ # Checking error logs for warnings, so need to stop server
4045
+ # gracefully so that memory leaks etc. can be properly detected.
4046
+ stop_servers(reverse all_servers());
4047
+ check_warnings_post_shutdown($server_socket );
4048
+ # Even if we got warnings here, we should not fail this
4049
+ # particular test, as the warnings may be caused by an earlier
4050
+ # test.
4051
+ } else {
4052
+ # Not checking warnings, so can do a hard shutdown.
4053
+ stop_all_servers($opt_shutdown_timeout );
4062
4054
}
4063
- }
4064
- mtr_report_test_passed($tinfo );
4065
- }
4066
- elsif ( $res == 62 )
4067
- {
4068
- # Testcase itself tell us to skip this one
4069
- $tinfo -> {skip_detected_by_test }= 1;
4070
- # Try to get reason from test log file
4071
- find_testcase_skipped_reason($tinfo );
4072
- mtr_report_test_skipped($tinfo );
4073
- # Restart if skipped due to missing perl, it may have had side effects
4074
- if ( $tinfo -> {' comment' } =~ / ^perl not found/ )
4075
- {
4076
- stop_all_servers($opt_shutdown_timeout );
4077
- }
4078
- }
4079
- elsif ( $res == 65 )
4080
- {
4081
- # Testprogram killed by signal
4082
- $tinfo -> {comment }=
4083
- " testprogram crashed(returned code $res )" ;
4084
- report_failure_and_restart($tinfo );
4085
- }
4086
- elsif ( $res == 1 )
4087
- {
4088
- # Check if the test tool requests that
4089
- # an analyze script should be run
4090
- my $analyze = find_analyze_request();
4091
- if ($analyze ){
4092
- run_on_all($tinfo , " analyze-$analyze " );
4093
- }
4094
-
4095
- # Wait a bit and see if a server died, if so report that instead
4096
- mtr_milli_sleep(100);
4097
- my $srvproc = My::SafeProcess::check_any();
4098
- if ($srvproc && grep ($srvproc eq $_ , started(all_servers()))) {
4099
- $proc = $srvproc ;
4100
- goto SRVDIED;
4101
- }
4102
-
4103
- # Test case failure reported by mysqltest
4104
- report_failure_and_restart($tinfo );
4105
- }
4106
- else
4107
- {
4108
- # mysqltest failed, probably crashed
4109
- $tinfo -> {comment }=
4110
- " mysqltest failed with unexpected return code $res \n " ;
4111
- report_failure_and_restart($tinfo );
4112
- }
4113
-
4114
- # Save info from this testcase run to mysqltest.log
4115
- if ( -f $path_current_testlog )
4116
- {
4117
- if ($opt_resfile && $res && $res != 62) {
4118
- resfile_output_file($path_current_testlog );
4119
- }
4120
- mtr_appendfile_to_file($path_current_testlog , $path_testlog );
4121
- unlink ($path_current_testlog );
4122
- }
4123
-
4124
- return ($res == 62) ? 0 : $res ;
4125
-
4055
+ mtr_report(" Resuming tests...\n " );
4056
+ resfile_output($tinfo -> {' check' }) if $opt_resfile ;
4057
+ }
4058
+ else {
4059
+ # Test case check failed fatally, probably a server crashed
4060
+ report_failure_and_restart($tinfo );
4061
+ return 1;
4062
+ }
4063
+ }
4064
+ mtr_report_test_passed($tinfo );
4126
4065
}
4127
-
4128
- # ----------------------------------------------------
4129
- # Check if it was an expected crash
4130
- # ----------------------------------------------------
4131
- my $check_crash = check_expected_crash_and_restart($proc );
4132
- if ($check_crash == 0) # unexpected exit/crash of $proc
4066
+ elsif ( $res == 62 )
4067
+ {
4068
+ # Testcase itself tell us to skip this one
4069
+ $tinfo -> {skip_detected_by_test }= 1;
4070
+ # Try to get reason from test log file
4071
+ find_testcase_skipped_reason($tinfo );
4072
+ mtr_report_test_skipped($tinfo );
4073
+ # Restart if skipped due to missing perl, it may have had side effects
4074
+ if ( $tinfo -> {' comment' } =~ / ^perl not found/ )
4075
+ {
4076
+ stop_all_servers($opt_shutdown_timeout );
4077
+ }
4078
+ }
4079
+ elsif ( $res == 65 )
4080
+ {
4081
+ # Testprogram killed by signal
4082
+ $tinfo -> {comment }=
4083
+ " testprogram crashed(returned code $res )" ;
4084
+ report_failure_and_restart($tinfo );
4085
+ }
4086
+ elsif ( $res == 1 )
4133
4087
{
4134
- $expected_exit = 0;
4135
- last ;
4088
+ # Check if the test tool requests that
4089
+ # an analyze script should be run
4090
+ my $analyze = find_analyze_request();
4091
+ if ($analyze ){
4092
+ run_on_all($tinfo , " analyze-$analyze " );
4093
+ }
4094
+
4095
+ # Wait a bit and see if a server died, if so report that instead
4096
+ mtr_milli_sleep(100);
4097
+ my $srvproc = My::SafeProcess::check_any();
4098
+ if ($srvproc && grep ($srvproc eq $_ , started(all_servers()))) {
4099
+ $proc = $srvproc ;
4100
+ goto SRVDIED;
4101
+ }
4102
+
4103
+ # Test case failure reported by mysqltest
4104
+ report_failure_and_restart($tinfo );
4136
4105
}
4137
- elsif ( $check_crash == 1) # $proc was started again by check_expected_crash_and_restart()
4106
+ else
4138
4107
{
4139
- delete $keep_waiting_proc {$proc };
4108
+ # mysqltest failed, probably crashed
4109
+ $tinfo -> {comment }=
4110
+ " mysqltest failed with unexpected return code $res \n " ;
4111
+ report_failure_and_restart($tinfo );
4140
4112
}
4141
- elsif ($check_crash == 2) # we must keep waiting
4113
+
4114
+ # Save info from this testcase run to mysqltest.log
4115
+ if ( -f $path_current_testlog )
4142
4116
{
4143
- # do nothing
4117
+ if ($opt_resfile && $res && $res != 62) {
4118
+ resfile_output_file($path_current_testlog );
4119
+ }
4120
+ mtr_appendfile_to_file($path_current_testlog , $path_testlog );
4121
+ unlink ($path_current_testlog );
4144
4122
}
4123
+
4124
+ return ($res == 62) ? 0 : $res ;
4125
+
4145
4126
}
4146
4127
4147
- if ($expected_exit ) {
4128
+ # ----------------------------------------------------
4129
+ # Check if it was an expected crash
4130
+ # ----------------------------------------------------
4131
+ my $check_crash = check_expected_crash_and_restart($proc );
4132
+ if ($check_crash )
4133
+ {
4134
+ # Keep waiting if it returned 2, if 1 don't wait or stop waiting.
4135
+ $keep_waiting_proc = 0 if $check_crash == 1;
4136
+ $keep_waiting_proc = $proc if $check_crash == 2;
4148
4137
next ;
4149
4138
}
4150
4139
0 commit comments