1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Automerge with 5.1

This commit is contained in:
Michael Widenius
2010-08-25 01:44:50 +03:00
167 changed files with 1625 additions and 925 deletions

View File

@ -6,7 +6,6 @@ use strict;
use warnings;
use Carp;
sub new {
my ($class, $option_name, $option_value)= @_;
my $self= bless { name => $option_name,
@ -61,7 +60,7 @@ sub insert {
$option->{value}= $value;
}
else {
my $option= My::Config::Option->new($option_name, $value);
$option= My::Config::Option->new($option_name, $value);
# Insert option in list
push(@{$self->{options}}, $option);
# Insert option in hash
@ -163,6 +162,62 @@ sub if_exist {
return $option->value();
}
package My::Config::Group::ENV;
our @ISA=qw(My::Config::Group);
use strict;
use warnings;
use Carp;
sub new {
my ($class, $group_name)= @_;
bless My::Config::Group->new($group_name), $class;
}
#
# Return value for an option in the group, fail if it does not exist
#
sub value {
my ($self, $option_name)= @_;
my $option= $self->option($option_name);
if (! defined($option) and defined $ENV{$option_name}) {
my $value= $ENV{$option_name};
$option= My::Config::Option->new($option_name, $value);
}
croak "No option named '$option_name' in group '$self->{name}'"
if ! defined($option);
return $option->value();
}
package My::Config::Group::OPT;
our @ISA=qw(My::Config::Group);
use strict;
use warnings;
use Carp;
sub new {
my ($class, $group_name)= @_;
bless My::Config::Group->new($group_name), $class;
}
sub options {
my ($self)= @_;
()
}
sub value {
my ($self, $option_name)= @_;
my $option= $self->option($option_name);
croak "No option named '$option_name' in group '$self->{name}'"
if ! defined($option);
return $option->value()->();
}
package My::Config;
@ -182,7 +237,10 @@ sub new {
my ($class, $path)= @_;
my $group_name= undef;
my $self= bless { groups => [] }, $class;
my $self= bless { groups => [
My::Config::Group::ENV->new('ENV'),
My::Config::Group::OPT->new('OPT'),
] }, $class;
my $F= IO::File->new($path, "<")
or croak "Could not open '$path': $!";
@ -199,19 +257,13 @@ sub new {
}
# Magic #! comments
elsif ( $line =~ /^#\!/) {
my $magic= $line;
elsif ( $line =~ /^(#\!\S+)(?:\s*(.*?)\s*)?$/) {
my ($magic, $arg)= ($1, $2);
croak "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;
$self->insert($group_name, $magic, $arg);
}
# Empty lines
@ -236,7 +288,7 @@ sub new {
}
# <option>
elsif ( $line =~ /^([\@\w-]+)\s*$/ ) {
elsif ( $line =~ /^(#?[\w-]+)\s*$/ ) {
my $option= $1;
croak "Found option '$option' outside of group"
@ -247,7 +299,7 @@ sub new {
}
# <option>=<value>
elsif ( $line =~ /^([\@\w-]+)\s*=\s*(.*?)\s*$/ ) {
elsif ( $line =~ /^(#?[\w-]+)\s*=\s*(.*?)\s*$/ ) {
my $option= $1;
my $value= $2;
@ -256,10 +308,17 @@ sub new {
#print "$option=$value\n";
$self->insert($group_name, $option, $value);
} else {
croak "Unexpected line '$line' found in '$path'";
}
# Comments
elsif ( $line =~ /^#/ || $line =~ /^;/) {
# Skip comment
next;
}
else {
croak "Unexpected line '$line' found in '$path'";
}
}
undef $F; # Close the file
@ -437,44 +496,4 @@ sub exists {
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 croak "Could not open '$path': $!";
print $F $self;
undef $F; # Close the file
}
1;

View File

@ -57,16 +57,12 @@ sub fix_pidfile {
sub fix_port {
my ($self, $config, $group_name, $group)= @_;
my $hostname= $group->value('#host');
return $self->{HOSTS}->{$hostname}++;
return $self->{PORT}++;
}
sub fix_host {
my ($self)= @_;
# Get next host from HOSTS array
my @hosts= keys(%{$self->{HOSTS}});;
my $host_no= $self->{NEXT_HOST}++ % @hosts;
return $hosts[$host_no];
'localhost'
}
sub is_unique {
@ -229,7 +225,7 @@ if (IS_WINDOWS)
sub fix_ndb_mgmd_port {
my ($self, $config, $group_name, $group)= @_;
my $hostname= $group->value('HostName');
return $self->{HOSTS}->{$hostname}++;
return $self->{PORT}++;
}
@ -428,20 +424,24 @@ sub post_check_embedded_group {
sub resolve_at_variable {
my ($self, $config, $group, $option)= @_;
local $_ = $option->value();
my ($res, $after);
# Split the options value on last .
my @parts= split(/\./, $option->value());
my $option_name= pop(@parts);
my $group_name= join('.', @parts);
while (m/(.*?)\@((?:\w+\.)+)(#?[-\w]+)/g) {
my ($before, $group_name, $option_name)= ($1, $2, $3);
$after = $';
chop($group_name);
$group_name =~ s/^\@//; # Remove at
my $from_group= $config->group($group_name)
or croak "There is no group named '$group_name' that ",
"can be used to resolve '$option_name'";
my $from_group= $config->group($group_name)
or croak "There is no group named '$group_name' that ",
"can be used to resolve '$option_name'";
my $value= $from_group->value($option_name);
$res .= $before.$value;
}
$res .= $after;
my $from= $from_group->value($option_name);
$config->insert($group->name(), $option->name(), $from)
$config->insert($group->name(), $option->name(), $res)
}
@ -453,7 +453,7 @@ sub post_fix_resolve_at_variables {
next unless defined $option->value();
$self->resolve_at_variable($config, $group, $option)
if ($option->value() =~ /^\@/);
if ($option->value() =~ /\@/);
}
}
}
@ -595,28 +595,18 @@ sub new_config {
croak "you must pass '$required'" unless defined $args->{$required};
}
# Fill in hosts/port hash
my $hosts= {};
my $baseport= $args->{baseport};
$args->{hosts}= [ 'localhost' ] unless exists($args->{hosts});
foreach my $host ( @{$args->{hosts}} ) {
$hosts->{$host}= $baseport;
}
# Open the config template
my $config= My::Config->new($args->{'template_path'});
my $extra_template_path= $args->{'extra_template_path'};
if ($extra_template_path){
$config->append(My::Config->new($extra_template_path));
}
my $self= bless {
CONFIG => $config,
ARGS => $args,
HOSTS => $hosts,
NEXT_HOST => 0,
PORT => $args->{baseport},
SERVER_ID => 1,
}, $class;
# add auto-options
$config->insert('OPT', 'port' => sub { fix_port($self, $config) });
$config->insert('OPT', 'vardir' => sub { shift->{ARGS}->{vardir} });
{
# Run pre rules

0
mysql-test/lib/My/Handles.pm Executable file → Normal file
View File

View File

@ -120,7 +120,7 @@ sub new {
my $input = delete($opts{'input'});
my $output = delete($opts{'output'});
my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'});
my $verbose = delete($opts{'verbose'}) || $::opt_verbose;
my $nocore = delete($opts{'nocore'});
my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'});

View File

@ -0,0 +1,10 @@
# A default suite class that is used for all suites without their owns suite.pm
# see README.suites for a description
package My::Suite;
sub config_files { () }
sub servers { () }
bless { };

View File

@ -20,6 +20,12 @@ sub new {
return $self;
}
sub fullname {
my ($self)= @_;
$self->{name} . (defined $self->{combination}
? " '$self->{combination}'"
: "")
}
#
# Return a unique key that can be used to

View File

@ -39,7 +39,6 @@ our $enable_disabled;
our $default_storage_engine;
our $opt_with_ndbcluster_only;
our $defaults_file;
our $defaults_extra_file;
our $quick_collect;
sub collect_option {
@ -68,21 +67,10 @@ require "mtr_misc.pl";
my $do_test_reg;
my $skip_test_reg;
# Related to adding InnoDB plugin combinations
my $lib_innodb_plugin;
# If "Quick collect", set to 1 once a test to run has been found.
my $some_test_found;
sub find_innodb_plugin {
$lib_innodb_plugin=
my_find_file($::basedir,
["storage/innodb_plugin", "storage/innodb_plugin/.libs",
"lib/mysql/plugin", "lib/plugin"],
["ha_innodb_plugin.dll", "ha_innodb_plugin.so",
"ha_innodb_plugin.sl"],
NOT_REQUIRED);
}
my $default_suite_object = do 'My/Suite.pm';
sub init_pattern {
my ($from, $what)= @_;
@ -116,8 +104,6 @@ sub collect_test_cases ($$$) {
$do_test_reg= init_pattern($do_test, "--do-test");
$skip_test_reg= init_pattern($skip_test, "--skip-test");
&find_innodb_plugin;
# 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.
@ -188,17 +174,17 @@ sub collect_test_cases ($$$) {
my $opts= $tinfo->{'master_opt'} ? $tinfo->{'master_opt'} : [];
push(@criteria, join("!", sort @{$opts}) . "~");
$sort_criteria{$tinfo->{name}} = join(" ", @criteria);
$sort_criteria{$tinfo->fullname()} = join(" ", @criteria);
}
@$cases = sort {
$sort_criteria{$a->{'name'}} . $a->{'name'} cmp
$sort_criteria{$b->{'name'}} . $b->{'name'}; } @$cases;
$sort_criteria{$a->fullname()} . $a->fullname() cmp
$sort_criteria{$b->fullname()} . $b->fullname() } @$cases;
# For debugging the sort-order
# foreach my $tinfo (@$cases)
# {
# print("$sort_criteria{$tinfo->{'name'}} -> \t$tinfo->{'name'}\n");
# print $sort_criteria{$tinfo->fullname()}," -> \t",$tinfo->fullname(),"\n";
# }
}
@ -310,6 +296,17 @@ sub collect_one_suite
mtr_verbose("testdir: $testdir");
mtr_verbose("resdir: $resdir");
#
# Load the Suite object
#
unless ($::suites{$suite}) {
if (-f "$suitedir/suite.pm") {
$::suites{$suite} = do "$suitedir/suite.pm";
} else {
$::suites{$suite} = $default_suite_object;
}
}
# ----------------------------------------------------------------------
# Build a hash of disabled testcases for this suite
# ----------------------------------------------------------------------
@ -438,14 +435,16 @@ sub collect_one_suite
{
# Read combinations file in my.cnf format
mtr_verbose("Read combinations file");
my %env_filter = map { $_ => 1 } split /:/, $ENV{"\U${suite}_COMBINATIONS"};
my $config= My::Config->new($combination_file);
foreach my $group ($config->groups()) {
my $comb= {};
$comb->{name}= $group->name();
next if %env_filter and not $env_filter{$comb->{name}};
foreach my $option ( $group->options() ) {
push(@{$comb->{comb_opt}}, $option->option());
}
push(@combinations, $comb);
push(@combinations, $comb) if $comb->{comb_opt};
}
}
@ -539,28 +538,7 @@ sub optimize_cases {
# support it
# =======================================================
#print "binlog_format: $binlog_format\n";
if (defined $binlog_format )
{
# =======================================================
# Fixed --binlog-format=x specified on command line
# =======================================================
if ( defined $tinfo->{'binlog_formats'} )
{
#print "binlog_formats: ". join(", ", @{$tinfo->{binlog_formats}})."\n";
# The test supports different binlog formats
# check if the selected one is ok
my $supported=
grep { $_ eq $binlog_format } @{$tinfo->{'binlog_formats'}};
if ( !$supported )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}=
"Doesn't support --binlog-format='$binlog_format'";
}
}
}
else
if (not defined $binlog_format )
{
# =======================================================
# Use dynamic switching of binlog format
@ -623,10 +601,6 @@ sub optimize_cases {
$tinfo->{'ndb_test'}= 1
if ( $default_engine =~ /^ndb/i );
$tinfo->{'innodb_test'}= 1
if ( $default_engine =~ /^innodb/i );
$tinfo->{'pbxt_test'}= 1
if ( $default_engine =~ /^pbxt/i );
}
}
@ -758,7 +732,7 @@ sub collect_one_test_case {
name => "$suitename.$tname",
shortname => $tname,
path => "$testdir/$filename",
suite => $suitename,
);
my $result_file= "$resdir/$tname.result";
@ -880,7 +854,7 @@ sub collect_one_test_case {
if ( -f "$testdir/$tname.slave-mi");
tags_from_test_file($tinfo,"$testdir/${tname}.test");
my @source_files = tags_from_test_file($tinfo,"$testdir/${tname}.test");
# Get default storage engine from suite.opt file
@ -897,12 +871,6 @@ sub collect_one_test_case {
$tinfo->{'ndb_test'}= 1
if ( $local_default_storage_engine =~ /^ndb/i );
$tinfo->{'innodb_test'}= 1
if ( $local_default_storage_engine =~ /^innodb/i );
$tinfo->{'pbxt_test'}= 1
if ( $local_default_storage_engine =~ /^pbxt/i );
}
if ( $tinfo->{'big_test'} and ! $::opt_big_test )
@ -949,72 +917,6 @@ sub collect_one_test_case {
}
}
if ($tinfo->{'federated_test'})
{
# This is a test that needs federated, enable it
push(@{$tinfo->{'master_opt'}}, "--loose-federated");
push(@{$tinfo->{'slave_opt'}}, "--loose-federated");
}
if ( $tinfo->{'innodb_test'} )
{
# This is a test that needs innodb
if ( $::mysqld_variables{'innodb'} eq "OFF" ||
! exists $::mysqld_variables{'innodb'} )
{
# innodb is not supported, skip it
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "No innodb support";
return $tinfo;
}
}
elsif ( $tinfo->{'innodb_plugin_test'} )
{
# This is a test that needs the innodb plugin
if (&find_innodb_plugin)
{
my $sep= (IS_WINDOWS) ? ';' : ':';
my $plugin_filename= basename($lib_innodb_plugin);
my $plugin_list=
"innodb=$plugin_filename$sep" .
"innodb_trx=$plugin_filename$sep" .
"innodb_locks=$plugin_filename$sep" .
"innodb_lock_waits=$plugin_filename$sep" .
"innodb_cmp=$plugin_filename$sep" .
"innodb_cmp_reset=$plugin_filename$sep" .
"innodb_cmpmem=$plugin_filename$sep" .
"innodb_cmpmem_reset=$plugin_filename";
foreach my $k ('master_opt', 'slave_opt') {
push(@{$tinfo->{$k}}, '--ignore-builtin-innodb');
push(@{$tinfo->{$k}}, '--plugin-dir=' . dirname($lib_innodb_plugin));
push(@{$tinfo->{$k}}, "--plugin-load=$plugin_list");
}
}
}
else
{
push(@{$tinfo->{'master_opt'}}, "--loose-skip-innodb");
push(@{$tinfo->{'slave_opt'}}, "--loose-skip-innodb");
}
if ( $tinfo->{'need_binlog'} )
{
if (grep(/^--skip-log-bin/, @::opt_extra_mysqld_opt) )
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= "Test needs binlog";
return $tinfo;
}
}
else
{
# Test does not need binlog, add --skip-binlog to
# the options used when starting
push(@{$tinfo->{'master_opt'}}, "--loose-skip-log-bin");
push(@{$tinfo->{'slave_opt'}}, "--loose-skip-log-bin");
}
if ( $tinfo->{'rpl_test'} )
{
if ( $skip_rpl )
@ -1085,28 +987,6 @@ sub collect_one_test_case {
$tinfo->{template_path}= $config;
}
if ( $tinfo->{'pbxt_test'} )
{
# This is a test that needs pbxt
if ( $::mysqld_variables{'pbxt'} eq "OFF" ||
! exists $::mysqld_variables{'pbxt'} )
{
# Engine is not supported, skip it
$tinfo->{'skip'}= 1;
return $tinfo;
}
}
else
{
# Only disable engine if it's on by default (to avoid warnings about
# not existing loose options
if ( $::mysqld_variables{'pbxt'} eq "ON")
{
push(@{$tinfo->{'master_opt'}}, "--loose-skip-pbxt");
push(@{$tinfo->{'slave_opt'}}, "--loose-skip-pbxt");
}
}
if ( $tinfo->{'example_plugin_test'} )
{
if ( !$ENV{'HA_EXAMPLE_SO'} )
@ -1127,27 +1007,27 @@ sub collect_one_test_case {
}
}
# Set extra config file to use
if (defined $defaults_extra_file) {
$tinfo->{extra_template_path}= $defaults_extra_file;
if (not ref $::suites{$tinfo->{suite}})
{
$tinfo->{'skip'}= 1;
$tinfo->{'comment'}= $::suites{$tinfo->{suite}};
return $tinfo;
}
# ----------------------------------------------------------------------
# Append mysqld extra options to both master and slave
# Append mysqld extra options to master and slave, as appropriate
# ----------------------------------------------------------------------
for (@source_files) {
s/\.\w+$//;
process_opts_file($tinfo, "$_.opt", 'master_opt');
process_opts_file($tinfo, "$_.opt", 'slave_opt');
process_opts_file($tinfo, "$_-master.opt", 'master_opt');
process_opts_file($tinfo, "$_-slave.opt", 'slave_opt');
}
push(@{$tinfo->{'master_opt'}}, @::opt_extra_mysqld_opt);
push(@{$tinfo->{'slave_opt'}}, @::opt_extra_mysqld_opt);
# ----------------------------------------------------------------------
# Add master opts, extra options only for master
# ----------------------------------------------------------------------
process_opts_file($tinfo, "$testdir/$tname-master.opt", 'master_opt');
# ----------------------------------------------------------------------
# Add slave opts, list of extra option only for slave
# ----------------------------------------------------------------------
process_opts_file($tinfo, "$testdir/$tname-slave.opt", 'slave_opt');
return $tinfo;
}
@ -1157,24 +1037,6 @@ sub collect_one_test_case {
# the specified value in "tinfo"
my @tags=
(
["include/have_binlog_format_row.inc", "binlog_formats", ["row"]],
["include/have_binlog_format_statement.inc", "binlog_formats", ["statement"]],
["include/have_binlog_format_mixed.inc", "binlog_formats", ["mixed"]],
["include/have_binlog_format_mixed_or_row.inc",
"binlog_formats", ["mixed", "row"]],
["include/have_binlog_format_mixed_or_statement.inc",
"binlog_formats", ["mixed", "statement"]],
["include/have_binlog_format_row_or_statement.inc",
"binlog_formats", ["row", "statement"]],
["include/have_log_bin.inc", "need_binlog", 1],
["include/have_innodb.inc", "innodb_test", 1],
["include/have_innodb_plugin.inc", "innodb_plugin_test", 1],
["include/have_real.inc", "innodb_test", 1],
["include/have_real_innodb_plugin.inc", "innodb_plugin_test", 1],
["include/have_xtradb.inc", "innodb_test", 1],
["include/have_pbxt.inc", "pbxt_test", 1],
["include/big_test.inc", "big_test", 1],
["include/have_debug.inc", "need_debug", 1],
["include/have_ndb.inc", "ndb_test", 1],
@ -1182,7 +1044,6 @@ my @tags=
["include/master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "rpl_test", 1],
["include/ndb_master-slave.inc", "ndb_test", 1],
["federated.inc", "federated_test", 1],
["include/not_embedded.inc", "not_embedded", 1],
["include/not_valgrind.inc", "not_valgrind", 1],
["include/have_example_plugin.inc", "example_plugin_test", 1],
@ -1196,6 +1057,7 @@ sub tags_from_test_file {
my $file= shift;
#mtr_verbose("$file");
my $F= IO::File->new($file) or mtr_error("can't open file \"$file\": $!");
my @all_files=($file);
while ( my $line= <$F> )
{
@ -1231,13 +1093,13 @@ sub tags_from_test_file {
# Only source the file if it exists, we may get
# false positives in the regexes above if someone
# writes "source nnnn;" in a test case(such as mysqltest.test)
tags_from_test_file($tinfo, $sourced_file);
unshift @all_files, tags_from_test_file($tinfo, $sourced_file);
last;
}
}
}
}
@all_files;
}
sub unspace {
@ -1250,6 +1112,7 @@ sub unspace {
sub opts_from_file ($) {
my $file= shift;
local $_;
open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
my @args;

View File

@ -61,14 +61,10 @@ sub _name {
sub _mtr_report_test_name ($) {
my $tinfo= shift;
my $tname= $tinfo->{name};
my $tname= $tinfo->fullname();
return unless defined $verbose;
# Add combination name if any
$tname.= " '$tinfo->{combination}'"
if defined $tinfo->{combination};
print _name(). _timestamp();
printf "%-40s ", $tname;
my $worker = $tinfo->{worker};