summaryrefslogtreecommitdiff
path: root/mysql-test/lib
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2010-04-28 14:52:24 +0200
committerunknown <knielsen@knielsen-hq.org>2010-04-28 14:52:24 +0200
commitb1e00b6be81c80b09d11085d77d86978e26df988 (patch)
treebb1fdd7363fbf2580572ac9a56dbd4c933cc4c0d /mysql-test/lib
parent1f683a7270e63abfadce20c6f51370621ff065e1 (diff)
parentc9cfd2df5f2f58c2cdf716999ebea252c307333f (diff)
downloadmariadb-git-b1e00b6be81c80b09d11085d77d86978e26df988.tar.gz
Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
Diffstat (limited to 'mysql-test/lib')
-rw-r--r--mysql-test/lib/My/ConfigFactory.pm11
-rw-r--r--mysql-test/lib/My/SafeProcess.pm133
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_process_win.cc22
-rw-r--r--mysql-test/lib/mtr_cases.pm31
-rw-r--r--mysql-test/lib/mtr_gprof.pl45
-rw-r--r--mysql-test/lib/mtr_misc.pl13
-rw-r--r--mysql-test/lib/mtr_report.pm36
-rw-r--r--mysql-test/lib/mtr_stress.pl2
-rw-r--r--mysql-test/lib/v1/mtr_stress.pl2
-rwxr-xr-xmysql-test/lib/v1/mysql-test-run.pl5
10 files changed, 148 insertions, 152 deletions
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm
index 3c9ddfa3814..c70831ab4b9 100644
--- a/mysql-test/lib/My/ConfigFactory.pm
+++ b/mysql-test/lib/My/ConfigFactory.pm
@@ -357,11 +357,14 @@ sub post_check_client_group {
if (IS_WINDOWS)
{
- # Shared memory base may or may not be defined (e.g not defined in embedded)
- my $shm = $group_to_copy_from->option("shared-memory-base-name");
- if (defined $shm)
+ if (! $self->{ARGS}->{embedded})
{
- $config->insert($client_group_name,"shared-memory-base-name", $shm->value());
+ # Shared memory base may or may not be defined (e.g not defined in embedded)
+ my $shm = $group_to_copy_from->option("shared-memory-base-name");
+ if (defined $shm)
+ {
+ $config->insert($client_group_name,"shared-memory-base-name", $shm->value());
+ }
}
}
}
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 301392a4d88..b3409020f21 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -81,24 +81,28 @@ sub is_child {
}
-# Find the safe process binary or script
my @safe_process_cmd;
my $safe_kill;
-if (IS_WIN32PERL or IS_CYGWIN){
- # Use my_safe_process.exe
- my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
- "my_safe_process");
- push(@safe_process_cmd, $exe);
-
- # Use my_safe_kill.exe
- $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
-}
-else
-{
- # Use my_safe_process
- my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
- "my_safe_process");
- push(@safe_process_cmd, $exe);
+
+# Find the safe process binary or script
+sub find_bin {
+ if (IS_WIN32PERL or IS_CYGWIN)
+ {
+ # Use my_safe_process.exe
+ my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
+ "my_safe_process");
+ push(@safe_process_cmd, $exe);
+
+ # Use my_safe_kill.exe
+ $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
+ }
+ else
+ {
+ # Use my_safe_process
+ my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
+ "my_safe_process");
+ push(@safe_process_cmd, $exe);
+ }
}
@@ -184,63 +188,6 @@ sub run {
}
#
-# Start a process that returns after "duration" seconds
-# or when it's parent process does not exist anymore
-#
-sub timer {
- my $class= shift;
- my $duration= shift or croak "duration required";
- my $parent_pid= $$;
-
- my $pid= My::SafeProcess::Base::_safe_fork();
- if ($pid){
- # Parent
- my $proc= bless
- ({
- SAFE_PID => $pid,
- SAFE_NAME => "timer",
- PARENT => $$,
- }, $class);
-
- # Put the new process in list of running
- $running{$pid}= $proc;
- return $proc;
- }
-
- # Child, install signal handlers and sleep for "duration"
- $SIG{INT}= 'IGNORE';
-
- $SIG{TERM}= sub {
- #print STDERR "timer $$: woken up, exiting!\n";
- exit(0);
- };
-
- $0= "safe_timer($duration)";
-
- if (IS_WIN32PERL){
- # Just a thread in same process
- sleep($duration);
- print STDERR "timer $$: expired after $duration seconds\n";
- exit(0);
- }
-
- my $count_down= $duration;
- while($count_down--){
-
- # Check that parent is still alive
- if (kill(0, $parent_pid) == 0){
- #print STDERR "timer $$: parent gone, exiting!\n";
- exit(0);
- }
-
- sleep(1);
- }
- print STDERR "timer $$: expired after $duration seconds\n";
- exit(0);
-}
-
-
-#
# Shutdown process nicely, and wait for shutdown_timeout seconds
# If processes hasn't shutdown, kill them hard and wait for return
#
@@ -338,12 +285,12 @@ sub start_kill {
$ret= system($safe_kill, $winpid) >> 8;
if ($ret == 3){
- print "Couldn't open the winpid: $winpid ",
+ print "Couldn't open the winpid: $winpid ".
"for pid: $pid, try one more time\n";
sleep(1);
$winpid= _winpid($pid);
$ret= system($safe_kill, $winpid) >> 8;
- print "Couldn't open the winpid: $winpid ",
+ print "Couldn't open the winpid: $winpid ".
"for pid: $pid, continue and see what happens...\n";
}
}
@@ -544,6 +491,40 @@ sub wait_any {
#
+# Wait for any process to exit, or a timeout
+#
+# Returns a reference to the SafeProcess that
+# exited or a pseudo-process with $proc->{timeout} == 1
+#
+
+sub wait_any_timeout {
+ my $class= shift;
+ my $timeout= shift;
+ my $proc;
+ my $millis=10;
+
+ do {
+ ::mtr_milli_sleep($millis);
+ # Slowly increse interval up to max. 1 second
+ $millis++ if $millis < 1000;
+ # Return a "fake" process for timeout
+ if (::has_expired($timeout)) {
+ $proc= bless
+ ({
+ SAFE_PID => 0,
+ SAFE_NAME => "timer",
+ timeout => 1,
+ }, $class);
+ } else {
+ $proc= check_any();
+ }
+ } while (! $proc);
+
+ return $proc;
+}
+
+
+#
# Wait for all processes to exit
#
sub wait_all {
@@ -600,7 +581,7 @@ sub self2str {
sub _verbose {
return unless $_verbose;
- print STDERR " ## ", @_, "\n";
+ print STDERR " ## ". @_. "\n";
}
diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
index aa9093fb2b4..896bd599f4f 100755
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
@@ -186,14 +186,20 @@ int main(int argc, const char** argv )
die("No real args -> nothing to do");
/* Copy the remaining args to child_arg */
for (int j= i+1; j < argc; j++) {
- if (strchr (argv[j], ' ')) {
- /* Protect with "" if this arg contains a space */
- to+= _snprintf(to, child_args + sizeof(child_args) - to,
- "\"%s\" ", argv[j]);
- } else {
- to+= _snprintf(to, child_args + sizeof(child_args) - to,
- "%s ", argv[j]);
- }
+ arg= argv[j];
+ if (strchr (arg, ' ') &&
+ arg[0] != '\"' &&
+ arg[strlen(arg)] != '\"')
+ {
+ /* Quote arg that contains spaces and are not quoted already */
+ to+= _snprintf(to, child_args + sizeof(child_args) - to,
+ "\"%s\" ", arg);
+ }
+ else
+ {
+ to+= _snprintf(to, child_args + sizeof(child_args) - to,
+ "%s ", arg);
+ }
}
break;
} else {
diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm
index ad8a204db47..1a39255d7e3 100644
--- a/mysql-test/lib/mtr_cases.pm
+++ b/mysql-test/lib/mtr_cases.pm
@@ -40,7 +40,6 @@ our $default_storage_engine;
our $opt_with_ndbcluster_only;
our $defaults_file;
our $defaults_extra_file;
-our $reorder= 1;
our $quick_collect;
sub collect_option {
@@ -99,7 +98,8 @@ sub init_pattern {
#
##############################################################################
-sub collect_test_cases ($$) {
+sub collect_test_cases ($$$) {
+ my $opt_reorder= shift; # True if we're reordering tests
my $suites= shift; # Semicolon separated list of test suites
my $opt_cases= shift;
my $cases= []; # Array of hash(one hash for each testcase)
@@ -118,10 +118,16 @@ sub collect_test_cases ($$) {
!(IS_WINDOWS && $::opt_embedded_server) &&
$lib_innodb_plugin);
- foreach my $suite (split(",", $suites))
+ # If not reordering, we also shouldn't group by suites, unless
+ # no test cases were named.
+ # This also effects some logic in the loop following this.
+ if ($opt_reorder or !@$opt_cases)
{
- push(@$cases, collect_one_suite($suite, $opt_cases));
- last if $some_test_found;
+ foreach my $suite (split(",", $suites))
+ {
+ push(@$cases, collect_one_suite($suite, $opt_cases));
+ last if $some_test_found;
+ }
}
if ( @$opt_cases )
@@ -135,6 +141,7 @@ sub collect_test_cases ($$) {
my ($sname, $tname, $extension)= split_testname($test_name_spec);
foreach my $test ( @$cases )
{
+ last unless $opt_reorder;
# test->{name} is always in suite.name format
if ( $test->{name} =~ /.*\.$tname/ )
{
@@ -144,12 +151,13 @@ sub collect_test_cases ($$) {
}
if ( not $found )
{
+ $sname= "main" if !$opt_reorder and !$sname;
mtr_error("Could not find '$tname' in '$suites' suite(s)") unless $sname;
- # If suite was part of name, find it there
- my ($this_case) = collect_one_suite($sname, [ $tname ]);
- if ($this_case)
+ # If suite was part of name, find it there, may come with combinations
+ my @this_case = collect_one_suite($sname, [ $tname ]);
+ if (@this_case)
{
- push (@$cases, $this_case);
+ push (@$cases, @this_case);
}
else
{
@@ -159,7 +167,7 @@ sub collect_test_cases ($$) {
}
}
- if ( $reorder && !$quick_collect)
+ if ( $opt_reorder && !$quick_collect)
{
# Reorder the test cases in an order that will make them faster to run
my %sort_criteria;
@@ -528,6 +536,9 @@ sub collect_one_suite
next if ($test->{'name'} eq 'main.innodb-autoinc');
# Fails with innodb plugin: r6185 Testcases changes not included
next if ($test->{'name'} eq 'main.innodb_bug44369');
+ # Fix for BUG47621 is not in InnoDB plugin
+ next if ($test->{'name'} eq 'main.innodb_bug21704');
+ next if ($test->{'name'} eq 'main.innodb_bug47621');
# Copy test options
my $new_test= My::Test->new();
while (my ($key, $value) = each(%$test))
diff --git a/mysql-test/lib/mtr_gprof.pl b/mysql-test/lib/mtr_gprof.pl
index f6615301dd7..5820a4007b8 100644
--- a/mysql-test/lib/mtr_gprof.pl
+++ b/mysql-test/lib/mtr_gprof.pl
@@ -20,43 +20,20 @@
use strict;
-# These are not to be prefixed with "mtr_"
+sub gprof_collect ($@) {
+ my ($exe_mysqld, @gprof_dirs)= @_;
-sub gprof_prepare ();
-sub gprof_collect ();
+ print ("Collecting gprof reports.....\n");
-##############################################################################
-#
-#
-#
-##############################################################################
-
-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" )
+ foreach my $datadir (@gprof_dirs)
{
- # 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";
+ my $gprof_msg= "$datadir/gprof.msg";
+ my $gprof_err= "$datadir/gprof.err";
+ if ( -f "$datadir/gmon.out" )
+ {
+ system("gprof $exe_mysqld $datadir/gmon.out 2>$gprof_err >$gprof_msg");
+ print ("GPROF output in $gprof_msg, errors in $gprof_err\n");
+ }
}
}
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index 05e5593a713..6838435bbde 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -30,7 +30,9 @@ sub mtr_script_exists(@);
sub mtr_file_exists(@);
sub mtr_exe_exists(@);
sub mtr_exe_maybe_exists(@);
-
+sub mtr_milli_sleep($);
+sub start_timer($);
+sub has_expired($);
##############################################################################
#
@@ -167,7 +169,7 @@ sub mtr_exe_exists (@) {
}
-sub mtr_milli_sleep {
+sub mtr_milli_sleep ($) {
die "usage: mtr_milli_sleep(milliseconds)" unless @_ == 1;
my ($millis)= @_;
@@ -194,4 +196,11 @@ sub mtr_wait_lock_file {
return ($waited);
}
+# Simple functions to start and check timers (have to be actively polled)
+# Timer can be "killed" by setting it to 0
+
+sub start_timer ($) { return time + $_[0]; }
+
+sub has_expired ($) { return $_[0] && time gt $_[0]; }
+
1;
diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm
index 944f62b29e3..f6a6a2b63b5 100644
--- a/mysql-test/lib/mtr_report.pm
+++ b/mysql-test/lib/mtr_report.pm
@@ -69,7 +69,7 @@ sub _mtr_report_test_name ($) {
$tname.= " '$tinfo->{combination}'"
if defined $tinfo->{combination};
- print _name(), _timestamp();
+ print _name(). _timestamp();
printf "%-40s ", $tname;
my $worker = $tinfo->{worker};
printf "w$worker " if $worker;
@@ -222,7 +222,8 @@ sub mtr_report_test ($) {
}
-sub mtr_report_stats ($$$) {
+sub mtr_report_stats ($$$$) {
+ my $prefix= shift;
my $fail= shift;
my $tests= shift;
my $extra_warnings= shift;
@@ -328,6 +329,9 @@ sub mtr_report_stats ($$$) {
}
}
+ # Print summary line prefix
+ print "$prefix: ";
+
# Print a list of testcases that failed
if ( $tot_failed != 0 )
{
@@ -404,13 +408,13 @@ MSG
##############################################################################
sub mtr_print_line () {
- print '-' x 60, "\n";
+ print '-' x 60 . "\n";
}
sub mtr_print_thick_line {
my $char= shift || '=';
- print $char x 78, "\n";
+ print $char x 78 . "\n";
}
@@ -468,7 +472,7 @@ sub _timestamp {
# Always print message to screen
sub mtr_print (@) {
- print _name(), join(" ", @_), "\n";
+ print _name(). join(" ", @_). "\n";
}
@@ -476,22 +480,22 @@ sub mtr_print (@) {
sub mtr_report (@) {
if (defined $verbose)
{
- print _name(), join(" ", @_), "\n";
+ print _name(). join(" ", @_). "\n";
}
}
# Print warning to screen
sub mtr_warning (@) {
- print STDERR _name(), _timestamp(),
- "mysql-test-run: WARNING: ", join(" ", @_), "\n";
+ print STDERR _name(). _timestamp().
+ "mysql-test-run: WARNING: ". join(" ", @_). "\n";
}
# Print error to screen and then exit
sub mtr_error (@) {
- print STDERR _name(), _timestamp(),
- "mysql-test-run: *** ERROR: ", join(" ", @_), "\n";
+ print STDERR _name(). _timestamp().
+ "mysql-test-run: *** ERROR: ". join(" ", @_). "\n";
if (IS_WINDOWS)
{
POSIX::_exit(1);
@@ -506,8 +510,8 @@ sub mtr_error (@) {
sub mtr_debug (@) {
if ( $verbose > 2 )
{
- print STDERR _name(),
- _timestamp(), "####: ", join(" ", @_), "\n";
+ print STDERR _name().
+ _timestamp(). "####: ". join(" ", @_). "\n";
}
}
@@ -515,8 +519,8 @@ sub mtr_debug (@) {
sub mtr_verbose (@) {
if ( $verbose )
{
- print STDERR _name(), _timestamp(),
- "> ",join(" ", @_),"\n";
+ print STDERR _name(). _timestamp().
+ "> ".join(" ", @_)."\n";
}
}
@@ -526,8 +530,8 @@ sub mtr_verbose_restart (@) {
my $proc= $server->{proc};
if ( $verbose_restart )
{
- print STDERR _name(),_timestamp(),
- "> Restart $proc - ",join(" ", @args),"\n";
+ print STDERR _name()._timestamp().
+ "> Restart $proc - ".join(" ", @args)."\n";
}
}
diff --git a/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl
index cd5c7b0dbb7..702bc178ae5 100644
--- a/mysql-test/lib/mtr_stress.pl
+++ b/mysql-test/lib/mtr_stress.pl
@@ -150,7 +150,7 @@ sub run_stress_test ()
mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details");
- mtr_add_arg($args, "--abort-on-error");
+ mtr_add_arg($args, "--abort-on-error=1");
if ( $::opt_stress_init_file )
{
diff --git a/mysql-test/lib/v1/mtr_stress.pl b/mysql-test/lib/v1/mtr_stress.pl
index 93b06b32c5f..40800c9729b 100644
--- a/mysql-test/lib/v1/mtr_stress.pl
+++ b/mysql-test/lib/v1/mtr_stress.pl
@@ -150,7 +150,7 @@ sub run_stress_test ()
mtr_add_arg($args, "--verbose");
mtr_add_arg($args, "--cleanup");
mtr_add_arg($args, "--log-error-details");
- mtr_add_arg($args, "--abort-on-error");
+ mtr_add_arg($args, "--abort-on-error=1");
if ( $::opt_stress_init_file )
{
diff --git a/mysql-test/lib/v1/mysql-test-run.pl b/mysql-test/lib/v1/mysql-test-run.pl
index 998555d76d1..174de23c530 100755
--- a/mysql-test/lib/v1/mysql-test-run.pl
+++ b/mysql-test/lib/v1/mysql-test-run.pl
@@ -920,6 +920,11 @@ sub command_line_setup () {
mtr_report("Using default engine '$used_default_engine'")
if defined $used_default_engine;
+ if ($glob_win32 and defined $opt_mem) {
+ mtr_report("--mem not supported on Windows, ignored");
+ $opt_mem= undef;
+ }
+
# --------------------------------------------------------------------------
# Check if we should speed up tests by trying to run on tmpfs
# --------------------------------------------------------------------------