diff options
Diffstat (limited to 'mysql-test/lib/mtr_io.pl')
-rw-r--r-- | mysql-test/lib/mtr_io.pl | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl new file mode 100644 index 00000000000..14ea37dbb75 --- /dev/null +++ b/mysql-test/lib/mtr_io.pl @@ -0,0 +1,71 @@ +# -*- cperl -*- + +# This is a library file used by the Perl version of mysql-test-run, +# and is part of the translation of the Bourne shell script with the +# same name. + +use strict; + +sub mtr_get_pid_from_file ($); +sub mtr_get_opts_from_file ($); +sub mtr_tofile ($@); +sub mtr_tonewfile($@); + +############################################################################## +# +# +# +############################################################################## + +sub mtr_get_pid_from_file ($) { + my $file= shift; + + open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); + my $pid= <FILE>; + chomp($pid); + close FILE; + return $pid; +} + +sub mtr_get_opts_from_file ($) { + my $file= shift; + + open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); + my @args; + while ( <FILE> ) + { + chomp; + s/\$MYSQL_TEST_DIR/$::glob_mysql_test_dir/g; + push(@args, split(' ', $_)); + } + close FILE; + return \@args; +} + +sub mtr_fromfile ($) { + my $file= shift; + + open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!"); + my $text= join('', <FILE>); + close FILE; + return $text; +} + +sub mtr_tofile ($@) { + my $file= shift; + + open(FILE,">>",$file) or mtr_error("can't open file \"$file\": $!"); + print FILE join("", @_); + close FILE; +} + +sub mtr_tonewfile ($@) { + my $file= shift; + + open(FILE,">",$file) or mtr_error("can't open file \"$file\": $!"); + print FILE join("", @_); + close FILE; +} + + +1; |