diff options
Diffstat (limited to 'mysql-test/lib/My')
-rw-r--r-- | mysql-test/lib/My/ConfigFactory.pm | 17 | ||||
-rw-r--r-- | mysql-test/lib/My/Find.pm | 20 | ||||
-rw-r--r--[-rwxr-xr-x] | mysql-test/lib/My/Handles.pm | 0 | ||||
-rw-r--r-- | mysql-test/lib/My/Options.pm | 20 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess.pm | 28 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/CMakeLists.txt | 23 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/Makefile.am | 29 | ||||
-rw-r--r--[-rwxr-xr-x] | mysql-test/lib/My/SafeProcess/safe_kill_win.cc | 1 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/safe_process.cc | 11 | ||||
-rw-r--r--[-rwxr-xr-x] | mysql-test/lib/My/SafeProcess/safe_process_win.cc | 11 |
10 files changed, 89 insertions, 71 deletions
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index bb990a9f8d2..6ba23754890 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -53,6 +53,15 @@ sub get_testdir { return $testdir; } +# Retrive build directory (which is different from basedir in out-of-source build) +sub get_bindir { + if (defined $ENV{MTR_BINDIR}) + { + return $ENV{MTR_BINDIR}; + } + my ($self, $group)= @_; + return $self->get_basedir($group); +} sub fix_charset_dir { my ($self, $config, $group_name, $group)= @_; @@ -62,8 +71,8 @@ sub fix_charset_dir { sub fix_language { my ($self, $config, $group_name, $group)= @_; - return my_find_dir($self->get_basedir($group), - \@share_locations, "english"); + return my_find_dir($self->get_bindir($group), + \@share_locations); } sub fix_datadir { @@ -221,7 +230,7 @@ my @mysqld_rules= { 'basedir' => sub { return shift->{ARGS}->{basedir}; } }, { 'tmpdir' => \&fix_tmpdir }, { 'character-sets-dir' => \&fix_charset_dir }, - { 'language' => \&fix_language }, + { 'lc-messages-dir' => \&fix_language }, { 'datadir' => \&fix_datadir }, { 'pid-file' => \&fix_pidfile }, { '#host' => \&fix_host }, @@ -357,6 +366,7 @@ my @mysql_upgrade_rules= sub post_check_client_group { my ($self, $config, $client_group_name, $mysqld_group_name)= @_; + # Settings needed for client, copied from its "mysqld" my %client_needs= ( @@ -366,7 +376,6 @@ sub post_check_client_group { user => '#user', password => '#password', ); - my $group_to_copy_from= $config->group($mysqld_group_name); while (my ($name_to, $name_from)= each( %client_needs )) { my $option= $group_to_copy_from->option($name_from); diff --git a/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm index 8cbd6db3201..9d1d2915012 100644 --- a/mysql-test/lib/My/Find.pm +++ b/mysql-test/lib/My/Find.pm @@ -165,16 +165,16 @@ sub my_find_paths { } # ------------------------------------------------------- - # Windows specific - # ------------------------------------------------------- - if (IS_WINDOWS) { - # Add the default extra build dirs unless a specific one has - # already been selected - push(@extra_dirs, - ("release", - "relwithdebinfo", - "debug")) if @extra_dirs == 0; - } + # CMake generator specific (Visual Studio and Xcode have multimode builds) + # ------------------------------------------------------- + + # Add the default extra build dirs unless a specific one has + # already been selected + push(@extra_dirs, + ("Release", + "Relwithdebinfo", + "Debug")) if @extra_dirs == 0; + #print "extra_build_dir: @extra_dirs\n"; diff --git a/mysql-test/lib/My/Handles.pm b/mysql-test/lib/My/Handles.pm index 66ee22b403f..66ee22b403f 100755..100644 --- a/mysql-test/lib/My/Handles.pm +++ b/mysql-test/lib/My/Handles.pm diff --git a/mysql-test/lib/My/Options.pm b/mysql-test/lib/My/Options.pm index 6e8cf7ec919..dcd934084e2 100644 --- a/mysql-test/lib/My/Options.pm +++ b/mysql-test/lib/My/Options.pm @@ -67,9 +67,6 @@ sub _split_option { elsif ($option=~ /^(.*)=(.*)$/){ return ($1, $2) } - elsif ($option=~ /^-O$/){ - return (undef, undef); - } die "Unknown option format '$option'"; } @@ -169,20 +166,11 @@ sub toSQL { my @sql; foreach my $option (@options) { - my ($name, $value)= _split_option($option); - #print "name: $name\n"; + my ($sql_name, $value)= _split_option($option); + #print "name: $sql_name\n"; #print "value: $value\n"; - if ($name =~ /^O, (.*)/){ - push(@sql, "SET GLOBAL $1=$value"); - } - elsif ($name =~ /^set-variable=(.*)/){ - push(@sql, "SET GLOBAL $1=$value"); - } - else { - my $sql_name= $name; - $sql_name=~ s/-/_/g; - push(@sql, "SET GLOBAL $sql_name=$value"); - } + $sql_name=~ s/-/_/g; + push(@sql, "SET GLOBAL $sql_name=$value"); } return join("; ", @sql); } diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 9334d97f665..14153982d4e 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -1,5 +1,5 @@ # -*- cperl -*- -# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public @@ -85,23 +85,35 @@ sub is_child { my @safe_process_cmd; my $safe_kill; +my $bindir; +if(defined $ENV{MTR_BINDIR}) +{ + # This is an out-of-source build. Build directory + # is given in MTR_BINDIR env.variable + $bindir = $ENV{MTR_BINDIR}."/mysql-test"; +} +else +{ + $bindir = "."; +} + # Find the safe process binary or script sub find_bin { if (IS_WIN32PERL or IS_CYGWIN) { # Use my_safe_process.exe - my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], + my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], "my_safe_process"); push(@safe_process_cmd, $exe); # Use my_safe_kill.exe - $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill"); + $safe_kill= my_find_bin($bindir, "lib/My/SafeProcess", "my_safe_kill"); } else { # Use my_safe_process - my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"], + my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], "my_safe_process"); push(@safe_process_cmd, $exe); } @@ -127,6 +139,7 @@ sub new { my $host = delete($opts{'host'}); my $shutdown = delete($opts{'shutdown'}); my $user_data= delete($opts{'user_data'}); + my $envs = delete($opts{'envs'}); # if (defined $host) { # $safe_script= "lib/My/SafeProcess/safe_process_cpcd.pl"; @@ -149,6 +162,13 @@ sub new { # Point the safe_process at the right parent if running on cygwin push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; + foreach my $env_var (@$envs) { + croak("Missing = in env string") unless $env_var =~ /=/; + croak("Env string $env_var seen, probably missing value for --mysqld-env") + if $env_var =~ /^--/; + push @safe_args, "--env $env_var"; + } + push(@safe_args, "--"); push(@safe_args, $path); # The program safe_process should execute diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index 5150fcaafff..810096805c8 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2008 MySQL AB +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # # 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 @@ -11,7 +11,22 @@ # # 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 +# 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) +SET(INSTALL_ARGS + DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" + COMPONENT Test +) + +IF (WIN32) + MYSQL_ADD_EXECUTABLE(my_safe_process safe_process_win.cc ${INSTALL_ARGS}) + MYSQL_ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc ${INSTALL_ARGS}) +ELSE() + MYSQL_ADD_EXECUTABLE(my_safe_process safe_process.cc ${INSTALL_ARGS}) +ENDIF() + +INSTALL(TARGETS my_safe_process DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test) +IF(WIN32) + INSTALL(TARGETS my_safe_kill DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test) +ENDIF() +INSTALL(FILES safe_process.pl Base.pm DESTINATION "${INSTALL_MYSQLTESTDIR}/lib/My/SafeProcess" COMPONENT Test) diff --git a/mysql-test/lib/My/SafeProcess/Makefile.am b/mysql-test/lib/My/SafeProcess/Makefile.am deleted file mode 100644 index eb665240190..00000000000 --- a/mysql-test/lib/My/SafeProcess/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2008 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -testroot = $(prefix) -safedir = $(testroot)/mysql-test/lib/My/SafeProcess -#nobase_bin_PROGRAMS = ... -safe_PROGRAMS = my_safe_process - -my_safe_process_SOURCES = safe_process.cc - -EXTRA_DIST = safe_kill_win.cc \ - safe_process_win.cc \ - CMakeLists.txt - - -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc index 9b013b960bf..72fe874e621 100755..100644 --- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc @@ -24,6 +24,7 @@ #include <windows.h> #include <stdio.h> #include <signal.h> +#include <stdlib.h> int main(int argc, const char** argv ) { diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 477beca0ada..e5eca0c0d8b 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -175,7 +175,7 @@ int main(int argc, char* const argv[] ) } else { if ( strcmp(arg, "--verbose") == 0 ) verbose++; - else if ( strncmp(arg, "--parent-pid", 10) == 0 ) + else if ( strncmp(arg, "--parent-pid", 12) == 0 ) { /* Override parent_pid with a value provided by user */ const char* start; @@ -184,10 +184,15 @@ int main(int argc, char* const argv[] ) start++; /* Step past = */ if ((parent_pid= atoi(start)) == 0) die("Invalid value '%s' passed to --parent-id", start); - } else if ( strcmp(arg, "--nocore") == 0 ) + } + else if ( strcmp(arg, "--nocore") == 0 ) { nocore = true; // Don't allow the process to dump core } + else if ( strncmp (arg, "--env ", 6) == 0 ) + { + putenv(strdup(arg+6)); + } else die("Unknown option: %s", arg); } diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 931705e1911..7e0ae68b4de 100755..100644 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 MySQL AB, 2009 Sun Microsystems, Inc. +/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 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 @@ -54,6 +54,7 @@ #include <stdio.h> #include <tlhelp32.h> #include <signal.h> +#include <stdlib.h> static int verbose= 0; static char safe_process_name[32]= {0}; @@ -219,6 +220,10 @@ int main(int argc, const char** argv ) { nocore= TRUE; } + else if ( strncmp (arg, "--env ", 6) == 0 ) + { + putenv(strdup(arg+6)); + } else die("Unknown option: %s", arg); } @@ -251,6 +256,10 @@ int main(int argc, const char** argv ) Make all processes associated with the job terminate when the last handle to the job is closed. */ +#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE +#define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000 +#endif + jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; if (SetInformationJobObject(job_handle, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli)) == 0) |