Commit e7305b8c authored by anozdrin@mysql.com's avatar anozdrin@mysql.com

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-im-tests-fw
parents e55126d0 d30534c9
...@@ -50,6 +50,7 @@ dist-hook: ...@@ -50,6 +50,7 @@ dist-hook:
$(distdir)/std_data $(distdir)/lib $(distdir)/std_data $(distdir)/lib
-$(INSTALL_DATA) $(srcdir)/t/*.def $(distdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.def $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.test $(distdir)/t $(INSTALL_DATA) $(srcdir)/t/*.test $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.imtest $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.sql $(distdir)/t $(INSTALL_DATA) $(srcdir)/t/*.sql $(distdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.disabled $(distdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(distdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t
...@@ -73,6 +74,7 @@ install-data-local: ...@@ -73,6 +74,7 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir) $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir)
-$(INSTALL_DATA) $(srcdir)/t/*.def $(DESTDIR)$(testdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.def $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.imtest $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.sql $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.sql $(DESTDIR)$(testdir)/t
-$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t
$(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t
......
...@@ -8,7 +8,7 @@ use File::Basename; ...@@ -8,7 +8,7 @@ use File::Basename;
use strict; use strict;
sub collect_test_cases ($); sub collect_test_cases ($);
sub collect_one_test_case ($$$$$$); sub collect_one_test_case ($$$$$$$);
############################################################################## ##############################################################################
# #
...@@ -40,13 +40,84 @@ sub collect_test_cases ($) { ...@@ -40,13 +40,84 @@ sub collect_test_cases ($) {
if ( @::opt_cases ) if ( @::opt_cases )
{ {
foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort foreach my $tname ( @::opt_cases ) { # Run in specified order, no sort
$tname= basename($tname, ".test"); my $elem= undef;
my $elem= "$tname.test"; my $component_id= undef;
if ( ! -f "$testdir/$elem")
# Get rid of directory part (path). Leave the extension since it is used
# to understand type of the test.
$tname = basename($tname);
# Check if the extenstion has been specified.
if ( mtr_match_extension($tname, "test") )
{
$elem= $tname;
$tname=~ s/\.test$//;
$component_id= 'mysqld';
}
elsif ( mtr_match_extension($tname, "imtest") )
{
$elem= $tname;
$tname =~ s/\.imtest$//;
$component_id= 'im';
if ( $::glob_use_embedded_server )
{
mtr_report(
"Instance Manager's tests are not available in embedded mode." .
"Test case '$tname' is skipped.");
next;
}
unless ( $::exe_im )
{
mtr_report(
"Instance Manager executable is unavailable. " .
"Test case '$tname' is skipped.");
next;
}
}
# If target component is known, check that the specified test case
# exists.
#
# Otherwise, try to guess the target component.
if ( defined $component_id )
{ {
mtr_error("Test case $tname ($testdir/$elem) is not found"); if ( ! -f "$testdir/$elem")
{
mtr_error("Test case $tname ($testdir/$elem) is not found");
}
} }
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,{}); else
{
my $mysqld_test_exists = -f "$testdir/$tname.test";
my $im_test_exists = -f "$testdir/$tname.imtest";
if ( $mysqld_test_exists && $im_test_exists )
{
mtr_error("Ambiguos test case name ($tname)");
}
elsif ( ! $mysqld_test_exists && !$im_test_exists )
{
mtr_error("Test case $tname is not found");
}
elsif ( $mysqld_test_exists )
{
$elem= "$tname.test";
$component_id= 'mysqld';
}
elsif ( $im_test_exists )
{
$elem= "$tname.imtest";
$component_id= 'im';
}
}
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,{},
$component_id);
} }
closedir TESTDIR; closedir TESTDIR;
} }
...@@ -70,11 +141,26 @@ sub collect_test_cases ($) { ...@@ -70,11 +141,26 @@ sub collect_test_cases ($) {
} }
foreach my $elem ( sort readdir(TESTDIR) ) { foreach my $elem ( sort readdir(TESTDIR) ) {
my $tname= mtr_match_extension($elem,"test"); my $component_id= undef;
next if ! defined $tname; my $tname= undef;
if ($tname= mtr_match_extension($elem, 'test'))
{
$component_id = 'mysqld';
}
elsif ($tname= mtr_match_extension($elem, 'imtest'))
{
$component_id = 'im';
}
else
{
next;
}
next if $::opt_do_test and ! defined mtr_match_prefix($elem,$::opt_do_test); next if $::opt_do_test and ! defined mtr_match_prefix($elem,$::opt_do_test);
collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled); collect_one_test_case($testdir,$resdir,$tname,$elem,$cases,\%disabled,
$component_id);
} }
closedir TESTDIR; closedir TESTDIR;
} }
...@@ -112,13 +198,14 @@ sub collect_test_cases ($) { ...@@ -112,13 +198,14 @@ sub collect_test_cases ($) {
############################################################################## ##############################################################################
sub collect_one_test_case($$$$$$) { sub collect_one_test_case($$$$$$$) {
my $testdir= shift; my $testdir= shift;
my $resdir= shift; my $resdir= shift;
my $tname= shift; my $tname= shift;
my $elem= shift; my $elem= shift;
my $cases= shift; my $cases= shift;
my $disabled=shift; my $disabled=shift;
my $component_id= shift;
my $path= "$testdir/$elem"; my $path= "$testdir/$elem";
...@@ -138,6 +225,7 @@ sub collect_one_test_case($$$$$$) { ...@@ -138,6 +225,7 @@ sub collect_one_test_case($$$$$$) {
my $tinfo= {}; my $tinfo= {};
$tinfo->{'name'}= $tname; $tinfo->{'name'}= $tname;
$tinfo->{'result_file'}= "$resdir/$tname.result"; $tinfo->{'result_file'}= "$resdir/$tname.result";
$tinfo->{'component_id'} = $component_id;
push(@$cases, $tinfo); push(@$cases, $tinfo);
if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) ) if ( $::opt_skip_test and defined mtr_match_prefix($tname,$::opt_skip_test) )
...@@ -188,6 +276,7 @@ sub collect_one_test_case($$$$$$) { ...@@ -188,6 +276,7 @@ sub collect_one_test_case($$$$$$) {
my $master_sh= "$testdir/$tname-master.sh"; my $master_sh= "$testdir/$tname-master.sh";
my $slave_sh= "$testdir/$tname-slave.sh"; my $slave_sh= "$testdir/$tname-slave.sh";
my $disabled_file= "$testdir/$tname.disabled"; my $disabled_file= "$testdir/$tname.disabled";
my $im_opt_file= "$testdir/$tname-im.opt";
$tinfo->{'master_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; $tinfo->{'master_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : [];
$tinfo->{'slave_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : []; $tinfo->{'slave_opt'}= $::glob_win32 ? ["--default-time-zone=+3:00"] : [];
...@@ -290,6 +379,15 @@ sub collect_one_test_case($$$$$$) { ...@@ -290,6 +379,15 @@ sub collect_one_test_case($$$$$$) {
} }
} }
if ( -f $im_opt_file )
{
$tinfo->{'im_opts'} = mtr_get_opts_from_file($im_opt_file);
}
else
{
$tinfo->{'im_opts'} = [];
}
# FIXME why this late? # FIXME why this late?
if ( $disabled->{$tname} ) if ( $disabled->{$tname} )
{ {
......
...@@ -12,16 +12,17 @@ use strict; ...@@ -12,16 +12,17 @@ use strict;
#use POSIX ":sys_wait_h"; #use POSIX ":sys_wait_h";
use POSIX 'WNOHANG'; use POSIX 'WNOHANG';
sub mtr_run ($$$$$$); sub mtr_run ($$$$$$;$);
sub mtr_spawn ($$$$$$); sub mtr_spawn ($$$$$$;$);
sub mtr_stop_mysqld_servers ($); sub mtr_stop_mysqld_servers ($);
sub mtr_kill_leftovers (); sub mtr_kill_leftovers ();
sub mtr_record_dead_children (); sub mtr_record_dead_children ();
sub mtr_exit ($); sub mtr_exit ($);
sub sleep_until_file_created ($$$); sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
# static in C # static in C
sub spawn_impl ($$$$$$$); sub spawn_impl ($$$$$$$$);
############################################################################## ##############################################################################
# #
...@@ -32,37 +33,43 @@ sub spawn_impl ($$$$$$$); ...@@ -32,37 +33,43 @@ sub spawn_impl ($$$$$$$);
# This function try to mimic the C version used in "netware/mysql_test_run.c" # 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" # FIXME learn it to handle append mode as well, a "new" flag or a "append"
sub mtr_run ($$$$$$) { sub mtr_run ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file,
$spawn_opts);
} }
sub mtr_run_test ($$$$$$) { sub mtr_run_test ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file,
$spawn_opts);
} }
sub mtr_spawn ($$$$$$) { sub mtr_spawn ($$$$$$;$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $input= shift; my $input= shift;
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; my $pid_file= shift;
my $spawn_opts= shift;
return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file); return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file,
$spawn_opts);
} }
...@@ -72,7 +79,7 @@ sub mtr_spawn ($$$$$$) { ...@@ -72,7 +79,7 @@ sub mtr_spawn ($$$$$$) {
# #
############################################################################## ##############################################################################
sub spawn_impl ($$$$$$$) { sub spawn_impl ($$$$$$$$) {
my $path= shift; my $path= shift;
my $arg_list_t= shift; my $arg_list_t= shift;
my $mode= shift; my $mode= shift;
...@@ -80,6 +87,7 @@ sub spawn_impl ($$$$$$$) { ...@@ -80,6 +87,7 @@ sub spawn_impl ($$$$$$$) {
my $output= shift; my $output= shift;
my $error= shift; my $error= shift;
my $pid_file= shift; # FIXME my $pid_file= shift; # FIXME
my $spawn_opts= shift;
if ( $::opt_script_debug ) if ( $::opt_script_debug )
{ {
...@@ -89,6 +97,18 @@ sub spawn_impl ($$$$$$$) { ...@@ -89,6 +97,18 @@ sub spawn_impl ($$$$$$$) {
print STDERR "#### ", "STDOUT $output\n" if $output; print STDERR "#### ", "STDOUT $output\n" if $output;
print STDERR "#### ", "STDERR $error\n" if $error; print STDERR "#### ", "STDERR $error\n" if $error;
print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n"; print STDERR "#### ", "$mode : $path ", join(" ",@$arg_list_t), "\n";
print STDERR "#### ", "spawn options:\n";
if ($spawn_opts)
{
foreach my $key (sort keys %{$spawn_opts})
{
print STDERR "#### ", " - $key: $spawn_opts->{$key}\n";
}
}
else
{
print STDERR "#### ", " none\n";
}
print STDERR "#### ", "-" x 78, "\n"; print STDERR "#### ", "-" x 78, "\n";
} }
...@@ -135,9 +155,16 @@ sub spawn_impl ($$$$$$$) { ...@@ -135,9 +155,16 @@ sub spawn_impl ($$$$$$$) {
# $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c"; # $ENV{'COMSPEC'}= "$::glob_cygwin_shell -c";
} }
my $log_file_open_mode = '>';
if ($spawn_opts and $spawn_opts->{'append_log_file'})
{
$log_file_open_mode = '>>';
}
if ( $output ) if ( $output )
{ {
if ( ! open(STDOUT,">",$output) ) if ( ! open(STDOUT,$log_file_open_mode,$output) )
{ {
mtr_error("can't redirect STDOUT to \"$output\": $!"); mtr_error("can't redirect STDOUT to \"$output\": $!");
} }
...@@ -154,7 +181,7 @@ sub spawn_impl ($$$$$$$) { ...@@ -154,7 +181,7 @@ sub spawn_impl ($$$$$$$) {
} }
else else
{ {
if ( ! open(STDERR,">",$error) ) if ( ! open(STDERR,$log_file_open_mode,$error) )
{ {
mtr_error("can't redirect STDERR to \"$output\": $!"); mtr_error("can't redirect STDERR to \"$output\": $!");
} }
...@@ -534,16 +561,7 @@ sub mtr_stop_mysqld_servers ($) { ...@@ -534,16 +561,7 @@ sub mtr_stop_mysqld_servers ($) {
start_reap_all(); # Avoid zombies start_reap_all(); # Avoid zombies
SIGNAL: SIGNAL:
foreach my $sig (15,9) mtr_kill_processes(\keys (%mysqld_pids));
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, keys %mysqld_pids);
while ( $retries-- and kill(0, keys %mysqld_pids) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
stop_reap_all(); # Get into control again stop_reap_all(); # Get into control again
...@@ -805,7 +823,7 @@ sub sleep_until_file_created ($$$) { ...@@ -805,7 +823,7 @@ sub sleep_until_file_created ($$$) {
} }
# Check if it died after the fork() was successful # Check if it died after the fork() was successful
if ( waitpid($pid,&WNOHANG) == $pid ) if ( $pid > 0 && waitpid($pid,&WNOHANG) == $pid )
{ {
return 0; return 0;
} }
...@@ -826,6 +844,21 @@ sub sleep_until_file_created ($$$) { ...@@ -826,6 +844,21 @@ sub sleep_until_file_created ($$$) {
} }
sub mtr_kill_processes ($) {
my $pids = shift;
foreach my $sig (15,9)
{
my $retries= 20; # FIXME 20 seconds, this is silly!
kill($sig, @{$pids});
while ( $retries-- and kill(0, @{$pids}) )
{
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
}
}
}
############################################################################## ##############################################################################
# #
# When we exit, we kill off all children # When we exit, we kill off all children
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment