#At file:///home/bm136801/my/menv-55/ based on revid:bjorn.munch@stripped
3155 Bjorn Munch 2011-01-20
Bug #59489 Enable setting of env. variables for mysqld from mtr
Added --mysqld-env option, propagate via safe_process
On Windows, we do set it in the parent. Not tested on Windows yet
modified:
mysql-test/lib/My/SafeProcess.pm
mysql-test/lib/My/SafeProcess/safe_process.cc
mysql-test/lib/My/SafeProcess/safe_process_win.cc
mysql-test/mysql-test-run.pl
=== modified file 'mysql-test/lib/My/SafeProcess.pm'
--- a/mysql-test/lib/My/SafeProcess.pm 2011-01-18 10:21:37 +0000
+++ b/mysql-test/lib/My/SafeProcess.pm 2011-01-20 13:32:13 +0000
@@ -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
@@ -139,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";
@@ -161,6 +162,11 @@ 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 (split('&', $envs)) {
+ croak("Missing = in env string") unless $env_var =~ /=/;
+ push @safe_args, "--env $env_var";
+ }
+
push(@safe_args, "--");
push(@safe_args, $path); # The program safe_process should execute
=== modified file 'mysql-test/lib/My/SafeProcess/safe_process.cc'
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc 2011-01-18 10:03:44 +0000
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc 2011-01-20 13:32:13 +0000
@@ -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
@@ -152,7 +152,9 @@ int main(int argc, char* const argv[] )
pid_t own_pid= getpid();
pid_t parent_pid= getppid();
bool nocore = false;
-
+ char* env_ptrs[50]; // 50 --mysqld-env should be plenty
+ int num_envs= 0;
+
/* Install signal handlers */
signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal);
@@ -175,7 +177,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 +186,18 @@ 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 )
+ {
+ /* Do not set env.var. here but remember and set in child */
+ if (num_envs >= 50)
+ die("Too many --env settings added, max. 50 allowed");
+ env_ptrs[num_envs++]= strdup(arg+6);
+ }
else
die("Unknown option: %s", arg);
}
@@ -240,6 +250,10 @@ int main(int argc, char* const argv[] )
// Close write end
close(pfd[1]);
+ for (int i= 0; i < num_envs; i++)
+ {
+ putenv(env_ptrs[i]);
+ }
if (execvp(child_argv[0], child_argv) < 0)
die("Failed to exec child");
}
=== modified file 'mysql-test/lib/My/SafeProcess/safe_process_win.cc'
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc 2011-01-18 10:21:37 +0000
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc 2011-01-20 13:32:13 +0000
@@ -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
@@ -220,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);
}
=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl 2011-01-18 10:21:37 +0000
+++ b/mysql-test/mysql-test-run.pl 2011-01-20 13:32:13 +0000
@@ -175,6 +175,7 @@ our $opt_big_test= 0;
our @opt_combinations;
our @opt_extra_mysqld_opt;
+our @opt_mysqld_envs;
my $opt_compress;
my $opt_ssl;
@@ -961,6 +962,7 @@ sub command_line_setup {
# Extra options used when starting mysqld
'mysqld=s' => \@opt_extra_mysqld_opt,
+ 'mysqld-env=s' => \@opt_mysqld_envs,
# Run test on running server
'extern=s' => \%opts_extern, # Append to hash
@@ -4691,6 +4693,7 @@ sub mysqld_start ($$) {
nocore => $opt_skip_core,
host => undef,
shutdown => sub { mysqld_stop($mysqld) },
+ envs => join('&', @opt_mysqld_envs),
);
mtr_verbose("Started $mysqld->{proc}");
}
@@ -5705,9 +5708,10 @@ Options for test case authoring
check-testcases Check testcases for sideeffects
mark-progress Log line number and elapsed time to <testname>.progress
-Options that pass on options
+Options that pass on options (these may be repeated)
mysqld=ARGS Specify additional arguments to "mysqld"
+ mysqld-env=VAR=VAL Specify additional environment settings for "mysqld"
Options to run test on running server
Attachment: [text/bzr-bundle] bzr/bjorn.munch@oracle.com-20110120133213-3qs3h2oq2g4rgkrs.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-mtr branch (bjorn.munch:3155) Bug#59489 | Bjorn Munch | 20 Jan |