mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge janus.mylan:/usr/home/serg/Abk/mysql-5.1
into janus.mylan:/usr/home/serg/Abk/mysql-maria include/my_sys.h: Auto merged mysql-test/lib/mtr_cases.pl: Auto merged mysql-test/lib/mtr_misc.pl: Auto merged mysql-test/mysql-test-run.pl: Auto merged mysql-test/r/ps_2myisam.result: Auto merged mysql-test/r/ps_3innodb.result: Auto merged mysql-test/r/ps_4heap.result: Auto merged mysql-test/r/ps_5merge.result: Auto merged mysql-test/r/query_cache.result: Auto merged mysql-test/r/subselect.result: Auto merged mysql-test/r/view.result: Auto merged mysql-test/suite/binlog/r/binlog_unsafe.result: Auto merged mysql-test/suite/binlog/t/binlog_unsafe.test: Auto merged mysql-test/suite/ndb/r/ps_7ndb.result: Auto merged mysql-test/suite/rpl/r/rpl_switch_stm_row_mixed.result: Auto merged mysql-test/suite/rpl/t/rpl_insert.test: Auto merged mysql-test/suite/rpl/t/rpl_switch_stm_row_mixed.test: Auto merged mysql-test/t/disabled.def: Auto merged mysql-test/t/query_cache.test: Auto merged mysql-test/t/subselect.test: Auto merged mysql-test/t/view.test: Auto merged sql/field.h: Auto merged sql/filesort.cc: Auto merged sql/ha_partition.cc: Auto merged sql/handler.cc: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.h: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/opt_range.cc: Auto merged sql/set_var.cc: Auto merged sql/set_var.h: Auto merged sql/slave.cc: Auto merged sql/slave.h: Auto merged sql/sp_head.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_union.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/unireg.cc: Auto merged sql/share/errmsg.txt: Auto merged storage/myisam/ft_boolean_search.c: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisam/sort.c: Auto merged sql/log_event_old.h: SCCS merged BitKeeper/triggers/post-commit: merged client/mysqldump.c: merged configure.in: merged client/mysqltest.c: merged include/Makefile.am: merged include/atomic/nolock.h: merged mysql-test/lib/mtr_report.pl: merged sql/handler.h: merged sql/mysqld.cc: merged sql/sql_select.cc: merged
This commit is contained in:
422
mysql-test/lib/My/Config.pm
Normal file
422
mysql-test/lib/My/Config.pm
Normal file
@ -0,0 +1,422 @@
|
||||
# -*- cperl -*-
|
||||
|
||||
package My::Config::Option;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
sub new {
|
||||
my ($class, $option_name, $option_value)= @_;
|
||||
my $self= bless { name => $option_name,
|
||||
value => $option_value
|
||||
}, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
sub name {
|
||||
my ($self)= @_;
|
||||
return $self->{name};
|
||||
}
|
||||
|
||||
|
||||
sub value {
|
||||
my ($self)= @_;
|
||||
return $self->{value};
|
||||
}
|
||||
|
||||
|
||||
package My::Config::Group;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
sub new {
|
||||
my ($class, $group_name)= @_;
|
||||
my $self= bless { name => $group_name,
|
||||
options => [],
|
||||
options_by_name => {},
|
||||
}, $class;
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
sub insert {
|
||||
my ($self, $option_name, $value, $if_not_exist)= @_;
|
||||
my $option= $self->option($option_name);
|
||||
if (defined($option) and !$if_not_exist) {
|
||||
$option->{value}= $value;
|
||||
}
|
||||
else {
|
||||
my $option= My::Config::Option->new($option_name, $value);
|
||||
# Insert option in list
|
||||
push(@{$self->{options}}, $option);
|
||||
# Insert option in hash
|
||||
$self->{options_by_name}->{$option_name}= $option;
|
||||
}
|
||||
return $option;
|
||||
}
|
||||
|
||||
sub remove {
|
||||
my ($self, $option_name)= @_;
|
||||
|
||||
# Check that option exists
|
||||
my $option= $self->option($option_name);
|
||||
|
||||
return undef unless defined $option;
|
||||
|
||||
# Remove from the hash
|
||||
delete($self->{options_by_name}->{$option_name}) or die;
|
||||
|
||||
# Remove from the array
|
||||
@{$self->{options}}= grep { $_->name ne $option_name } @{$self->{options}};
|
||||
|
||||
return $option;
|
||||
}
|
||||
|
||||
|
||||
sub options {
|
||||
my ($self)= @_;
|
||||
return @{$self->{options}};
|
||||
}
|
||||
|
||||
|
||||
sub name {
|
||||
my ($self)= @_;
|
||||
return $self->{name};
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a specific option in the group
|
||||
#
|
||||
sub option {
|
||||
my ($self, $option_name)= @_;
|
||||
|
||||
return $self->{options_by_name}->{$option_name};
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a specific value for an option in the group
|
||||
#
|
||||
sub value {
|
||||
my ($self, $option_name)= @_;
|
||||
my $option= $self->option($option_name);
|
||||
|
||||
die "No option named '$option_name' in this group"
|
||||
if ! defined($option);
|
||||
|
||||
return $option->value();
|
||||
}
|
||||
|
||||
|
||||
package My::Config;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use IO::File;
|
||||
use File::Basename;
|
||||
|
||||
#
|
||||
# Constructor for My::Config
|
||||
# - represents a my.cnf config file
|
||||
#
|
||||
# Array of arrays
|
||||
#
|
||||
sub new {
|
||||
my ($class, $path)= @_;
|
||||
my $group_name= undef;
|
||||
|
||||
my $self= bless { groups => [] }, $class;
|
||||
my $F= IO::File->new($path, "<")
|
||||
or die "Could not open '$path': $!";
|
||||
|
||||
while ( my $line= <$F> ) {
|
||||
chomp($line);
|
||||
|
||||
# [group]
|
||||
if ( $line =~ /\[(.*)\]/ ) {
|
||||
# New group found
|
||||
$group_name= $1;
|
||||
#print "group: $group_name\n";
|
||||
|
||||
$self->insert($group_name, undef, undef);
|
||||
}
|
||||
|
||||
# Magic #! comments
|
||||
elsif ( $line =~ /^#\!/) {
|
||||
my $magic= $line;
|
||||
die "Found magic comment '$magic' outside of group"
|
||||
unless $group_name;
|
||||
|
||||
#print "$magic\n";
|
||||
$self->insert($group_name, $magic, undef);
|
||||
}
|
||||
|
||||
# Comments
|
||||
elsif ( $line =~ /^#/ || $line =~ /^;/) {
|
||||
# Skip comment
|
||||
next;
|
||||
}
|
||||
|
||||
# Empty lines
|
||||
elsif ( $line =~ /^$/ ) {
|
||||
# Skip empty lines
|
||||
next;
|
||||
}
|
||||
|
||||
# !include <filename>
|
||||
elsif ( $line =~ /^\!include\s*(.*?)\s*$/ ) {
|
||||
my $include_file_name= dirname($path)."/".$1;
|
||||
# Check that the file exists
|
||||
die "The include file '$include_file_name' does not exist"
|
||||
unless -f $include_file_name;
|
||||
|
||||
$self->append(My::Config->new($include_file_name));
|
||||
}
|
||||
|
||||
# <option>
|
||||
elsif ( $line =~ /^([\@\w-]+)\s*$/ ) {
|
||||
my $option= $1;
|
||||
|
||||
die "Found option '$option' outside of group"
|
||||
unless $group_name;
|
||||
|
||||
#print "$option\n";
|
||||
$self->insert($group_name, $option, undef);
|
||||
}
|
||||
|
||||
# <option>=<value>
|
||||
elsif ( $line =~ /^([\@\w-]+)\s*=\s*(.*?)\s*$/ ) {
|
||||
my $option= $1;
|
||||
my $value= $2;
|
||||
|
||||
die "Found option '$option=$value' outside of group"
|
||||
unless $group_name;
|
||||
|
||||
#print "$option=$value\n";
|
||||
$self->insert($group_name, $option, $value);
|
||||
} else {
|
||||
die "Unexpected line '$line' found in '$path'";
|
||||
}
|
||||
|
||||
}
|
||||
undef $F; # Close the file
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
#
|
||||
# Insert a new group if it does not already exist
|
||||
# and add option if defined
|
||||
#
|
||||
sub insert {
|
||||
my ($self, $group_name, $option, $value, $if_not_exist)= @_;
|
||||
my $group;
|
||||
|
||||
# Create empty array for the group if it doesn't exist
|
||||
if ( !$self->group_exists($group_name) ) {
|
||||
$group= $self->_group_insert($group_name);
|
||||
}
|
||||
else {
|
||||
$group= $self->group($group_name);
|
||||
}
|
||||
|
||||
if ( defined $option ) {
|
||||
#print "option: $option, value: $value\n";
|
||||
|
||||
# Add the option to the group
|
||||
$group->insert($option, $value, $if_not_exist);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Remove a option, given group and option name
|
||||
#
|
||||
sub remove {
|
||||
my ($self, $group_name, $option_name)= @_;
|
||||
my $group= $self->group($group_name);
|
||||
|
||||
die "group '$group_name' does not exist"
|
||||
unless defined($group);
|
||||
|
||||
$group->remove($option_name) or
|
||||
die "option '$option_name' does not exist";
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Check if group with given name exists in config
|
||||
#
|
||||
sub group_exists {
|
||||
my ($self, $group_name)= @_;
|
||||
|
||||
foreach my $group ($self->groups()) {
|
||||
return 1 if $group->{name} eq $group_name;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Insert a new group into config
|
||||
#
|
||||
sub _group_insert {
|
||||
my ($self, $group_name)= @_;
|
||||
caller eq __PACKAGE__ or die;
|
||||
|
||||
# Check that group does not already exist
|
||||
die "Group already exists" if $self->group_exists($group_name);
|
||||
|
||||
my $group= My::Config::Group->new($group_name);
|
||||
push(@{$self->{groups}}, $group);
|
||||
return $group;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Append a configuration to current config
|
||||
#
|
||||
sub append {
|
||||
my ($self, $from)= @_;
|
||||
|
||||
foreach my $group ($from->groups()) {
|
||||
foreach my $option ($group->options()) {
|
||||
$self->insert($group->name(), $option->name(), $option->value());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a list with all the groups in config
|
||||
#
|
||||
sub groups {
|
||||
my ($self)= @_;
|
||||
return ( @{$self->{groups}} );
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a list of all the groups in config
|
||||
# starting with the given string
|
||||
#
|
||||
sub like {
|
||||
my ($self, $prefix)= @_;
|
||||
return ( grep ( $_->{name} =~ /^$prefix/, $self->groups()) );
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return the first group in config
|
||||
# starting with the given string
|
||||
#
|
||||
sub first_like {
|
||||
my ($self, $prefix)= @_;
|
||||
return ($self->like($prefix))[0];
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a specific group in the config
|
||||
#
|
||||
sub group {
|
||||
my ($self, $group_name)= @_;
|
||||
|
||||
foreach my $group ( $self->groups() ) {
|
||||
return $group if $group->{name} eq $group_name;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a list of all options in a specific group in the config
|
||||
#
|
||||
sub options_in_group {
|
||||
my ($self, $group_name)= @_;
|
||||
|
||||
my $group= $self->group($group_name);
|
||||
return () unless defined $group;
|
||||
return $group->options();
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Return a value given group and option name
|
||||
#
|
||||
sub value {
|
||||
my ($self, $group_name, $option_name)= @_;
|
||||
my $group= $self->group($group_name);
|
||||
|
||||
die "group '$group_name' does not exist"
|
||||
unless defined($group);
|
||||
|
||||
my $option= $group->option($option_name);
|
||||
die "option '$option_name' does not exist"
|
||||
unless defined($option);
|
||||
|
||||
return $option->value();
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Check if an option exists
|
||||
#
|
||||
sub exists {
|
||||
my ($self, $group_name, $option_name)= @_;
|
||||
my $group= $self->group($group_name);
|
||||
|
||||
die "group '$group_name' does not exist"
|
||||
unless defined($group);
|
||||
|
||||
my $option= $group->option($option_name);
|
||||
return defined($option);
|
||||
}
|
||||
|
||||
|
||||
# Overload "to string"-operator with 'stringify'
|
||||
use overload
|
||||
'""' => \&stringify;
|
||||
|
||||
#
|
||||
# Return the config as a string in my.cnf file format
|
||||
#
|
||||
sub stringify {
|
||||
my ($self)= @_;
|
||||
my $res;
|
||||
|
||||
foreach my $group ($self->groups()) {
|
||||
$res .= "[$group->{name}]\n";
|
||||
|
||||
foreach my $option ($group->options()) {
|
||||
$res .= $option->name();
|
||||
my $value= $option->value();
|
||||
if (defined $value) {
|
||||
$res .= "=$value";
|
||||
}
|
||||
$res .= "\n";
|
||||
}
|
||||
$res .= "\n";
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Save the config to named file
|
||||
#
|
||||
sub save {
|
||||
my ($self, $path)= @_;
|
||||
my $F= IO::File->new($path, ">")
|
||||
or die "Could not open '$path': $!";
|
||||
print $F $self;
|
||||
undef $F; # Close the file
|
||||
}
|
||||
|
||||
1;
|
@ -22,8 +22,10 @@ use File::Basename;
|
||||
use IO::File();
|
||||
use strict;
|
||||
|
||||
use My::Config;
|
||||
|
||||
sub collect_test_cases ($);
|
||||
sub collect_one_suite ($$);
|
||||
sub collect_one_suite ($);
|
||||
sub collect_one_test_case ($$$$$$$$$);
|
||||
|
||||
sub mtr_options_from_test_file($$);
|
||||
@ -61,7 +63,7 @@ sub collect_test_cases ($) {
|
||||
|
||||
foreach my $suite (split(",", $suites))
|
||||
{
|
||||
collect_one_suite($suite, $cases);
|
||||
push(@$cases, collect_one_suite($suite));
|
||||
}
|
||||
|
||||
|
||||
@ -205,51 +207,24 @@ sub split_testname {
|
||||
}
|
||||
|
||||
|
||||
sub collect_one_suite($$)
|
||||
sub collect_one_suite($)
|
||||
{
|
||||
my $suite= shift; # Test suite name
|
||||
my $cases= shift; # List of test cases
|
||||
my @cases; # Array of hash
|
||||
|
||||
mtr_verbose("Collecting: $suite");
|
||||
|
||||
my $combination_file= "combinations";
|
||||
my $combinations = [];
|
||||
|
||||
my $suitedir= "$::glob_mysql_test_dir"; # Default
|
||||
my $combination_file= "$::glob_mysql_test_dir/$combination_file";
|
||||
if ( $suite ne "main" )
|
||||
{
|
||||
$suitedir= mtr_path_exists("$suitedir/suite/$suite",
|
||||
"$suitedir/$suite");
|
||||
mtr_verbose("suitedir: $suitedir");
|
||||
$combination_file= "$suitedir/$combination_file";
|
||||
}
|
||||
|
||||
my $testdir= "$suitedir/t";
|
||||
my $resdir= "$suitedir/r";
|
||||
|
||||
if (!@::opt_combination)
|
||||
{
|
||||
# Read combinations file
|
||||
if ( open(COMB,$combination_file) )
|
||||
{
|
||||
while (<COMB>)
|
||||
{
|
||||
chomp;
|
||||
s/\ +/ /g;
|
||||
push (@$combinations, $_) unless ($_ eq '');
|
||||
}
|
||||
close COMB;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# take the combination from command-line
|
||||
@$combinations = @::opt_combination;
|
||||
}
|
||||
# Remember last element position
|
||||
my $begin_index = $#{@$cases} + 1;
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Build a hash of disabled testcases for this suite
|
||||
# ----------------------------------------------------------------------
|
||||
@ -324,7 +299,7 @@ sub collect_one_suite($$)
|
||||
}
|
||||
|
||||
collect_one_test_case($testdir,$resdir,$suite,$tname,
|
||||
"$tname.$extension",$cases,\%disabled,
|
||||
"$tname.$extension",\@cases,\%disabled,
|
||||
$component_id,$suite_opts);
|
||||
}
|
||||
}
|
||||
@ -354,85 +329,168 @@ sub collect_one_suite($$)
|
||||
next if ($do_test and not $tname =~ /$do_test/o);
|
||||
|
||||
collect_one_test_case($testdir,$resdir,$suite,$tname,
|
||||
$elem,$cases,\%disabled,$component_id,
|
||||
$elem,\@cases,\%disabled,$component_id,
|
||||
$suite_opts);
|
||||
}
|
||||
closedir TESTDIR;
|
||||
}
|
||||
|
||||
|
||||
# Return empty list if no testcases found
|
||||
return if (@cases == 0);
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Proccess combinations only if new tests were added
|
||||
# Read combinations for this suite and build testcases x combinations
|
||||
# if any combinations exists
|
||||
# ----------------------------------------------------------------------
|
||||
if (0 and $combinations && $begin_index <= $#{@$cases})
|
||||
{
|
||||
my $end_index = $#{@$cases};
|
||||
my $is_copy;
|
||||
# Keep original master/slave options
|
||||
my @orig_opts;
|
||||
for (my $idx = $begin_index; $idx <= $end_index; $idx++)
|
||||
if ( ! $::opt_skip_combination )
|
||||
{
|
||||
my @combinations;
|
||||
my $combination_file= "$suitedir/combinations";
|
||||
#print "combination_file: $combination_file\n";
|
||||
if (@::opt_combinations)
|
||||
{
|
||||
foreach my $param (('master_opt','slave_opt','slave_mi'))
|
||||
{
|
||||
@{$orig_opts[$idx]{$param}} = @{$cases->[$idx]->{$param}};
|
||||
# take the combination from command-line
|
||||
mtr_verbose("Take the combination from command line");
|
||||
foreach my $combination (@::opt_combinations) {
|
||||
my $comb= {};
|
||||
$comb->{name}= $combination;
|
||||
push(@{$comb->{comb_opt}}, $combination);
|
||||
push(@combinations, $comb);
|
||||
}
|
||||
}
|
||||
my $comb_index = 1;
|
||||
# Copy original test cases
|
||||
foreach my $comb_set (@$combinations)
|
||||
{
|
||||
for (my $idx = $begin_index; $idx <= $end_index; $idx++)
|
||||
elsif (-f $combination_file )
|
||||
{
|
||||
# Read combinations file in my.cnf format
|
||||
mtr_verbose("Read combinations file");
|
||||
my $config= My::Config->new($combination_file);
|
||||
|
||||
foreach my $group ($config->groups()) {
|
||||
my $comb= {};
|
||||
$comb->{name}= $group->name();
|
||||
foreach my $option ( $group->options() ) {
|
||||
push(@{$comb->{comb_opt}}, $option->name()."=".$option->value());
|
||||
}
|
||||
push(@combinations, $comb);
|
||||
}
|
||||
}
|
||||
|
||||
if (@combinations)
|
||||
{
|
||||
print " - adding combinations\n";
|
||||
#print_testcases(@cases);
|
||||
|
||||
my @new_cases;
|
||||
foreach my $comb (@combinations)
|
||||
{
|
||||
my $test = $cases->[$idx];
|
||||
my $copied_test = {};
|
||||
foreach my $param (keys %{$test})
|
||||
{
|
||||
# Scalar. Copy as is.
|
||||
$copied_test->{$param} = $test->{$param};
|
||||
# Array. Copy reference instead itself
|
||||
if ($param =~ /(master_opt|slave_opt|slave_mi)/)
|
||||
{
|
||||
my $new_arr = [];
|
||||
@$new_arr = @{$orig_opts[$idx]{$param}};
|
||||
$copied_test->{$param} = $new_arr;
|
||||
}
|
||||
elsif ($param =~ /(comment|combinations)/)
|
||||
{
|
||||
$copied_test->{$param} = '';
|
||||
}
|
||||
}
|
||||
if ($is_copy)
|
||||
{
|
||||
push(@$cases, $copied_test);
|
||||
$test = $cases->[$#{@$cases}];
|
||||
}
|
||||
foreach my $comb_opt (split(/ /,$comb_set))
|
||||
{
|
||||
push(@{$test->{'master_opt'}},$comb_opt);
|
||||
push(@{$test->{'slave_opt'}},$comb_opt);
|
||||
# Enable rpl if added option is --binlog-format and test case supports that
|
||||
if ($comb_opt =~ /^--binlog-format=.+$/)
|
||||
{
|
||||
my @opt_pairs = split(/=/, $comb_opt);
|
||||
if ($test->{'binlog_format'} =~ /^$opt_pairs[1]$/ || $test->{'binlog_format'} eq '')
|
||||
{
|
||||
$test->{'skip'} = 0;
|
||||
$test->{'comment'} = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$test->{'skip'} = 1;
|
||||
$test->{'comment'} = "Requiring binlog format '$test->{'binlog_format'}'";;
|
||||
}
|
||||
}
|
||||
}
|
||||
$test->{'combination'} = $comb_set;
|
||||
}
|
||||
$is_copy = 1;
|
||||
$comb_index++;
|
||||
}
|
||||
foreach my $test (@cases)
|
||||
{
|
||||
#print $test->{name}, " ", $comb, "\n";
|
||||
my $new_test= {};
|
||||
|
||||
while (my ($key, $value) = each(%$test)) {
|
||||
if (ref $value eq "ARRAY") {
|
||||
push(@{$new_test->{$key}}, @$value);
|
||||
} else {
|
||||
$new_test->{$key}= $value;
|
||||
}
|
||||
}
|
||||
|
||||
# Append the combination options to master_opt and slave_opt
|
||||
push(@{$new_test->{master_opt}}, @{$comb->{comb_opt}});
|
||||
push(@{$new_test->{slave_opt}}, @{$comb->{comb_opt}});
|
||||
|
||||
# Add combination name shrt name
|
||||
$new_test->{combination}= $comb->{name};
|
||||
|
||||
# Add the new test to new test cases list
|
||||
push(@new_cases, $new_test);
|
||||
}
|
||||
}
|
||||
#print_testcases(@new_cases);
|
||||
@cases= @new_cases;
|
||||
#print_testcases(@cases);
|
||||
}
|
||||
}
|
||||
|
||||
return $cases;
|
||||
optimize_cases(\@cases);
|
||||
#print_testcases(@cases);
|
||||
|
||||
return @cases;
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Loop through all test cases
|
||||
# - optimize which test to run by skipping unnecessary ones
|
||||
# - update settings if necessary
|
||||
#
|
||||
sub optimize_cases {
|
||||
my ($cases)= @_;
|
||||
|
||||
foreach my $tinfo ( @$cases )
|
||||
{
|
||||
# Skip processing if already marked as skipped
|
||||
next if $tinfo->{skip};
|
||||
|
||||
# Replication test needs an adjustment of binlog format
|
||||
if (mtr_match_prefix($tinfo->{'name'}, "rpl"))
|
||||
{
|
||||
|
||||
# =======================================================
|
||||
# Get binlog-format used by this test from master_opt
|
||||
# =======================================================
|
||||
my $test_binlog_format;
|
||||
foreach my $opt ( @{$tinfo->{master_opt}} ) {
|
||||
$test_binlog_format= $test_binlog_format ||
|
||||
mtr_match_prefix($opt, "--binlog-format=");
|
||||
}
|
||||
# print $tinfo->{name}." uses ".$test_binlog_format."\n";
|
||||
|
||||
# =======================================================
|
||||
# If a special binlog format was selected with
|
||||
# --mysqld=--binlog-format=x, skip all test with different
|
||||
# binlog-format
|
||||
# =======================================================
|
||||
if (defined $::used_binlog_format and
|
||||
$test_binlog_format and
|
||||
$::used_binlog_format ne $test_binlog_format)
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
$tinfo->{'comment'}= "Requires --binlog-format='$test_binlog_format'";
|
||||
next;
|
||||
}
|
||||
|
||||
# =======================================================
|
||||
# Check that testcase supports the designated binlog-format
|
||||
# =======================================================
|
||||
if ($test_binlog_format and defined $tinfo->{'sup_binlog_formats'} )
|
||||
{
|
||||
my $supported=
|
||||
grep { $_ eq $test_binlog_format } @{$tinfo->{'sup_binlog_formats'}};
|
||||
if ( !$supported )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
$tinfo->{'comment'}=
|
||||
"Doesn't support --binlog-format='$test_binlog_format'";
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
# =======================================================
|
||||
# Use dynamic switching of binlog-format if mtr started
|
||||
# w/o --mysqld=--binlog-format=xxx and combinations.
|
||||
# =======================================================
|
||||
if (!defined $tinfo->{'combination'} and
|
||||
!defined $::used_binlog_format)
|
||||
{
|
||||
$test_binlog_format= $tinfo->{'sup_binlog_formats'}->[0];
|
||||
}
|
||||
|
||||
# Save binlog format for dynamic switching
|
||||
$tinfo->{binlog_format}= $test_binlog_format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -522,6 +580,7 @@ sub collect_one_test_case($$$$$$$$$) {
|
||||
$tinfo->{'slave_opt'}= [];
|
||||
$tinfo->{'slave_mi'}= [];
|
||||
|
||||
|
||||
# Add suite opts
|
||||
foreach my $opt ( @$suite_opts )
|
||||
{
|
||||
@ -735,14 +794,6 @@ sub collect_one_test_case($$$$$$$$$) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defined $tinfo->{'binlog_format'} and
|
||||
! ( $tinfo->{'binlog_format'} eq $::used_binlog_format ) )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
$tinfo->{'comment'}= "Requiring binlog format '$tinfo->{'binlog_format'}'";
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $tinfo->{'need_debug'} && ! $::debug_compiled_binaries )
|
||||
{
|
||||
$tinfo->{'skip'}= 1;
|
||||
@ -822,10 +873,17 @@ sub collect_one_test_case($$$$$$$$$) {
|
||||
our @tags=
|
||||
(
|
||||
["include/have_innodb.inc", "innodb_test", 1],
|
||||
["include/have_binlog_format_row.inc", "binlog_format", "row"],
|
||||
["include/have_binlog_format_row.inc", "sup_binlog_formats", ["row"]],
|
||||
["include/have_log_bin.inc", "need_binlog", 1],
|
||||
["include/have_binlog_format_statement.inc", "binlog_format", "statement"],
|
||||
["include/have_binlog_format_mixed.inc", "binlog_format", "mixed"],
|
||||
["include/have_binlog_format_statement.inc",
|
||||
"sup_binlog_formats", ["statement"]],
|
||||
["include/have_binlog_format_mixed.inc", "sup_binlog_formats", ["mixed"]],
|
||||
["include/have_binlog_format_mixed_or_row.inc",
|
||||
"sup_binlog_formats", ["mixed","row"]],
|
||||
["include/have_binlog_format_mixed_or_statement.inc",
|
||||
"sup_binlog_formats", ["mixed","statement"]],
|
||||
["include/have_binlog_format_row_or_statement.inc",
|
||||
"sup_binlog_formats", ["row","statement"]],
|
||||
["include/big_test.inc", "big_test", 1],
|
||||
["include/have_debug.inc", "need_debug", 1],
|
||||
["include/have_ndb.inc", "ndb_test", 1],
|
||||
@ -851,8 +909,8 @@ sub mtr_options_from_test_file($$) {
|
||||
{
|
||||
if ( index($line, $tag->[0]) >= 0 )
|
||||
{
|
||||
# Tag matched, assign value to "tinfo"
|
||||
$tinfo->{"$tag->[1]"}= $tag->[2];
|
||||
# Tag matched, assign value to "tinfo"
|
||||
$tinfo->{"$tag->[1]"}= $tag->[2];
|
||||
}
|
||||
}
|
||||
|
||||
@ -873,8 +931,29 @@ sub mtr_options_from_test_file($$) {
|
||||
mtr_options_from_test_file($tinfo, $sourced_file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub print_testcases {
|
||||
my (@cases)= @_;
|
||||
|
||||
print "=" x 60, "\n";
|
||||
foreach my $test (@cases){
|
||||
print "[", $test->{name}, "]", "\n";
|
||||
while ((my ($key, $value)) = each(%$test)) {
|
||||
print " ", $key, "=";
|
||||
if (ref $value eq "ARRAY") {
|
||||
print join(", ", @$value);
|
||||
} else {
|
||||
print $value;
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
print "=" x 60, "\n";
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
@ -280,4 +280,33 @@ sub mtr_cmp_opts ($$) {
|
||||
return 0; # They are the same
|
||||
}
|
||||
|
||||
#
|
||||
# Compare two arrays and put all unequal elements into a new one
|
||||
#
|
||||
sub mtr_diff_opts ($$) {
|
||||
my $l1= shift;
|
||||
my $l2= shift;
|
||||
my $f;
|
||||
my $l= [];
|
||||
foreach my $e1 (@$l1)
|
||||
{
|
||||
$f= undef;
|
||||
foreach my $e2 (@$l2)
|
||||
{
|
||||
$f= 1 unless ($e1 ne $e2);
|
||||
}
|
||||
push(@$l, $e1) unless (defined $f);
|
||||
}
|
||||
foreach my $e2 (@$l2)
|
||||
{
|
||||
$f= undef;
|
||||
foreach my $e1 (@$l1)
|
||||
{
|
||||
$f= 1 unless ($e1 ne $e2);
|
||||
}
|
||||
push(@$l, $e2) unless (defined $f);
|
||||
}
|
||||
return $l;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -50,9 +50,13 @@ my $tot_real_time= 0;
|
||||
|
||||
sub mtr_report_test_name ($) {
|
||||
my $tinfo= shift;
|
||||
my $tname= $tinfo->{name};
|
||||
|
||||
_mtr_log("$tinfo->{name}");
|
||||
printf "%-30s ", $tinfo->{'name'};
|
||||
$tname.= " '$tinfo->{combination}'"
|
||||
if defined $tinfo->{combination};
|
||||
|
||||
_mtr_log($tname);
|
||||
printf "%-30s ", $tname;
|
||||
}
|
||||
|
||||
sub mtr_report_test_skipped ($) {
|
||||
@ -365,6 +369,24 @@ sub mtr_report_stats ($) {
|
||||
/Slave: Can't DROP 'c7'.* 1091/ or
|
||||
/Slave: Key column 'c6'.* 1072/ or
|
||||
|
||||
# rpl_idempotency.test produces warnings for the slave.
|
||||
($testname eq 'rpl.rpl_idempotency' and
|
||||
(/Slave: Can\'t find record in \'t1\' Error_code: 1032/ or
|
||||
/Slave: Cannot add or update a child row: a foreign key constraint fails .* Error_code: 1452/
|
||||
)) or
|
||||
|
||||
# These tests does "kill" on queries, causing sporadic errors when writing to logs
|
||||
(($testname eq 'rpl.rpl_skip_error' or
|
||||
$testname eq 'rpl.rpl_err_ignoredtable' or
|
||||
$testname eq 'binlog.binlog_killed_simulate' or
|
||||
$testname eq 'binlog.binlog_killed') and
|
||||
(/Failed to write to mysql\.\w+_log/
|
||||
)) or
|
||||
|
||||
# rpl_temporary has an error on slave that can be ignored
|
||||
($testname eq 'rpl.rpl_temporary' and
|
||||
(/Slave: Can\'t find record in \'user\' Error_code: 1032/
|
||||
))
|
||||
# maria-recovery.test has warning about missing log file
|
||||
/Can't get stat of '.*maria_log.00/ or
|
||||
# and about marked-corrupted table
|
||||
|
Reference in New Issue
Block a user