summaryrefslogtreecommitdiff
path: root/mysql-test/lib/mtr_io.pl
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
commit7006168a398a6c7f03ea5b29811b796acfa31edc (patch)
treee628dba305872724812721f583ea0be67c31ebfb /mysql-test/lib/mtr_io.pl
parenta9f719171794f27b20e43909ba9c4169bf362da0 (diff)
downloadmariadb-git-7006168a398a6c7f03ea5b29811b796acfa31edc.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/mtr_io.pl')
-rw-r--r--mysql-test/lib/mtr_io.pl63
1 files changed, 61 insertions, 2 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;