summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authorunknown <kent@mysql.com>2005-01-11 01:35:08 +0100
committerunknown <kent@mysql.com>2005-01-11 01:35:08 +0100
commitac606583ca57bf3e6431f6181158c30a8f73255a (patch)
treee628dba305872724812721f583ea0be67c31ebfb /mysql-test/lib
parent2d3c55cd7be8ad9bd2647c3cd8484364d4aefc10 (diff)
downloadmariadb-git-ac606583ca57bf3e6431f6181158c30a8f73255a.tar.gz
mtr_process.pl:
Catch more fork() errors. Moved sleep_until_file_created() here from "mysql-test-run.pl". Improved debug output. mtr_io.pl: Improved mtr_get_opts_from_file(), try to mimic some sh. mysql-test-run.pl: Cleaned up the timeout handling. Created new function environment_setup(). Corrected time zone handling. Moved sleep_until_file_created() to "lib/mtr_process.pl". Improved debug output. mysql-test/mysql-test-run.pl: Cleaned up the timeout handling. Created new function environment_setup(). Corrected time zone handling. Moved sleep_until_file_created() to "lib/mtr_process.pl". Improved debug output. mysql-test/lib/mtr_io.pl: Improved mtr_get_opts_from_file(), try to mimic some sh. mysql-test/lib/mtr_process.pl: Catch more fork() errors. Moved sleep_until_file_created() here from "mysql-test-run.pl". Improved debug output.
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/mtr_io.pl63
-rw-r--r--mysql-test/lib/mtr_process.pl79
2 files changed, 120 insertions, 22 deletions
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index 14ea37dbb75..017ba11645b 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -35,13 +35,72 @@ sub mtr_get_opts_from_file ($) {
while ( <FILE> )
{
chomp;
- s/\$MYSQL_TEST_DIR/$::glob_mysql_test_dir/g;
- push(@args, split(' ', $_));
+
+ # --set-variable=init_connect=set @a='a\\0c'
+ s/^\s+//; # Remove leading space
+ s/\s+$//; # Remove ending space
+
+ # This is strange, but we need to fill whitespace inside
+ # quotes with something, to remove later. We do this to
+ # be able to split on space. Else, we have trouble with
+ # options like
+ #
+ # --someopt="--insideopt1 --insideopt2"
+ #
+ # But still with this, we are not 100% sure it is right,
+ # we need a shell to do it right.
+
+# print STDERR "\n";
+# print STDERR "AAA: $_\n";
+
+ s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
+ s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
+ s/\'([^\'\"]*)\'/unspace($1,"\x0a")/ge;
+ s/\"([^\'\"]*)\"/unspace($1,"\x0b")/ge;
+
+# print STDERR "BBB: $_\n";
+
+# foreach my $arg (/(--?\w.*?)(?=\s+--?\w|$)/)
+
+ # FIXME ENV vars should be expanded!!!!
+
+ foreach my $arg (split(/[ \t]+/))
+ {
+ $arg =~ tr/\x11\x0a\x0b/ \'\"/; # Put back real chars
+ # The outermost quotes has to go
+ $arg =~ s/^([^\'\"]*)\'(.*)\'([^\'\"]*)$/$1$2$3/
+ or $arg =~ s/^([^\'\"]*)\"(.*)\"([^\'\"]*)$/$1$2$3/;
+ $arg =~ s/\\\\/\\/g;
+
+ $arg =~ s/\$\{(\w+)\}/envsubst($1)/ge;
+ $arg =~ s/\$(\w+)/envsubst($1)/ge;
+
+# print STDERR "ARG: $arg\n";
+ push(@args, $arg);
+ }
}
close FILE;
return \@args;
}
+sub envsubst {
+ my $string= shift;
+
+ if ( ! defined $ENV{$string} )
+ {
+ mtr_error("opt file referense \$$string that is unknown");
+ }
+
+ return $ENV{$string};
+}
+
+sub unspace {
+ my $string= shift;
+ my $quote= shift;
+ $string =~ s/[ \t]/\x11/g;
+ return "$quote$string$quote";
+}
+
sub mtr_fromfile ($) {
my $file= shift;
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 8c584802b8e..e832468d0cb 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -4,7 +4,7 @@
# and is part of the translation of the Bourne shell script with the
# same name.
-use Carp qw(cluck);
+#use Carp qw(cluck);
use strict;
use POSIX ":sys_wait_h";
@@ -64,18 +64,6 @@ sub spawn_impl ($$$$$$$) {
my $error= shift;
my $pid_file= shift; # FIXME
- # FIXME really needing a PATH???
- # $ENV{'PATH'}= "/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$ENV{'PATH'}";
-
- $ENV{'TZ'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work
- $ENV{'LC_COLLATE'}= "C";
- $ENV{'MYSQL_TEST_DIR'}= $::glob_mysql_test_dir;
- $ENV{'MASTER_MYPORT'}= $::opt_master_myport;
- $ENV{'SLAVE_MYPORT'}= $::opt_slave_myport;
-# $ENV{'MYSQL_TCP_PORT'}= '@MYSQL_TCP_PORT@'; # FIXME
- $ENV{'MYSQL_TCP_PORT'}= 3306;
- $ENV{'MASTER_MYSOCK'}= $::master->[0]->{'path_mysock'};
-
if ( $::opt_script_debug )
{
print STDERR "\n";
@@ -85,17 +73,21 @@ sub spawn_impl ($$$$$$$) {
print STDERR "#### ", "STDERR $error\n" if $error;
if ( $join )
{
- print STDERR "#### ", "run";
+ print STDERR "#### ", "RUN ";
}
else
{
- print STDERR "#### ", "spawn";
+ print STDERR "#### ", "SPAWN ";
}
print STDERR "$path ", join(" ",@$arg_list_t), "\n";
print STDERR "#### ", "-" x 78, "\n";
}
my $pid= fork();
+ if ( ! defined $pid )
+ {
+ mtr_error("$path ($pid) can't be forked");
+ }
if ( $pid )
{
@@ -104,17 +96,22 @@ sub spawn_impl ($$$$$$$) {
{
# We run a command and wait for the result
# FIXME this need to be improved
- waitpid($pid,0);
+ my $res= waitpid($pid,0);
+
+ if ( $res == -1 )
+ {
+ mtr_error("$path ($pid) got lost somehow");
+ }
my $exit_value= $? >> 8;
my $signal_num= $? & 127;
my $dumped_core= $? & 128;
if ( $signal_num )
{
- mtr_error("spawn got signal $signal_num");
+ mtr_error("$path ($pid) got signal $signal_num");
}
if ( $dumped_core )
{
- mtr_error("spawn dumped core");
+ mtr_error("$path ($pid) dumped core");
}
return $exit_value;
}
@@ -326,7 +323,8 @@ sub mtr_stop_mysqld_servers ($$) {
mtr_init_args(\$args);
mtr_add_arg($args, "--no-defaults");
- mtr_add_arg($args, "-uroot");
+ mtr_add_arg($args, "--user=%s", $::opt_user);
+ mtr_add_arg($args, "--password=");
if ( -e $srv->{'sockfile'} )
{
mtr_add_arg($args, "--socket=%s", $srv->{'sockfile'});
@@ -336,7 +334,8 @@ sub mtr_stop_mysqld_servers ($$) {
mtr_add_arg($args, "--port=%s", $srv->{'port'});
}
mtr_add_arg($args, "--connect_timeout=5");
- mtr_add_arg($args, "--shutdown_timeout=70");
+ mtr_add_arg($args, "--shutdown_timeout=20");
+ mtr_add_arg($args, "--protocol=tcp"); # FIXME new thing, will it help?!
mtr_add_arg($args, "shutdown");
# We don't wait for termination of mysqladmin
mtr_spawn($::exe_mysqladmin, $args,
@@ -361,6 +360,10 @@ sub mtr_stop_mysqld_servers ($$) {
{
last PIDSOCKFILEREMOVED;
}
+ if ( $loop % 20 == 1 )
+ {
+ mtr_warning("Still processes alive after 10 seconds, retrying for $loop seconds...");
+ }
mtr_debug("Sleep for 1 second waiting for pid and socket file removal");
sleep(1); # One second
}
@@ -464,4 +467,40 @@ sub stop_reap_all {
$SIG{CHLD}= 'DEFAULT';
}
+##############################################################################
+#
+# Wait for a file to be created
+#
+##############################################################################
+
+
+sub sleep_until_file_created ($$) {
+ my $pidfile= shift;
+ my $timeout= shift;
+
+ my $loop= $timeout;
+ while ( $loop-- )
+ {
+ if ( -r $pidfile )
+ {
+ return;
+ }
+ mtr_debug("Sleep for 1 second waiting for creation of $pidfile");
+
+ if ( $loop % 20 == 1 )
+ {
+ mtr_warning("Waiting for $pidfile to be created, still trying for $loop seconds...");
+ }
+
+ sleep(1);
+ }
+
+ if ( ! -r $pidfile )
+ {
+ mtr_error("No $pidfile was created");
+ }
+}
+
+
+
1;