1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Windows fixeds for mtr

CMakeLists.txt:
  Add CMakeLists.txt in mysql-test/lib/My/SafeProcess/
mysql-test/lib/My/Find.pm:
  Fix for windows
mysql-test/lib/My/SafeProcess.pm:
  Fix Tim's review comments
mysql-test/lib/mtr_misc.pl:
  Rename glob_win32 to is_win32
mysql-test/mysql-test-run.pl:
  Move set_mtr_build_thread_ports earlier
  Set MTR_BUILD_THREAD if to the used value
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
  New BitKeeper file ``mysql-test/lib/My/SafeProcess/CMakeLists.txt''
This commit is contained in:
unknown
2007-12-19 12:58:06 +01:00
parent 516a843b52
commit 23f0c6d4fc
6 changed files with 75 additions and 34 deletions

View File

@ -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(<base>, <paths>, <names>)"
croak "usage: my_find_bin(<base>, <paths>, <names>)"
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(<base>, <paths>[, <dirs>])"
croak "usage: my_find_dir(<base>, <paths>[, <dirs>])"
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;

View File

@ -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;

View File

@ -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)