diff options
author | unknown <kent@mysql.com> | 2005-08-18 00:07:17 +0200 |
---|---|---|
committer | unknown <kent@mysql.com> | 2005-08-18 00:07:17 +0200 |
commit | 2b4cfda2ebffcb483b2a48e6357c4c466486ed97 (patch) | |
tree | 91046585310db26f3531a9a7e30b8ba37a28f3c3 | |
parent | 9c0cfb16ded7f2ed2480e1a6adc0060fd9795065 (diff) | |
download | mariadb-git-2b4cfda2ebffcb483b2a48e6357c4c466486ed97.tar.gz |
mtr_process.pl:
Bug#11792: Create a shell like 'mysqltest' exit status
mysql-test/lib/mtr_process.pl:
Bug#11792: Create a shell like 'mysqltest' exit status
-rw-r--r-- | mysql-test/lib/mtr_process.pl | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index fb37296971e..ec12bc3907c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -185,10 +185,6 @@ sub spawn_parent_impl { if ( $mode eq 'run' or $mode eq 'test' ) { - my $exit_value= -1; -# my $signal_num= 0; -# my $dumped_core= 0; - if ( $mode eq 'run' ) { # Simple run of command, we wait for it to return @@ -199,12 +195,7 @@ sub spawn_parent_impl { mtr_error("$path ($pid) got lost somehow"); } - $exit_value= $?; -# $exit_value= $? >> 8; -# $signal_num= $? & 127; -# $dumped_core= $? & 128; - - return $exit_value; + return mtr_process_exit_status($?); } else { @@ -218,6 +209,7 @@ sub spawn_parent_impl { # FIXME is this as it should be? Can't mysqld terminate # normally from running a test case? + my $exit_value= -1; my $ret_pid; # What waitpid() returns while ( ($ret_pid= waitpid(-1,0)) != -1 ) @@ -230,10 +222,7 @@ sub spawn_parent_impl { if ( $ret_pid == $pid ) { # We got termination of mysqltest, we are done - $exit_value= $?; -# $exit_value= $? >> 8; -# $signal_num= $? & 127; -# $dumped_core= $? & 128; + $exit_value= mtr_process_exit_status($?); last; } @@ -292,6 +281,23 @@ sub spawn_parent_impl { } +# ---------------------------------------------------------------------- +# We try to emulate how an Unix shell calculates the exit code +# ---------------------------------------------------------------------- + +sub mtr_process_exit_status { + my $raw_status= shift; + + if ( $raw_status & 127 ) + { + return ($raw_status & 127) + 128; # Signal num + 128 + } + else + { + return $raw_status >> 8; # Exit code + } +} + ############################################################################## # |