2004-12-30 16:34:01 +01:00
|
|
|
# -*- cperl -*-
|
2009-01-08 20:03:56 +01:00
|
|
|
# Copyright 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc.
|
2006-12-31 01:02:27 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU 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 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-1301 USA
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
package mtr_report;
|
2004-12-30 16:34:01 +01:00
|
|
|
use strict;
|
2008-02-04 11:16:25 +01:00
|
|
|
|
|
|
|
use base qw(Exporter);
|
|
|
|
our @EXPORT= qw(report_option mtr_print_line mtr_print_thick_line
|
|
|
|
mtr_print_header mtr_report mtr_report_stats
|
|
|
|
mtr_warning mtr_error mtr_debug mtr_verbose
|
|
|
|
mtr_verbose_restart mtr_report_test_passed
|
2008-05-05 22:55:47 +02:00
|
|
|
mtr_report_test_skipped mtr_print
|
2008-04-25 08:23:57 +02:00
|
|
|
mtr_report_test);
|
2008-02-04 11:16:25 +01:00
|
|
|
|
2008-04-08 16:51:26 +02:00
|
|
|
use mtr_match;
|
Bug #42804 --parallel option does not work for MTR under ActiveState
perl
The problem here was the method how MTR gets its unique thread ids.
Prior to this patch, the method to do it was to maintain a global
table of pid,mtr_unique_id) pairs. The table was backed by a text
file. The table was cleaned up one in a while and dead processes leaking
unique_ids were determined with with kill(0) or with scripting tasklist
on Windows.
This method is flawed specifically on native Windows Perl. fork() is
implemented with starting a new thread, give it a syntetic negative PID
(threadID*(-1)), until this thread creates a new process with exec()
However, neither tasklist nor any other native Windows tool can cope with
negative perl PIDs. This lead to incorrect determination of dead process
and reusing already used mtr_unique_id.
The patch introduces alternative portable method of solving unique-id
problem. When a process needs a unique id in range [min...max], it just
starts to open files named min, min+1,...max in a loop . After file is
opened, we do non-blocking flock(). When flock() succeeds, process has
allocated the ID. When process dies, file is unlocked . Checks for zombies
are not necessary.
Since the change would create a co-existence problems with older version
of MTR, because of different way to calculate IDs, the default ID range
is changed from 250-299 to 300-349.
Another fix that was necessary enable --parallel option was to serialize
spawn() calls on Windows. specifically, IO redirects needed to be protected.
This patch also fixes hanging CRTL-C (as described in Bug #38629) for the
"new" MTR. The fix was already in 6.0 and is now downported.
2009-04-23 13:35:02 +02:00
|
|
|
use My::Platform;
|
|
|
|
use POSIX qw[ _exit ];
|
2008-02-04 11:16:25 +01:00
|
|
|
require "mtr_io.pl";
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-08-03 12:50:00 +02:00
|
|
|
my $tot_real_time= 0;
|
|
|
|
|
2008-06-19 11:20:45 +02:00
|
|
|
our $timestamp= 0;
|
2008-05-04 21:43:49 +02:00
|
|
|
our $timediff= 0;
|
2008-04-24 13:02:53 +02:00
|
|
|
our $name;
|
|
|
|
our $verbose;
|
|
|
|
our $verbose_restart= 0;
|
2008-05-04 21:40:40 +02:00
|
|
|
our $timer= 1;
|
2007-08-03 12:50:00 +02:00
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
sub report_option {
|
|
|
|
my ($opt, $value)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2009-01-21 11:17:16 +01:00
|
|
|
# Evaluate $opt as string to use "Getopt::Long::Callback legacy API"
|
|
|
|
my $opt_name = "$opt";
|
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
# Convert - to _ in option name
|
2009-01-21 11:17:16 +01:00
|
|
|
$opt_name =~ s/-/_/g;
|
2008-02-04 11:16:25 +01:00
|
|
|
no strict 'refs';
|
2009-01-21 11:17:16 +01:00
|
|
|
${$opt_name}= $value;
|
2008-02-04 11:16:25 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2008-05-09 11:50:36 +02:00
|
|
|
sub _name {
|
|
|
|
return $name ? $name." " : undef;
|
|
|
|
}
|
2008-02-04 11:16:25 +01:00
|
|
|
|
|
|
|
sub _mtr_report_test_name ($) {
|
2004-12-30 16:34:01 +01:00
|
|
|
my $tinfo= shift;
|
2007-11-23 13:29:31 +01:00
|
|
|
my $tname= $tinfo->{name};
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2008-04-24 13:02:53 +02:00
|
|
|
return unless defined $verbose;
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Add combination name if any
|
2007-11-23 13:29:31 +01:00
|
|
|
$tname.= " '$tinfo->{combination}'"
|
|
|
|
if defined $tinfo->{combination};
|
|
|
|
|
2008-05-09 11:50:36 +02:00
|
|
|
print _name(), _timestamp();
|
2008-05-04 23:22:41 +02:00
|
|
|
printf "%-40s ", $tname;
|
2009-05-28 13:02:03 +02:00
|
|
|
my $worker = $tinfo->{worker};
|
|
|
|
printf "w$worker " if $worker;
|
2009-02-24 12:53:34 +01:00
|
|
|
|
|
|
|
return $tname;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_report_test_skipped ($) {
|
2008-05-04 23:22:41 +02:00
|
|
|
my ($tinfo)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
$tinfo->{'result'}= 'MTR_RES_SKIPPED';
|
2008-05-04 23:22:41 +02:00
|
|
|
|
|
|
|
mtr_report_test($tinfo);
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-04 21:40:40 +02:00
|
|
|
sub mtr_report_test_passed ($) {
|
|
|
|
my ($tinfo)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2008-05-04 23:22:41 +02:00
|
|
|
# Save the timer value
|
2008-05-04 21:40:40 +02:00
|
|
|
my $timer_str= "";
|
|
|
|
if ( $timer and -f "$::opt_vardir/log/timer" )
|
2005-03-21 16:01:39 +01:00
|
|
|
{
|
2008-05-04 21:40:40 +02:00
|
|
|
$timer_str= mtr_fromfile("$::opt_vardir/log/timer");
|
|
|
|
$tinfo->{timer}= $timer_str;
|
2005-03-21 16:01:39 +01:00
|
|
|
}
|
2008-05-04 23:22:41 +02:00
|
|
|
|
2009-01-24 13:02:27 +01:00
|
|
|
# Big warning if status already set
|
|
|
|
if ( $tinfo->{'result'} ){
|
|
|
|
mtr_warning("mtr_report_test_passed: Test result",
|
|
|
|
"already set to '", $tinfo->{'result'}, ",");
|
2008-01-10 10:44:18 +01:00
|
|
|
}
|
2008-05-04 21:40:40 +02:00
|
|
|
|
2009-01-24 13:02:27 +01:00
|
|
|
$tinfo->{'result'}= 'MTR_RES_PASSED';
|
|
|
|
|
2008-05-04 23:22:41 +02:00
|
|
|
mtr_report_test($tinfo);
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2008-04-24 13:02:53 +02:00
|
|
|
sub mtr_report_test ($) {
|
|
|
|
my ($tinfo)= @_;
|
2009-02-24 12:53:34 +01:00
|
|
|
my $test_name = _mtr_report_test_name($tinfo);
|
2008-04-24 13:02:53 +02:00
|
|
|
|
2009-02-25 15:00:17 +01:00
|
|
|
my $comment= $tinfo->{'comment'};
|
|
|
|
my $logfile= $tinfo->{'logfile'};
|
|
|
|
my $warnings= $tinfo->{'warnings'};
|
|
|
|
my $result= $tinfo->{'result'};
|
2009-03-09 12:59:34 +01:00
|
|
|
my $retry= $tinfo->{'retries'} ? "retry-" : "";
|
2008-04-24 13:02:53 +02:00
|
|
|
|
2008-08-04 21:54:44 +02:00
|
|
|
if ($result eq 'MTR_RES_FAILED'){
|
|
|
|
|
2008-12-03 14:11:03 +01:00
|
|
|
my $timest = format_time();
|
2009-02-24 12:53:34 +01:00
|
|
|
my $fail = "fail";
|
|
|
|
|
|
|
|
if ( $::opt_experimental )
|
|
|
|
{
|
|
|
|
# Find out if this test case is an experimental one, so we can treat
|
|
|
|
# the failure as an expected failure instead of a regression.
|
2009-02-25 15:00:17 +01:00
|
|
|
for my $exp ( @$::experimental_test_cases ) {
|
2009-02-24 12:53:34 +01:00
|
|
|
if ( $exp ne $test_name ) {
|
2009-02-25 15:00:17 +01:00
|
|
|
# if the expression is not the name of this test case, but has
|
|
|
|
# an asterisk at the end, determine if the characters up to
|
|
|
|
# but excluding the asterisk are the same
|
2009-02-24 12:53:34 +01:00
|
|
|
if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) {
|
2009-09-03 08:19:54 +02:00
|
|
|
my $nexp = substr($exp, 0, length($exp) - 1);
|
|
|
|
if ( substr($test_name, 0, length($nexp)) ne $nexp ) {
|
2009-02-25 15:00:17 +01:00
|
|
|
# no match, try next entry
|
2009-02-24 12:53:34 +01:00
|
|
|
next;
|
|
|
|
}
|
2009-02-25 15:00:17 +01:00
|
|
|
# if yes, fall through to set the exp-fail status
|
2009-02-24 12:53:34 +01:00
|
|
|
} else {
|
2009-02-25 15:00:17 +01:00
|
|
|
# no match, try next entry
|
2009-02-24 12:53:34 +01:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fail = "exp-fail";
|
2009-10-17 18:34:56 +02:00
|
|
|
$tinfo->{exp_fail}= 1;
|
2009-02-24 12:53:34 +01:00
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2008-12-03 14:11:03 +01:00
|
|
|
|
2008-08-04 21:54:44 +02:00
|
|
|
if ( $warnings )
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
2009-03-09 12:59:34 +01:00
|
|
|
mtr_report("[ $retry$fail ] Found warnings/errors in server log file!");
|
2008-12-03 14:11:03 +01:00
|
|
|
mtr_report(" Test ended at $timest");
|
2008-08-04 21:54:44 +02:00
|
|
|
mtr_report($warnings);
|
2008-04-24 13:02:53 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-08-04 21:54:44 +02:00
|
|
|
my $timeout= $tinfo->{'timeout'};
|
|
|
|
if ( $timeout )
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
2009-03-09 12:59:34 +01:00
|
|
|
mtr_report("[ $retry$fail ] timeout after $timeout seconds");
|
2008-12-03 14:11:03 +01:00
|
|
|
mtr_report(" Test ended at $timest");
|
2008-08-04 21:54:44 +02:00
|
|
|
mtr_report("\n$tinfo->{'comment'}");
|
2008-04-24 13:02:53 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-09 12:59:34 +01:00
|
|
|
mtr_report("[ $retry$fail ]\n Test ended at $timest");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
|
2008-08-04 21:54:44 +02:00
|
|
|
if ( $logfile )
|
|
|
|
{
|
|
|
|
# Test failure was detected by test tool and its report
|
|
|
|
# about what failed has been saved to file. Display the report.
|
|
|
|
mtr_report("\n$logfile\n");
|
|
|
|
}
|
|
|
|
if ( $comment )
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
|
|
|
# The test failure has been detected by mysql-test-run.pl
|
|
|
|
# when starting the servers or due to other error, the reason for
|
|
|
|
# failing the test is saved in "comment"
|
2008-08-04 21:54:44 +02:00
|
|
|
mtr_report("\n$comment\n");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
|
2008-08-04 21:54:44 +02:00
|
|
|
if ( !$logfile and !$comment )
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
|
|
|
# Neither this script or the test tool has recorded info
|
|
|
|
# about why the test has failed. Should be debugged.
|
2008-08-04 21:54:44 +02:00
|
|
|
mtr_report("\nUnknown result, neither 'comment' or 'logfile' set");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-04 21:54:44 +02:00
|
|
|
elsif ($result eq 'MTR_RES_SKIPPED')
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
|
|
|
if ( $tinfo->{'disable'} )
|
|
|
|
{
|
2008-08-04 21:54:44 +02:00
|
|
|
mtr_report("[ disabled ] $comment");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
2008-08-04 21:54:44 +02:00
|
|
|
elsif ( $comment )
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
2009-02-02 11:26:19 +01:00
|
|
|
mtr_report("[ skipped ] $comment");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-02 11:26:19 +01:00
|
|
|
mtr_report("[ skipped ]");
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-04 21:54:44 +02:00
|
|
|
elsif ($result eq 'MTR_RES_PASSED')
|
2008-04-24 13:02:53 +02:00
|
|
|
{
|
2008-05-04 21:40:40 +02:00
|
|
|
my $timer_str= $tinfo->{timer} || "";
|
|
|
|
$tot_real_time += ($timer_str/1000);
|
2009-03-09 12:59:34 +01:00
|
|
|
mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str));
|
2008-04-27 21:31:32 +02:00
|
|
|
|
|
|
|
# Show any problems check-testcase found
|
|
|
|
if ( defined $tinfo->{'check'} )
|
|
|
|
{
|
|
|
|
mtr_report($tinfo->{'check'});
|
|
|
|
}
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-02 10:00:45 +02:00
|
|
|
sub mtr_report_stats ($;$) {
|
|
|
|
my ($tests, $dont_error)= @_;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Find out how we where doing
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
my $tot_skiped= 0;
|
|
|
|
my $tot_passed= 0;
|
|
|
|
my $tot_failed= 0;
|
|
|
|
my $tot_tests= 0;
|
2006-10-04 12:47:32 +02:00
|
|
|
my $tot_restarts= 0;
|
2008-04-08 16:51:26 +02:00
|
|
|
my $found_problems= 0;
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
foreach my $tinfo (@$tests)
|
|
|
|
{
|
2008-05-04 21:21:11 +02:00
|
|
|
if ( $tinfo->{failures} )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2008-05-04 21:21:11 +02:00
|
|
|
# Test has failed at least one time
|
|
|
|
$tot_tests++;
|
|
|
|
$tot_failed++;
|
|
|
|
}
|
|
|
|
elsif ( $tinfo->{'result'} eq 'MTR_RES_SKIPPED' )
|
|
|
|
{
|
|
|
|
# Test was skipped
|
2004-12-30 16:34:01 +01:00
|
|
|
$tot_skiped++;
|
|
|
|
}
|
|
|
|
elsif ( $tinfo->{'result'} eq 'MTR_RES_PASSED' )
|
|
|
|
{
|
2008-05-04 21:21:11 +02:00
|
|
|
# Test passed
|
2004-12-30 16:34:01 +01:00
|
|
|
$tot_tests++;
|
|
|
|
$tot_passed++;
|
|
|
|
}
|
2008-05-04 21:21:11 +02:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
if ( $tinfo->{'restarted'} )
|
|
|
|
{
|
2008-05-04 21:21:11 +02:00
|
|
|
# Servers was restarted
|
2006-10-04 12:47:32 +02:00
|
|
|
$tot_restarts++;
|
|
|
|
}
|
2008-04-08 16:51:26 +02:00
|
|
|
|
2009-04-01 13:58:30 +02:00
|
|
|
# Add counts for repeated runs, if any.
|
|
|
|
# Note that the last run has already been counted above.
|
|
|
|
my $num_repeat = $tinfo->{'repeat'} - 1;
|
|
|
|
if ( $num_repeat > 0 )
|
|
|
|
{
|
|
|
|
$tot_tests += $num_repeat;
|
|
|
|
my $rep_failed = $tinfo->{'rep_failures'} || 0;
|
|
|
|
$tot_failed += $rep_failed;
|
|
|
|
$tot_passed += $num_repeat - $rep_failed;
|
|
|
|
}
|
|
|
|
|
2008-04-08 16:51:26 +02:00
|
|
|
# Look for warnings produced by mysqltest
|
|
|
|
my $base_file= mtr_match_extension($tinfo->{'result_file'},
|
|
|
|
"result"); # Trim extension
|
|
|
|
my $warning_file= "$base_file.warnings";
|
|
|
|
if ( -f $warning_file )
|
|
|
|
{
|
|
|
|
$found_problems= 1;
|
|
|
|
mtr_warning("Check myqltest warnings in '$warning_file'");
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Print out a summary report to screen
|
|
|
|
# ----------------------------------------------------------------------
|
2007-12-12 18:19:24 +01:00
|
|
|
print "The servers were restarted $tot_restarts times\n";
|
2006-10-04 12:47:32 +02:00
|
|
|
|
2008-05-04 21:40:40 +02:00
|
|
|
if ( $timer )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2007-08-03 12:50:00 +02:00
|
|
|
use English;
|
|
|
|
|
|
|
|
mtr_report("Spent", sprintf("%.3f", $tot_real_time),"of",
|
|
|
|
time - $BASETIME, "seconds executing testcases");
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
|
2008-04-08 16:51:26 +02:00
|
|
|
my $warnlog= "$::opt_vardir/log/warnings";
|
|
|
|
if ( -f $warnlog )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2008-04-08 16:51:26 +02:00
|
|
|
mtr_warning("Got errors/warnings while running tests, please examine",
|
|
|
|
"'$warnlog' for details.");
|
2009-01-23 13:22:05 +01:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
|
|
|
print "\n";
|
|
|
|
|
2006-10-08 17:48:01 +02:00
|
|
|
# Print a list of check_testcases that failed(if any)
|
|
|
|
if ( $::opt_check_testcases )
|
|
|
|
{
|
2008-04-24 14:15:15 +02:00
|
|
|
my %check_testcases;
|
2006-10-08 17:48:01 +02:00
|
|
|
|
|
|
|
foreach my $tinfo (@$tests)
|
|
|
|
{
|
|
|
|
if ( defined $tinfo->{'check_testcase_failed'} )
|
|
|
|
{
|
2008-04-24 14:15:15 +02:00
|
|
|
$check_testcases{$tinfo->{'name'}}= 1;
|
2006-10-08 17:48:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 14:15:15 +02:00
|
|
|
if ( keys %check_testcases )
|
2006-10-08 17:48:01 +02:00
|
|
|
{
|
|
|
|
print "Check of testcase failed for: ";
|
2008-04-24 14:15:15 +02:00
|
|
|
print join(" ", keys %check_testcases);
|
2006-10-08 17:48:01 +02:00
|
|
|
print "\n\n";
|
|
|
|
}
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
2006-10-08 17:48:01 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
# Print a list of testcases that failed
|
|
|
|
if ( $tot_failed != 0 )
|
|
|
|
{
|
2008-05-02 12:11:04 +02:00
|
|
|
|
|
|
|
# Print each failed test, again
|
|
|
|
#foreach my $test ( @$tests ){
|
2008-05-04 21:21:11 +02:00
|
|
|
# if ( $test->{failures} ) {
|
2008-05-02 12:11:04 +02:00
|
|
|
# mtr_report_test($test);
|
|
|
|
# }
|
|
|
|
#}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $ratio= $tot_passed * 100 / $tot_tests;
|
|
|
|
print "Failed $tot_failed/$tot_tests tests, ";
|
|
|
|
printf("%.2f", $ratio);
|
|
|
|
print "\% were successful.\n\n";
|
|
|
|
|
|
|
|
# Print the list of test that failed in a format
|
|
|
|
# that can be copy pasted to rerun only failing tests
|
|
|
|
print "Failing test(s):";
|
|
|
|
|
2008-03-26 07:22:42 +01:00
|
|
|
my %seen= ();
|
2007-12-12 18:19:24 +01:00
|
|
|
foreach my $tinfo (@$tests)
|
|
|
|
{
|
2008-03-26 07:22:42 +01:00
|
|
|
my $tname= $tinfo->{'name'};
|
2009-04-01 13:58:30 +02:00
|
|
|
if ( ($tinfo->{failures} || $tinfo->{rep_failures}) and ! $seen{$tname})
|
2007-12-12 18:19:24 +01:00
|
|
|
{
|
2008-03-26 07:22:42 +01:00
|
|
|
print " $tname";
|
|
|
|
$seen{$tname}= 1;
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print "\n\n";
|
|
|
|
|
|
|
|
# Print info about reporting the error
|
|
|
|
print
|
|
|
|
"The log files in var/log may give you some hint of what went wrong.\n\n",
|
|
|
|
"If you want to report this error, please read first ",
|
|
|
|
"the documentation\n",
|
|
|
|
"at http://dev.mysql.com/doc/mysql/en/mysql-test-suite.html\n\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-04 21:40:40 +02:00
|
|
|
print "All $tot_tests tests were successful.\n\n";
|
2007-12-12 18:19:24 +01:00
|
|
|
}
|
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
if ( $tot_failed != 0 || $found_problems)
|
|
|
|
{
|
2009-06-02 10:00:45 +02:00
|
|
|
mtr_error("there were failing test cases") unless $dont_error;
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Text formatting
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
sub mtr_print_line () {
|
2007-12-12 18:19:24 +01:00
|
|
|
print '-' x 60, "\n";
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
sub mtr_print_thick_line {
|
2007-12-12 18:19:24 +01:00
|
|
|
my $char= shift || '=';
|
2009-02-01 14:14:39 +01:00
|
|
|
print $char x 78, "\n";
|
2005-01-03 16:54:08 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_print_header () {
|
|
|
|
print "\n";
|
2008-05-04 23:22:41 +02:00
|
|
|
printf "TEST";
|
|
|
|
print " " x 38;
|
|
|
|
print "RESULT ";
|
|
|
|
print "TIME (ms)" if $timer;
|
|
|
|
print "\n";
|
2004-12-30 16:34:01 +01:00
|
|
|
mtr_print_line();
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
2007-08-03 12:36:32 +02:00
|
|
|
# Log and reporting functions
|
2004-12-30 16:34:01 +01:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
use Time::localtime;
|
2007-08-03 12:36:32 +02:00
|
|
|
|
2008-04-24 14:15:15 +02:00
|
|
|
use Time::HiRes qw(gettimeofday);
|
|
|
|
|
2008-12-03 14:11:03 +01:00
|
|
|
sub format_time {
|
|
|
|
my $tm= localtime();
|
|
|
|
return sprintf("%4d-%02d-%02d %02d:%02d:%02d",
|
|
|
|
$tm->year + 1900, $tm->mon+1, $tm->mday,
|
|
|
|
$tm->hour, $tm->min, $tm->sec);
|
|
|
|
}
|
|
|
|
|
2008-04-24 14:15:15 +02:00
|
|
|
my $t0= gettimeofday();
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
sub _timestamp {
|
2008-02-04 11:16:25 +01:00
|
|
|
return "" unless $timestamp;
|
2007-08-03 12:36:32 +02:00
|
|
|
|
2008-04-24 14:15:15 +02:00
|
|
|
my $diff;
|
|
|
|
if ($timediff){
|
|
|
|
my $t1= gettimeofday();
|
|
|
|
my $elapsed= $t1 - $t0;
|
|
|
|
|
|
|
|
$diff= sprintf(" +%02.3f", $elapsed);
|
|
|
|
|
|
|
|
# Save current time for next lap
|
|
|
|
$t0= $t1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
my $tm= localtime();
|
2008-04-24 14:15:15 +02:00
|
|
|
return sprintf("%02d%02d%02d %2d:%02d:%02d%s ",
|
2007-12-12 18:19:24 +01:00
|
|
|
$tm->year % 100, $tm->mon+1, $tm->mday,
|
2008-04-24 14:15:15 +02:00
|
|
|
$tm->hour, $tm->min, $tm->sec, $diff);
|
2007-08-03 12:36:32 +02:00
|
|
|
}
|
|
|
|
|
2008-05-05 22:55:47 +02:00
|
|
|
# Always print message to screen
|
|
|
|
sub mtr_print (@) {
|
2008-05-09 11:50:36 +02:00
|
|
|
print _name(), join(" ", @_), "\n";
|
2008-05-05 22:55:47 +02:00
|
|
|
}
|
|
|
|
|
2007-08-03 12:36:32 +02:00
|
|
|
|
2008-05-05 22:55:47 +02:00
|
|
|
# Print message to screen if verbose is defined
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_report (@) {
|
2008-04-24 13:02:53 +02:00
|
|
|
if (defined $verbose)
|
|
|
|
{
|
2008-05-09 11:50:36 +02:00
|
|
|
print _name(), join(" ", @_), "\n";
|
2008-04-24 13:02:53 +02:00
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
# Print warning to screen
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_warning (@) {
|
2008-05-09 11:50:36 +02:00
|
|
|
print STDERR _name(), _timestamp(),
|
2008-04-24 13:02:53 +02:00
|
|
|
"mysql-test-run: WARNING: ", join(" ", @_), "\n";
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-04 11:16:25 +01:00
|
|
|
# Print error to screen and then exit
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_error (@) {
|
2008-05-09 11:50:36 +02:00
|
|
|
print STDERR _name(), _timestamp(),
|
2008-04-24 13:02:53 +02:00
|
|
|
"mysql-test-run: *** ERROR: ", join(" ", @_), "\n";
|
Bug #42804 --parallel option does not work for MTR under ActiveState
perl
The problem here was the method how MTR gets its unique thread ids.
Prior to this patch, the method to do it was to maintain a global
table of pid,mtr_unique_id) pairs. The table was backed by a text
file. The table was cleaned up one in a while and dead processes leaking
unique_ids were determined with with kill(0) or with scripting tasklist
on Windows.
This method is flawed specifically on native Windows Perl. fork() is
implemented with starting a new thread, give it a syntetic negative PID
(threadID*(-1)), until this thread creates a new process with exec()
However, neither tasklist nor any other native Windows tool can cope with
negative perl PIDs. This lead to incorrect determination of dead process
and reusing already used mtr_unique_id.
The patch introduces alternative portable method of solving unique-id
problem. When a process needs a unique id in range [min...max], it just
starts to open files named min, min+1,...max in a loop . After file is
opened, we do non-blocking flock(). When flock() succeeds, process has
allocated the ID. When process dies, file is unlocked . Checks for zombies
are not necessary.
Since the change would create a co-existence problems with older version
of MTR, because of different way to calculate IDs, the default ID range
is changed from 250-299 to 300-349.
Another fix that was necessary enable --parallel option was to serialize
spawn() calls on Windows. specifically, IO redirects needed to be protected.
This patch also fixes hanging CRTL-C (as described in Bug #38629) for the
"new" MTR. The fix was already in 6.0 and is now downported.
2009-04-23 13:35:02 +02:00
|
|
|
if (IS_WINDOWS)
|
|
|
|
{
|
|
|
|
POSIX::_exit(1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
exit(1);
|
|
|
|
}
|
2005-09-14 13:55:53 +02:00
|
|
|
}
|
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
sub mtr_debug (@) {
|
2008-04-24 13:02:53 +02:00
|
|
|
if ( $verbose > 2 )
|
2004-12-30 16:34:01 +01:00
|
|
|
{
|
2008-05-09 11:50:36 +02:00
|
|
|
print STDERR _name(),
|
2008-04-24 13:02:53 +02:00
|
|
|
_timestamp(), "####: ", join(" ", @_), "\n";
|
2004-12-30 16:34:01 +01:00
|
|
|
}
|
|
|
|
}
|
2007-08-03 12:36:32 +02:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2006-10-04 12:47:32 +02:00
|
|
|
sub mtr_verbose (@) {
|
2008-04-24 13:02:53 +02:00
|
|
|
if ( $verbose )
|
2006-10-04 12:47:32 +02:00
|
|
|
{
|
2008-05-09 11:50:36 +02:00
|
|
|
print STDERR _name(), _timestamp(),
|
2008-04-24 13:02:53 +02:00
|
|
|
"> ",join(" ", @_),"\n";
|
2006-10-04 12:47:32 +02:00
|
|
|
}
|
|
|
|
}
|
2004-12-30 16:34:01 +01:00
|
|
|
|
2007-12-12 18:19:24 +01:00
|
|
|
|
2008-02-04 09:15:44 +01:00
|
|
|
sub mtr_verbose_restart (@) {
|
|
|
|
my ($server, @args)= @_;
|
|
|
|
my $proc= $server->{proc};
|
2008-04-24 13:02:53 +02:00
|
|
|
if ( $verbose_restart )
|
2008-02-04 09:15:44 +01:00
|
|
|
{
|
2008-05-09 11:50:36 +02:00
|
|
|
print STDERR _name(),_timestamp(),
|
2008-04-24 13:02:53 +02:00
|
|
|
"> Restart $proc - ",join(" ", @args),"\n";
|
2008-02-04 09:15:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-30 16:34:01 +01:00
|
|
|
1;
|