diff options
author | unknown <msvensson@shellback.(none)> | 2006-10-04 12:47:32 +0200 |
---|---|---|
committer | unknown <msvensson@shellback.(none)> | 2006-10-04 12:47:32 +0200 |
commit | dccc6b10c34cc111e6a587642b4e7eb93bd3b6a1 (patch) | |
tree | ae15dc31f5918c502b4313aa7d8cd7f32ce8cca3 /mysql-test/lib/mtr_io.pl | |
parent | 99cfe38ae7d6da2dca8a3b377254d0bfba8b6ac4 (diff) | |
download | mariadb-git-dccc6b10c34cc111e6a587642b4e7eb93bd3b6a1.tar.gz |
Backport from 5.1
-Add support for detecting version and features from mysqld binary
- Autodetect netware
- Disable some features not available below 5.0
- Cleanup executable_setup to look for one executable at a time, only llok for the ones that are needed based on the selected testcases and settings
mysql-test/lib/mtr_cases.pl:
Backport from 5.1
mysql-test/lib/mtr_io.pl:
Backport from 5.1
Add new function mtr_appendfile_to_file
mysql-test/lib/mtr_misc.pl:
Backport from 5.1
mysql-test/lib/mtr_process.pl:
Backport from 5.1
mysql-test/lib/mtr_report.pl:
Backport from 5.1
mysql-test/mysql-test-run.pl:
Add support for detecting version and features from mysqld binary
Autodetect netware
Disable some features not available below 5.0
Cleanup executable_setup to look for one executable at a time, only llok for the ones that are needed based on the selected testcases and settings
mysql-test/r/mysqltest.result:
Update result
mysql-test/lib/mtr_im.pl:
New BitKeeper file ``mysql-test/lib/mtr_im.pl''
mysql-test/lib/mtr_stress.pl:
New BitKeeper file ``mysql-test/lib/mtr_stress.pl''
Diffstat (limited to 'mysql-test/lib/mtr_io.pl')
-rw-r--r-- | mysql-test/lib/mtr_io.pl | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index b3da6d97664..8a7fc56269c 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -11,6 +11,8 @@ sub mtr_get_opts_from_file ($); sub mtr_fromfile ($); sub mtr_tofile ($@); sub mtr_tonewfile($@); +sub mtr_lastlinefromfile($); +sub mtr_appendfile_to_file ($$); ############################################################################## # @@ -19,13 +21,39 @@ sub mtr_tonewfile($@); ############################################################################## sub mtr_get_pid_from_file ($) { - my $file= shift; + my $pid_file_path= shift; + my $TOTAL_ATTEMPTS= 30; + my $timeout= 1; - open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); - my $pid= <FILE>; - chomp($pid); - close FILE; - return $pid; + # We should read from the file until we get correct pid. As it is + # stated in BUG#21884, pid file can be empty at some moment. So, we should + # read it until we get valid data. + + for (my $cur_attempt= 1; $cur_attempt <= $TOTAL_ATTEMPTS; ++$cur_attempt) + { + mtr_debug("Reading pid file '$pid_file_path' " . + "($cur_attempt of $TOTAL_ATTEMPTS)..."); + + open(FILE, '<', $pid_file_path) + or mtr_error("can't open file \"$pid_file_path\": $!"); + + my $pid= <FILE>; + + chomp($pid) if defined $pid; + + close FILE; + + return $pid if defined $pid && $pid ne ''; + + mtr_debug("Pid file '$pid_file_path' is empty. " . + "Sleeping $timeout second(s)..."); + + sleep(1); + } + + mtr_error("Pid file '$pid_file_path' is corrupted. " . + "Can not retrieve PID in " . + ($timeout * $TOTAL_ATTEMPTS) . " seconds."); } sub mtr_get_opts_from_file ($) { @@ -113,6 +141,20 @@ sub mtr_fromfile ($) { return $text; } +sub mtr_lastlinefromfile ($) { + my $file= shift; + my $text; + + open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); + while (my $line= <FILE>) + { + $text= $line; + } + close FILE; + return $text; +} + + sub mtr_tofile ($@) { my $file= shift; @@ -129,5 +171,17 @@ sub mtr_tonewfile ($@) { close FILE; } +sub mtr_appendfile_to_file ($$) { + my $from_file= shift; + my $to_file= shift; + + open(TOFILE,">>",$to_file) or mtr_error("can't open file \"$to_file\": $!"); + open(FROMFILE,">>",$from_file) + or mtr_error("can't open file \"$from_file\": $!"); + print TOFILE while (<FROMFILE>); + close FROMFILE; + close TOFILE; +} + 1; |