# -*- cperl -*- # Copyright (c) 2004, 2011, Oracle and/or its affiliates. # Copyright (c) 2009-2011, Monty Program Ab # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; version 2 # of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
# 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;
use My::Platform;
sub mtr_init_args ($);
sub mtr_add_arg ($$@);
sub mtr_args2str($@);
sub mtr_path_exists(@);
sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_exe_maybe_exists(@);
sub mtr_compress_file($);
sub mtr_milli_sleep($);
sub start_timer($);
sub has_expired($);
sub init_timers();
sub mark_time_used($);
sub mark_time_idle();
sub add_total_times($);
sub print_times_used($$);
sub print_total_times($);
# # NOTE! More specific paths should be given before less specific. # For example /client/debug should be listed before /client #
sub mtr_path_exists (@) { foreach my $path ( @_ )
{
return $path if -e $path;
} if ( @_ == 1 )
{
mtr_error("Could not find $_[0]");
} else
{
mtr_error("Could not find any of " . join(" ", @_));
}
}
# # NOTE! More specific paths should be given before less specific. # For example /client/debug should be listed before /client #
sub mtr_script_exists (@) { foreach my $path ( @_ )
{ if(IS_WINDOWS)
{
return $path if -f $path;
} else
{
return $path if -x $path;
}
} if ( @_ == 1 )
{
mtr_error("Could not find $_[0]");
} else
{
mtr_error("Could not find any of " . join(" ", @_));
}
}
# # NOTE! More specific paths should be given before less specific. # For example /client/debug should be listed before /client #
sub mtr_file_exists (@) { foreach my $path ( @_ )
{
return $path if -e $path;
}
return "";
}
# # NOTE! More specific paths should be given before less specific. # For example /client/debug should be listed before /client #
sub mtr_exe_maybe_exists (@) {
my @path= @_;
map {$_.= ".exe"} @path if IS_WINDOWS; foreach my $path ( @path )
{ if(IS_WINDOWS)
{
return $path if -f $path;
} else
{
return $path if -x $path;
}
}
return "";
}
# # NOTE! More specific paths should be given before less specific. #
sub mtr_pl_maybe_exists (@) {
my @path= @_;
map {$_.= ".pl"} @path if IS_WINDOWS; foreach my $path ( @path )
{ if(IS_WINDOWS)
{
return $path if -f $path;
} else
{
return $path if -x $path;
}
}
return "";
}
# # NOTE! More specific paths should be given before less specific. # For example /client/debug should be listed before /client #
sub mtr_exe_exists (@) {
my @path= @_; if (my $path= mtr_exe_maybe_exists(@path))
{
return $path;
} # Could not find exe, show error if ( @path == 1 )
{
mtr_error("Could not find $path[0]");
} else
{
mtr_error("Could not find any of " . join(" ", @path));
}
}
# # Try to compress file using tools that might be available. # If zip/gzip is not available, just silently ignore. #
sub mtr_compress_file ($) {
my ($filename)= @_;
mtr_error ("File to compress not found: $filename") unless -f $filename;
my $did_compress= 0;
if (IS_WINDOWS)
{ # Capture stderr
my $ziperr= `zip $filename.zip $filename 2>&1`; if ($?) {
print "$ziperr\n"if $ziperr !~ /recognized as an internal or external/;
} else {
unlink($filename);
$did_compress=1;
}
} else
{
my $gzres= system("gzip $filename");
$did_compress= ! $gzres; if ($gzres && $gzres != -1) {
mtr_error ("Error: have gzip but it fails to compress core file");
}
}
mtr_print("Compressed file $filename") if $did_compress;
}
sub mtr_milli_sleep ($) {
die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1;
my ($millis)= @_;
select(undef, undef, undef, ($millis/1000));
}
sub mtr_wait_lock_file {
die "usage: mtr_wait_lock_file(path_to_file, keep_alive)" unless @_ == 2;
my ($file, $keep_alive)= @_;
my $waited= 0;
my $msg_counter= $keep_alive;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.