mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Many files:
Perl version of mysql-test-run new file mysql-test/lib/init_db.sql: Perl version of mysql-test-run mysql-test/lib/mtr_gcov.pl: Perl version of mysql-test-run mysql-test/lib/mtr_gprof.pl: Perl version of mysql-test-run mysql-test/lib/mtr_io.pl: Perl version of mysql-test-run mysql-test/lib/mtr_match.pl: Perl version of mysql-test-run mysql-test/lib/mtr_misc.pl: Perl version of mysql-test-run mysql-test/lib/mtr_process.pl: Perl version of mysql-test-run mysql-test/lib/mtr_report.pl: Perl version of mysql-test-run mysql-test/mysql-test-run.pl: Perl version of mysql-test-run
This commit is contained in:
parent
49501611aa
commit
4ad77748b3
9 changed files with 2989 additions and 0 deletions
54
mysql-test/lib/init_db.sql
Normal file
54
mysql-test/lib/init_db.sql
Normal file
File diff suppressed because one or more lines are too long
44
mysql-test/lib/mtr_gcov.pl
Normal file
44
mysql-test/lib/mtr_gcov.pl
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- 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;
|
||||
|
||||
# These are not to be prefixed with "mtr_"
|
||||
|
||||
sub gcov_prepare ();
|
||||
sub gcov_collect ();
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub gcov_prepare () {
|
||||
|
||||
`find $::glob_basedir -name \*.gcov \
|
||||
-or -name \*.da | xargs rm`;
|
||||
}
|
||||
|
||||
sub gcov_collect () {
|
||||
|
||||
print "Collecting source coverage info...\n";
|
||||
-f $::opt_gcov_msg and unlink($::opt_gcov_msg);
|
||||
-f $::opt_gcov_err and unlink($::opt_gcov_err);
|
||||
foreach my $d ( @::mysqld_src_dirs )
|
||||
{
|
||||
chdir("$::glob_basedir/$d");
|
||||
foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) )
|
||||
{
|
||||
`$::opt_gcov $f 2>>$::opt_gcov_err >>$::opt_gcov_msg`;
|
||||
}
|
||||
chdir($::glob_mysql_test_dir);
|
||||
}
|
||||
print "gcov info in $::opt_gcov_msg, errors in $::opt_gcov_err\n";
|
||||
}
|
||||
|
||||
|
||||
1;
|
50
mysql-test/lib/mtr_gprof.pl
Normal file
50
mysql-test/lib/mtr_gprof.pl
Normal file
|
@ -0,0 +1,50 @@
|
|||
# -*- 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;
|
||||
|
||||
# These are not to be prefixed with "mtr_"
|
||||
|
||||
sub gprof_prepare ();
|
||||
sub gprof_collect ();
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub gprof_prepare () {
|
||||
|
||||
rmtree($::opt_gprof_dir);
|
||||
mkdir($::opt_gprof_dir);
|
||||
}
|
||||
|
||||
# FIXME what about master1 and slave1?!
|
||||
sub gprof_collect () {
|
||||
|
||||
if ( -f "$::master->[0]->{'path_myddir'}/gmon.out" )
|
||||
{
|
||||
# FIXME check result code?!
|
||||
mtr_run("gprof",
|
||||
[$::exe_master_mysqld,
|
||||
"$::master->[0]->{'path_myddir'}/gmon.out"],
|
||||
$::opt_gprof_master, "", "", "");
|
||||
print "Master execution profile has been saved in $::opt_gprof_master\n";
|
||||
}
|
||||
if ( -f "$::slave->[0]->{'path_myddir'}/gmon.out" )
|
||||
{
|
||||
# FIXME check result code?!
|
||||
mtr_run("gprof",
|
||||
[$::exe_slave_mysqld,
|
||||
"$::slave->[0]->{'path_myddir'}/gmon.out"],
|
||||
$::opt_gprof_slave, "", "", "");
|
||||
print "Slave execution profile has been saved in $::opt_gprof_slave\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
71
mysql-test/lib/mtr_io.pl
Normal file
71
mysql-test/lib/mtr_io.pl
Normal file
|
@ -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;
|
67
mysql-test/lib/mtr_match.pl
Normal file
67
mysql-test/lib/mtr_match.pl
Normal file
|
@ -0,0 +1,67 @@
|
|||
# -*- 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_match_prefix ($$);
|
||||
sub mtr_match_extension ($$);
|
||||
sub mtr_match_any_exact ($$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Match a prefix and return what is after the prefix
|
||||
|
||||
sub mtr_match_prefix ($$) {
|
||||
my $string= shift;
|
||||
my $prefix= shift;
|
||||
|
||||
if ( $string =~ /^\Q$prefix\E(.*)$/ ) # strncmp
|
||||
{
|
||||
return $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return undef; # NULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Match extension and return the name without extension
|
||||
|
||||
sub mtr_match_extension ($$) {
|
||||
my $file= shift;
|
||||
my $ext= shift;
|
||||
|
||||
if ( $file =~ /^(.*)\.\Q$ext\E$/ ) # strchr+strcmp or something
|
||||
{
|
||||
return $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return undef; # NULL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub mtr_match_any_exact ($$) {
|
||||
my $string= shift;
|
||||
my $mlist= shift;
|
||||
|
||||
foreach my $m (@$mlist)
|
||||
{
|
||||
if ( $string eq $m )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
50
mysql-test/lib/mtr_misc.pl
Normal file
50
mysql-test/lib/mtr_misc.pl
Normal file
|
@ -0,0 +1,50 @@
|
|||
# -*- 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_full_hostname ();
|
||||
sub mtr_init_args ($);
|
||||
sub mtr_add_arg ($$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Misc
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# We want the fully qualified host name and hostname() may have returned
|
||||
# only the short name. So we use the resolver to find out.
|
||||
|
||||
sub mtr_full_hostname () {
|
||||
|
||||
my $hostname= hostname();
|
||||
if ( $hostname !~ /\./ )
|
||||
{
|
||||
my $address= gethostbyname($hostname)
|
||||
or die "Couldn't resolve $hostname : $!";
|
||||
my $fullname= gethostbyaddr($address, AF_INET);
|
||||
$hostname= $fullname if $fullname;
|
||||
}
|
||||
return $hostname;
|
||||
}
|
||||
|
||||
# FIXME move to own lib
|
||||
|
||||
sub mtr_init_args ($) {
|
||||
my $args = shift;
|
||||
$$args = []; # Empty list
|
||||
}
|
||||
|
||||
sub mtr_add_arg ($$) {
|
||||
my $args= shift;
|
||||
my $format= shift;
|
||||
my @fargs = @_;
|
||||
|
||||
push(@$args, sprintf($format, @fargs));
|
||||
}
|
||||
|
||||
1;
|
421
mysql-test/lib/mtr_process.pl
Normal file
421
mysql-test/lib/mtr_process.pl
Normal file
|
@ -0,0 +1,421 @@
|
|||
# -*- 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;
|
||||
|
||||
use POSIX ":sys_wait_h";
|
||||
|
||||
sub mtr_run ($$$$$$);
|
||||
sub mtr_spawn ($$$$$$);
|
||||
sub mtr_stop_servers ($);
|
||||
sub mtr_kill_leftovers ();
|
||||
|
||||
# static in C
|
||||
sub spawn_impl ($$$$$$$);
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Execute an external command
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# This function try to mimic the C version used in "netware/mysql_test_run.c"
|
||||
# FIXME learn it to handle append mode as well, a "new" flag or a "append"
|
||||
|
||||
sub mtr_run ($$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift;
|
||||
|
||||
return spawn_impl($path,$arg_list_t,1,$input,$output,$error,$pid_file);
|
||||
}
|
||||
|
||||
sub mtr_spawn ($$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
my $error= shift;
|
||||
my $pid_file= shift;
|
||||
|
||||
return spawn_impl($path,$arg_list_t,0,$input,$output,$error,$pid_file);
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# If $join is set, we return the error code, else we return the PID
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub spawn_impl ($$$$$$$) {
|
||||
my $path= shift;
|
||||
my $arg_list_t= shift;
|
||||
my $join= shift;
|
||||
my $input= shift;
|
||||
my $output= shift;
|
||||
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 "-" x 78, "\n";
|
||||
print STDERR "STDIN $input\n" if $input;
|
||||
print STDERR "STDOUT $output\n" if $output;
|
||||
print STDERR "STDERR $error\n" if $error;
|
||||
print STDERR "DAEMON\n" if !$join;
|
||||
print STDERR "EXEC $path ", join(" ",@$arg_list_t), "\n";
|
||||
print STDERR "-" x 78, "\n";
|
||||
}
|
||||
|
||||
my $pid= fork();
|
||||
|
||||
if ( $pid )
|
||||
{
|
||||
# Parent, i.e. the main script
|
||||
if ( $join )
|
||||
{
|
||||
# We run a command and wait for the result
|
||||
# FIXME this need to be improved
|
||||
waitpid($pid,0);
|
||||
my $exit_value= $? >> 8;
|
||||
my $signal_num= $? & 127;
|
||||
my $dumped_core= $? & 128;
|
||||
if ( $signal_num )
|
||||
{
|
||||
die("spawn got signal $signal_num");
|
||||
}
|
||||
if ( $dumped_core )
|
||||
{
|
||||
die("spawn dumped core");
|
||||
}
|
||||
return $exit_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
# We spawned a process we don't wait for
|
||||
return $pid;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# Child, redirect output and exec
|
||||
# FIXME I tried POSIX::setsid() here to detach and, I hoped,
|
||||
# avoid zombies. But everything went wild, somehow the parent
|
||||
# became a deamon as well, and was hard to kill ;-)
|
||||
# Need to catch SIGCHLD and do waitpid or something instead......
|
||||
|
||||
$SIG{INT}= 'DEFAULT'; # Parent do some stuff, we don't
|
||||
|
||||
if ( $output )
|
||||
{
|
||||
open(STDOUT,">",$output) or die "Can't redirect STDOUT to \"$output\": $!";
|
||||
}
|
||||
if ( $error )
|
||||
{
|
||||
if ( $output eq $error )
|
||||
{
|
||||
open(STDERR,">&STDOUT") or die "Can't dup STDOUT: $!";
|
||||
}
|
||||
else
|
||||
{
|
||||
open(STDERR,">",$error) or die "Can't redirect STDERR to \"$output\": $!";
|
||||
}
|
||||
}
|
||||
if ( $input )
|
||||
{
|
||||
open(STDIN,"<",$input) or die "Can't redirect STDIN to \"$input\": $!";
|
||||
}
|
||||
exec($path,@$arg_list_t);
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Kill processes left from previous runs
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_kill_leftovers () {
|
||||
|
||||
# First, kill all masters and slaves that would conflict with
|
||||
# this run. Make sure to remove the PID file, if any.
|
||||
|
||||
my @args;
|
||||
|
||||
for ( my $idx; $idx < 2; $idx++ )
|
||||
{
|
||||
# if ( $::master->[$idx]->{'pid'} )
|
||||
# {
|
||||
push(@args,
|
||||
$::master->[$idx]->{'path_mypid'},
|
||||
$::master->[$idx]->{'path_mysock'},
|
||||
);
|
||||
# }
|
||||
}
|
||||
|
||||
for ( my $idx; $idx < 3; $idx++ )
|
||||
{
|
||||
# if ( $::slave->[$idx]->{'pid'} )
|
||||
# {
|
||||
push(@args,
|
||||
$::slave->[$idx]->{'path_mypid'},
|
||||
$::slave->[$idx]->{'path_mysock'},
|
||||
);
|
||||
# }
|
||||
}
|
||||
|
||||
mtr_stop_servers(\@args);
|
||||
|
||||
# We scan the "var/run/" directory for other process id's to kill
|
||||
my $rundir= "$::glob_mysql_test_dir/var/run"; # FIXME $path_run_dir or something
|
||||
|
||||
if ( -d $rundir )
|
||||
{
|
||||
opendir(RUNDIR, $rundir)
|
||||
or mtr_error("can't open directory \"$rundir\": $!");
|
||||
|
||||
my @pids;
|
||||
|
||||
while ( my $elem= readdir(RUNDIR) )
|
||||
{
|
||||
my $pidfile= "$rundir/$elem";
|
||||
|
||||
if ( -f $pidfile )
|
||||
{
|
||||
my $pid= mtr_get_pid_from_file($pidfile);
|
||||
if ( ! unlink($pidfile) )
|
||||
{
|
||||
mtr_error("can't remove $pidfile");
|
||||
}
|
||||
push(@pids, $pid);
|
||||
}
|
||||
}
|
||||
closedir(RUNDIR);
|
||||
|
||||
my $retries= 10; # 10 seconds
|
||||
do
|
||||
{
|
||||
kill(9, @pids);
|
||||
} while ( $retries-- and kill(0, @pids) );
|
||||
|
||||
if ( kill(0, @pids) )
|
||||
{
|
||||
mtr_error("can't kill processes " . join(" ", @pids));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Shut down mysqld servers
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# To speed things we kill servers in parallel.
|
||||
# The argument is a list of 'pidfiles' and 'socketfiles'.
|
||||
# We use the pidfiles and socketfiles to try to terminate the servers.
|
||||
# This is not perfect, there could still be other server processes
|
||||
# left.
|
||||
|
||||
sub mtr_stop_servers ($) {
|
||||
my $spec= shift;
|
||||
|
||||
# First try nice normal shutdown using 'mysqladmin'
|
||||
|
||||
{
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args; # FIXME not used here....
|
||||
my $sockfile= shift @args;
|
||||
|
||||
if ( -f $sockfile )
|
||||
{
|
||||
|
||||
# FIXME wrong log.....
|
||||
# FIXME, stderr.....
|
||||
# Shutdown time must be high as slave may be in reconnect
|
||||
my $opts=
|
||||
[
|
||||
"--no-defaults",
|
||||
"-uroot",
|
||||
"--socket=$sockfile",
|
||||
"--connect_timeout=5",
|
||||
"--shutdown_timeout=70",
|
||||
"shutdown",
|
||||
];
|
||||
# We don't wait for termination of mysqladmin
|
||||
mtr_spawn($::exe_mysqladmin, $opts,
|
||||
"", $::path_manager_log, $::path_manager_log, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Wait for them all to remove their socket file
|
||||
|
||||
SOCKREMOVED:
|
||||
for (my $loop= $::opt_sleep_time_for_delete; $loop; $loop--)
|
||||
{
|
||||
my $sockfiles_left= 0;
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if ( -f $sockfile or -f $pidfile )
|
||||
{
|
||||
$sockfiles_left++; # Could be that pidfile is left
|
||||
}
|
||||
}
|
||||
if ( ! $sockfiles_left )
|
||||
{
|
||||
last SOCKREMOVED;
|
||||
}
|
||||
if ( $loop > 1 )
|
||||
{
|
||||
sleep(1); # One second
|
||||
}
|
||||
}
|
||||
|
||||
# We may have killed all that left a socket, but we are not sure we got
|
||||
# them all killed. We now check the PID file, if any
|
||||
|
||||
# Try nice kill with SIG_TERM
|
||||
|
||||
{
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if (-f $pidfile)
|
||||
{
|
||||
my $pid= mtr_get_pid_from_file($pidfile);
|
||||
mtr_warning("process $pid not cooperating with mysqladmin, " .
|
||||
"will send TERM signal to process");
|
||||
kill(15,$pid); # SIG_TERM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Wait for them all to die
|
||||
|
||||
for (my $loop= $::opt_sleep_time_for_delete; $loop; $loop--)
|
||||
{
|
||||
my $pidfiles_left= 0;
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if ( -f $pidfile )
|
||||
{
|
||||
$pidfiles_left++;
|
||||
}
|
||||
}
|
||||
if ( ! $pidfiles_left )
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( $loop > 1 )
|
||||
{
|
||||
sleep(1); # One second
|
||||
}
|
||||
}
|
||||
|
||||
# Try hard kill with SIG_KILL
|
||||
|
||||
{
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if (-f $pidfile)
|
||||
{
|
||||
my $pid= mtr_get_pid_from_file($pidfile);
|
||||
mtr_warning("$pid did not die from TERM signal, ",
|
||||
"will send KILL signal to process");
|
||||
kill(9,$pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# We check with Perl "kill 0" if process still exists
|
||||
|
||||
PIDFILES:
|
||||
for (my $loop= $::opt_sleep_time_for_delete; $loop; $loop--)
|
||||
{
|
||||
my $not_terminated= 0;
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if (-f $pidfile)
|
||||
{
|
||||
my $pid= mtr_get_pid_from_file($pidfile);
|
||||
if ( ! kill(0,$pid) )
|
||||
{
|
||||
$not_terminated++;
|
||||
mtr_warning("could't kill $pid");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! $not_terminated )
|
||||
{
|
||||
last PIDFILES;
|
||||
}
|
||||
if ( $loop > 1 )
|
||||
{
|
||||
sleep(1); # One second
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $pidfiles_left= 0;
|
||||
my @args= @$spec;
|
||||
while ( @args )
|
||||
{
|
||||
my $pidfile= shift @args;
|
||||
my $sockfile= shift @args;
|
||||
if ( -f $pidfile )
|
||||
{
|
||||
if ( ! unlink($pidfile) )
|
||||
{
|
||||
$pidfiles_left++;
|
||||
mtr_warning("could't delete $pidfile");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $pidfiles_left )
|
||||
{
|
||||
mtr_error("one or more pid files could not be deleted");
|
||||
}
|
||||
}
|
||||
|
||||
# FIXME We just assume they are all dead, we don't know....
|
||||
}
|
||||
|
||||
|
||||
1;
|
257
mysql-test/lib/mtr_report.pl
Normal file
257
mysql-test/lib/mtr_report.pl
Normal file
|
@ -0,0 +1,257 @@
|
|||
# -*- 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_report_test_name($);
|
||||
sub mtr_report_test_passed($);
|
||||
sub mtr_report_test_failed($);
|
||||
sub mtr_report_test_skipped($);
|
||||
|
||||
sub mtr_show_failed_diff ($);
|
||||
sub mtr_report_stats ($);
|
||||
sub mtr_print_line ();
|
||||
sub mtr_print_header ();
|
||||
sub mtr_report (@);
|
||||
sub mtr_warning (@);
|
||||
sub mtr_error (@);
|
||||
sub mtr_debug (@);
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# We can't use diff -u or diff -a as these are not portable
|
||||
|
||||
sub mtr_show_failed_diff ($) {
|
||||
my $tname= shift;
|
||||
|
||||
my $reject_file= "r/$tname.reject";
|
||||
my $result_file= "r/$tname.result";
|
||||
my $eval_file= "r/$tname.eval";
|
||||
|
||||
if ( -f $eval_file )
|
||||
{
|
||||
$result_file= $eval_file;
|
||||
}
|
||||
elsif ( $::opt_result_ext and
|
||||
( $::opt_record or -f "$result_file$::opt_result_ext" ))
|
||||
{
|
||||
# If we have an special externsion for result files we use it if we are
|
||||
# recording or a result file with that extension exists.
|
||||
$result_file= "$result_file$::opt_result_ext";
|
||||
}
|
||||
|
||||
if ( -f $reject_file )
|
||||
{
|
||||
print "Below are the diffs between actual and expected results:\n";
|
||||
print "-------------------------------------------------------\n";
|
||||
# FIXME check result code?!
|
||||
mtr_run("diff",["-c",$result_file,$reject_file], "", "", "", "");
|
||||
print "-------------------------------------------------------\n";
|
||||
print "Please follow the instructions outlined at\n";
|
||||
print "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html\n";
|
||||
print "to find the reason to this problem and how to report this.\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub mtr_report_test_name ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
printf "%-31s ", $tinfo->{'name'};
|
||||
}
|
||||
|
||||
sub mtr_report_test_skipped ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
$tinfo->{'result'}= 'MTR_RES_SKIPPED';
|
||||
print "[ skipped ]\n";
|
||||
}
|
||||
|
||||
sub mtr_report_test_passed ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
my $timer= "";
|
||||
# FIXME
|
||||
# if ( $::opt_timer and -f "$::glob_mysql_test_dir/var/log/timer" )
|
||||
# {
|
||||
# $timer= `cat var/log/timer`;
|
||||
# $timer= sprintf "%13s", $timer;
|
||||
# }
|
||||
$tinfo->{'result'}= 'MTR_RES_PASSED';
|
||||
print "[ pass ] $timer\n";
|
||||
}
|
||||
|
||||
sub mtr_report_test_failed ($) {
|
||||
my $tinfo= shift;
|
||||
|
||||
$tinfo->{'result'}= 'MTR_RES_FAILED';
|
||||
print "[ fail ]\n";
|
||||
|
||||
print "Errors are (from $::path_timefile) :\n";
|
||||
print mtr_fromfile($::path_timefile); # FIXME print_file() instead
|
||||
print "\n(the last lines may be the most important ones)\n";
|
||||
}
|
||||
|
||||
sub mtr_report_stats ($) {
|
||||
my $tests= shift;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Find out how we where doing
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
my $tot_skiped= 0;
|
||||
my $tot_passed= 0;
|
||||
my $tot_failed= 0;
|
||||
my $tot_tests= 0;
|
||||
|
||||
foreach my $tinfo (@$tests)
|
||||
{
|
||||
if ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
|
||||
{
|
||||
$tot_skiped++;
|
||||
}
|
||||
elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
|
||||
{
|
||||
$tot_tests++;
|
||||
$tot_passed++;
|
||||
}
|
||||
elsif ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
|
||||
{
|
||||
$tot_tests++;
|
||||
$tot_failed++;
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Print out a summary report to screen
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( ! $tot_failed )
|
||||
{
|
||||
print "All $tot_tests tests were successful.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
my $ratio= $tot_passed * 100 / $tot_tests;
|
||||
printf "Failed $tot_failed/$tot_tests tests, " .
|
||||
"%.2f\% successful.\n\n", $ratio;
|
||||
print
|
||||
"The log files in var/log may give you some hint\n",
|
||||
"of what when wrong.\n",
|
||||
"If you want to report this error, please read first ",
|
||||
"the documentation at\n",
|
||||
"http://www.mysql.com/doc/en/MySQL_test_suite.html\n";
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
if ( ! $::glob_use_running_server )
|
||||
{
|
||||
|
||||
# Report if there was any fatal warnings/errors in the log files
|
||||
#
|
||||
unlink("$::glob_mysql_test_dir/var/log/warnings");
|
||||
unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
|
||||
# Remove some non fatal warnings from the log files
|
||||
|
||||
# FIXME what is going on ????? ;-)
|
||||
# sed -e 's!Warning: Table:.* on delete!!g' -e 's!Warning: Setting lower_case_table_names=2!!g' -e 's!Warning: One can only use the --user.*root!!g' \
|
||||
# var/log/*.err \
|
||||
# | sed -e 's!Warning: Table:.* on rename!!g' \
|
||||
# > var/log/warnings.tmp;
|
||||
#
|
||||
# found_error=0;
|
||||
# # Find errors
|
||||
# for i in "^Warning:" "^Error:" "^==.* at 0x"
|
||||
# do
|
||||
# if ( $GREP "$i" var/log/warnings.tmp >> var/log/warnings )
|
||||
# {
|
||||
# found_error=1
|
||||
# }
|
||||
# done
|
||||
# unlink("$::glob_mysql_test_dir/var/log/warnings.tmp");
|
||||
# if ( $found_error= "1" )
|
||||
# {
|
||||
# print "WARNING: Got errors/warnings while running tests. Please examine\n"
|
||||
# print "$::glob_mysql_test_dir/var/log/warnings for details.\n"
|
||||
# }
|
||||
# }
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
if ( $tot_failed != 0 )
|
||||
{
|
||||
print "mysql-test-run: *** Failing the test(s):";
|
||||
|
||||
foreach my $tinfo (@$tests)
|
||||
{
|
||||
if ( $tinfo->{'result'} eq 'MTR_RES_FAILED' )
|
||||
{
|
||||
print " $tinfo->{'name'}";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
mtr_error("there where failing test cases");
|
||||
}
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Text formatting
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_print_line () {
|
||||
print '-' x 55, "\n";
|
||||
}
|
||||
|
||||
sub mtr_print_header () {
|
||||
print "\n";
|
||||
if ( $::opt_timer )
|
||||
{
|
||||
print "TEST RESULT TIME (ms)\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "TEST RESULT\n";
|
||||
}
|
||||
mtr_print_line();
|
||||
print "\n";
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Misc
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
sub mtr_report (@) {
|
||||
print join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_warning (@) {
|
||||
print STDERR "mysql-test-run: WARNING: ",join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_error (@) {
|
||||
die "mysql-test-run: *** ERROR: ",join(" ", @_),"\n";
|
||||
}
|
||||
|
||||
sub mtr_debug (@) {
|
||||
if ( $::opt_script_debug )
|
||||
{
|
||||
print "mysql-test-run: DEBUG: ",join(" ", @_),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
1975
mysql-test/mysql-test-run.pl
Executable file
1975
mysql-test/mysql-test-run.pl
Executable file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue