diff --git a/CMakeLists.txt b/CMakeLists.txt index 341f8d08df2..32eed9d39c7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,3 +245,4 @@ IF(WITH_EMBEDDED_SERVER) ADD_SUBDIRECTORY(libmysqld) ADD_SUBDIRECTORY(libmysqld/examples) ENDIF(WITH_EMBEDDED_SERVER) +ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess) diff --git a/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm index 8b996ce45a4..4a1fff0fdfc 100644 --- a/mysql-test/lib/My/Find.pm +++ b/mysql-test/lib/My/Find.pm @@ -22,6 +22,7 @@ package My::Find; # use strict; +use Carp; use base qw(Exporter); our @EXPORT= qw(my_find_bin my_find_dir); @@ -29,6 +30,7 @@ our @EXPORT= qw(my_find_bin my_find_dir); our $vs_config_dir; my $is_win= ($^O eq "MSWin32" or $^O eq "Win32"); +my $bin_extension= ".exe" if $is_win; # # my_find_bin - find an executable with "name_1...name_n" in @@ -47,13 +49,13 @@ my $is_win= ($^O eq "MSWin32" or $^O eq "Win32"); # sub my_find_bin { my ($base, $paths, $names)= @_; - die "usage: my_find_bin(, , )" + croak "usage: my_find_bin(, , )" unless @_ == 3; # ------------------------------------------------------- # Find and return the first executable # ------------------------------------------------------- - foreach my $path (my_find_paths($base, $paths, $names)) { + foreach my $path (my_find_paths($base, $paths, $names, $bin_extension)) { return $path if ( -x $path or ($is_win and -f $path) ); } find_error($base, $paths, $names); @@ -78,7 +80,7 @@ sub my_find_bin { # sub my_find_dir { my ($base, $paths, $dirs)= @_; - die "usage: my_find_dir(, [, ])" + croak "usage: my_find_dir(, [, ])" unless (@_ == 3 or @_ == 2); # ------------------------------------------------------- @@ -92,7 +94,7 @@ sub my_find_dir { sub my_find_paths { - my ($base, $paths, $names)= @_; + my ($base, $paths, $names, $extension)= @_; # Convert the arguments into two normal arrays to ease # further mappings @@ -110,13 +112,15 @@ sub my_find_paths { my $build_dir= $vs_config_dir || $ENV{MTR_VS_CONFIG} || $ENV{MTR_BUILD_DIR}; push(@extra_dirs, $build_dir) if defined $build_dir; + if (defined $extension){ + # Append extension to names, if name does not already have extension + map { $_.=$extension unless /\.(.*)+$/ } @names; + } + # ------------------------------------------------------- # Windows specific # ------------------------------------------------------- if ($is_win) { - # Append .exe to names, if name does not already have extension - map { $_.=".exe" unless /\.(.*)+$/ } @names; - # Add the default extra build dirs unless a specific one has # already been selected push(@extra_dirs, @@ -156,6 +160,21 @@ sub my_find_paths { } +sub commify { + return + (@_ == 0) ? '' : + (@_ == 1) ? $_[0] : + (@_ == 2) ? join(" or ", @_) : + join(", ", @_[0..($#_-1)], "or $_[-1]"); + +} + + +sub fnuttify { + return map('\''.$_.'\'', @_); +} + + sub find_error { my ($base, $paths, $names)= @_; @@ -163,9 +182,9 @@ sub find_error { push(@names, ref $names eq "ARRAY" ? @$names : $names); push(@paths, ref $paths eq "ARRAY" ? @$paths : $paths); - die "Could not find ", - join(", ", @names), " in ", - join(", ", my_find_paths($base, $paths, $names)); + croak "** ERROR: Could not find ", + commify(fnuttify(@names)), " in ", + commify(fnuttify(my_find_paths($base, $paths, $names))), "\n"; } 1; diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 7e1f699ee25..612096cceb7 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -86,23 +86,26 @@ BEGIN { } # Find the safe process binary or script -my $safe_path= $^X; # Path to perl binary -my $safe_script; +my @safe_process_cmd; my $safe_kill; if (IS_WIN32PERL or IS_CYGWIN){ # Use my_safe_process.exe - $safe_path= my_find_bin(("extra","bin"), "my_safe_process.exe"); - die "Could not find my_safe_process.exe" unless $safe_path; + my $exe= my_find_bin(".", "lib/My/SafeProcess", "my_safe_process.exe"); + die "Could not find my_safe_process.exe" unless $exe; + push(@safe_process_cmd, $exe); # Use my_safe_kill.exe - $safe_path= my_find_bin(("extra","bin"), "my_safe_kill"); + my $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill"); die "Could not find my_safe_kill.exe" unless $safe_kill; } else { # Use safe_process.pl - $safe_script= "lib/My/SafeProcess/safe_process.pl"; - $safe_script= "../$safe_script" unless -f $safe_script; - die "Could not find safe_process.pl" unless -f $safe_script; + my $script= "lib/My/SafeProcess/safe_process.pl"; + $script= "../$script" unless -f $script; + die "Could not find safe_process.pl" unless -f $script; + + # Call $script with Perl interpreter + push(@safe_process_cmd, $^X, $script); } @@ -124,9 +127,9 @@ sub new { my $host = delete($opts{'host'}); my $shutdown = delete($opts{'shutdown'}); - if (defined $host) { - $safe_script= "lib/My/SafeProcess/safe_process_cpcd.pl"; - } +# if (defined $host) { +# $safe_script= "lib/My/SafeProcess/safe_process_cpcd.pl"; +# } if (IS_CYGWIN){ # safe_procss is a windows program and need @@ -138,6 +141,7 @@ sub new { } my @safe_args; + my ($safe_path, $safe_script)= @safe_process_cmd; push(@safe_args, $safe_script) if defined $safe_script; push(@safe_args, "--verbose") if $verbose > 0; diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt new file mode 100644 index 00000000000..97fab820f95 --- /dev/null +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2006 MySQL AB +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +ADD_EXECUTABLE(my_safe_process safe_process_win.cc) +ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc) diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 95f5bf584f0..3c1d60fd6ab 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -49,7 +49,7 @@ sub mtr_native_path($) if ($::mysql_version_id < 50000); $path=~ s/\//\\/g - if ($::glob_win32); + if ($::is_win32); return $path; } @@ -72,7 +72,7 @@ sub mtr_add_arg ($$@) { # Quote args if args contain space $format= "\"$format\"" - if ($::glob_win32 and grep(/\s/, @fargs)); + if ($::is_win32 and grep(/\s/, @fargs)); push(@$args, sprintf($format, @fargs)); } @@ -111,7 +111,7 @@ sub mtr_path_exists (@) { sub mtr_script_exists (@) { foreach my $path ( @_ ) { - if($::glob_win32) + if($::is_win32) { return $path if -f $path; } @@ -151,10 +151,10 @@ sub mtr_file_exists (@) { sub mtr_exe_maybe_exists (@) { my @path= @_; - map {$_.= ".exe"} @path if $::glob_win32; + map {$_.= ".exe"} @path if $::is_win32; foreach my $path ( @path ) { - if($::glob_win32) + if($::is_win32) { return $path if -f $path; } diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index bb9ee1cfba8..8d9d10e7252 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -304,7 +304,7 @@ sub command_line_setup { 'skip-combination' => \&collect_option, # Specify ports - 'mtr-build-thread=i' => \$opt_mtr_build_thread, + 'build-thread|mtr-build-thread=i' => \$opt_mtr_build_thread, # Test case authoring 'record' => \$opt_record, @@ -410,6 +410,11 @@ sub command_line_setup { $basedir= dirname($basedir); } + # -------------------------------------------------------------------------- + # Check mtr_build_thread and calculate baseport + # -------------------------------------------------------------------------- + set_mtr_build_thread_ports($opt_mtr_build_thread); + # # Find the mysqld executable to be able to find the mysqld version # number as early as possible @@ -732,11 +737,6 @@ sub command_line_setup { $path_current_test_log= "$opt_vardir/log/current_test"; $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; - # -------------------------------------------------------------------------- - # Check mtr_build_thread and calculate baseport - # -------------------------------------------------------------------------- - set_mtr_build_thread_ports($opt_mtr_build_thread); - } @@ -765,6 +765,7 @@ sub set_mtr_build_thread_ports($) { print "got ".$mtr_build_thread."\n"; } $opt_mtr_build_thread= $mtr_build_thread; + $ENV{MTR_BUILD_THREAD}= $mtr_build_thread; # Calculate baseport $opt_baseport= $mtr_build_thread * 10 + 10000; @@ -3551,9 +3552,8 @@ Options to control what test suites or cases to run Options that specify ports - baseport=PORT Specify the first port number used mtr-build-thread=# Specify unique number to calculate port number(s) from. - Can be set in environment variable MTR_BUILD_THREAD. + build-thread=# Can be set in environment variable MTR_BUILD_THREAD. Set MTR_BUILD_THREAD="auto" to automatically aquire a build thread id that is unique to current host