diff options
Diffstat (limited to 'mysql-test/lib')
-rw-r--r-- | mysql-test/lib/My/ConfigFactory.pm | 8 | ||||
-rw-r--r-- | mysql-test/lib/My/CoreDump.pm | 127 | ||||
-rw-r--r-- | mysql-test/lib/My/Platform.pm | 10 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess.pm | 2 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/safe_process.cc | 16 | ||||
-rwxr-xr-x | mysql-test/lib/My/SafeProcess/safe_process_win.cc | 19 | ||||
-rw-r--r-- | mysql-test/lib/mtr_gcov.pl | 58 | ||||
-rw-r--r-- | mysql-test/lib/mtr_report.pm | 40 | ||||
-rw-r--r-- | mysql-test/lib/mtr_unique.pm | 2 |
9 files changed, 238 insertions, 44 deletions
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm index 567a05ac7a1..852f706c858 100644 --- a/mysql-test/lib/My/ConfigFactory.pm +++ b/mysql-test/lib/My/ConfigFactory.pm @@ -116,8 +116,8 @@ sub fix_tmpdir { sub fix_log_error { my ($self, $config, $group_name, $group)= @_; - my $dir= dirname($group->value('datadir')); - return "$dir/mysqld.err"; + my $dir= $self->{ARGS}->{vardir}; + return "$dir/log/$group_name.err"; } sub fix_log { @@ -203,7 +203,7 @@ my @mysqld_rules= { '#host' => \&fix_host }, { 'port' => \&fix_port }, { 'socket' => \&fix_socket }, - { 'log-error' => \&fix_log_error }, + { '#log-error' => \&fix_log_error }, { 'log' => \&fix_log }, { 'log-slow-queries' => \&fix_log_slow_queries }, { '#user' => sub { return shift->{ARGS}->{user} || ""; } }, @@ -389,7 +389,7 @@ sub post_check_embedded_group { my @no_copy = ( - 'log-error', # Embedded server writes stderr to mysqltest's log file + '#log-error', # Embedded server writes stderr to mysqltest's log file 'slave-net-timeout', # Embedded server are not build with replication ); diff --git a/mysql-test/lib/My/CoreDump.pm b/mysql-test/lib/My/CoreDump.pm index 599f9ccbfca..f3e9f521384 100644 --- a/mysql-test/lib/My/CoreDump.pm +++ b/mysql-test/lib/My/CoreDump.pm @@ -104,9 +104,136 @@ EOF } +# Check that Debugging tools for Windows are installed +sub cdb_check { + `cdb -? 2>&1`; + if ($? >> 8) + { + print "Cannot find cdb. Please Install Debugging tools for Windows\n"; + print "from http://www.microsoft.com/whdc/devtools/debugging/"; + if($ENV{'ProgramW6432'}) + { + print "install64bit.mspx (native x64 version)\n"; + } + else + { + print "installx86.mspx\n"; + } + } +} + + +sub _cdb { + my ($core_name)= @_; + print "\nTrying 'cdb' to get a backtrace\n"; + return unless -f $core_name; + + # Try to set environment for debugging tools for Windows + if ($ENV{'PATH'} !~ /Debugging Tools/) + { + if ($ENV{'ProgramW6432'}) + { + # On x64 computer + $ENV{'PATH'}.= ";".$ENV{'ProgramW6432'}."\\Debugging Tools For Windows (x64)"; + } + else + { + # On x86 computer. Newest versions of Debugging tools are installed in the + # directory with (x86) suffix, older versions did not have this suffix. + $ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows (x86)"; + $ENV{'PATH'}.= ";".$ENV{'ProgramFiles'}."\\Debugging Tools For Windows"; + } + } + + + # Read module list, find out the name of executable and + # build symbol path (required by cdb if executable was built on + # different machine) + my $tmp_name= $core_name.".cdb_lmv"; + `cdb -z $core_name -c \"lmv;q\" > $tmp_name 2>&1`; + if ($? >> 8) + { + unlink($tmp_name); + # check if cdb is installed and complain if not + cdb_check(); + return; + } + + open(temp,"< $tmp_name"); + my %dirhash=(); + while(<temp>) + { + if($_ =~ /Image path\: (.*)/) + { + if (rindex($1,'\\') != -1) + { + my $dir= substr($1, 0, rindex($1,'\\')); + $dirhash{$dir}++; + } + } + } + close(temp); + unlink($tmp_name); + + my $image_path= join(";", (keys %dirhash),"."); + + # For better callstacks, setup _NT_SYMBOL_PATH to include + # OS symbols. Note : Dowloading symbols for the first time + # can take some minutes + if (!$ENV{'_NT_SYMBOL_PATH'}) + { + my $windir= $ENV{'windir'}; + my $symbol_cache= substr($windir ,0, index($windir,'\\'))."\\cdb_symbols"; + + print "OS debug symbols will be downloaded and stored in $symbol_cache.\n"; + print "You can control the location of symbol cache with _NT_SYMBOL_PATH\n"; + print "environment variable. Please refer to Microsoft KB article\n"; + print "http://support.microsoft.com/kb/311503 for details about _NT_SYMBOL_PATH\n"; + print "-------------------------------------------------------------------------\n"; + + $ENV{'_NT_SYMBOL_PATH'}.= + "srv*".$symbol_cache."*http://msdl.microsoft.com/download/symbols"; + } + + my $symbol_path= $image_path.";".$ENV{'_NT_SYMBOL_PATH'}; + + + # Run cdb. Use "analyze" extension to print crashing thread stacktrace + # and "uniqstack" to print other threads + + my $cdb_cmd = "!sym prompts off; !analyze -v; .ecxr; !for_each_frame dv /t;!uniqstack -p;q"; + my $cdb_output= + `cdb -z $core_name -i "$image_path" -y "$symbol_path" -t 0 -lines -c "$cdb_cmd" 2>&1`; + return if $? >> 8; + return unless $cdb_output; + + # Remove comments (lines starting with *), stack pointer and frame + # pointer adresses and offsets to function to make output better readable + $cdb_output=~ s/^\*.*\n//gm; + $cdb_output=~ s/^([\:0-9a-fA-F\`]+ )+//gm; + $cdb_output=~ s/^ChildEBP RetAddr//gm; + $cdb_output=~ s/^Child\-SP RetAddr Call Site//gm; + $cdb_output=~ s/\+0x([0-9a-fA-F]+)//gm; + + print <<EOF, $cdb_output, "\n"; +Output from cdb follows. Faulting thread is printed twice,with and without function parameters +Search for STACK_TEXT to see the stack trace of +the faulting thread. Callstacks of other threads are printed after it. +EOF + return 1; +} + + sub show { my ($class, $core_name)= @_; + # On Windows, rely on cdb to be there... + if (IS_WINDOWS) + { + _cdb($core_name); + return; + } + # We try dbx first; gdb itself may coredump if run on a Sun Studio # compiled binary on Solaris. diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index 3dd5c552b10..69ffdfbb4ce 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -113,8 +113,8 @@ sub check_socket_path_length { # Create a tempfile name with same length as "path" my $tmpdir = tempdir( CLEANUP => 0); - my $len = length($path) - length($tmpdir); - my $testfile = $tmpdir . "x" x ($len > 0 ? $len : 1); + my $len = length($path) - length($tmpdir) - 1; + my $testfile = $tmpdir . "/" . "x" x ($len > 0 ? $len : 1); my $sock; eval { $sock= new IO::Socket::UNIX @@ -126,17 +126,15 @@ sub check_socket_path_length { die "Could not create UNIX domain socket: $!" unless defined $sock; - die "UNIX domain socket patch was truncated" + die "UNIX domain socket path was truncated" unless ($testfile eq $sock->hostpath()); $truncated= 0; # Yes, it worked! }; - #print "check_socket_path_length, failed: ", $@, '\n' if ($@); $sock= undef; # Close socket - unlink($testfile); # Remove the physical file - rmdir($tmpdir); # Remove the tempdir + rmtree($tmpdir); # Remove the tempdir and any socket file created return $truncated; } diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 0e3aa968052..5ef3286ad8e 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -117,6 +117,7 @@ sub new { my $output = delete($opts{'output'}); my $error = delete($opts{'error'}); my $verbose = delete($opts{'verbose'}); + my $nocore = delete($opts{'nocore'}); my $host = delete($opts{'host'}); my $shutdown = delete($opts{'shutdown'}); my $user_data= delete($opts{'user_data'}); @@ -137,6 +138,7 @@ sub new { push(@safe_args, $safe_script) if defined $safe_script; push(@safe_args, "--verbose") if $verbose > 0; + push(@safe_args, "--nocore") if $nocore; # Point the safe_process at the right parent if running on cygwin push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc index 7932f3fd2d6..6ad45a3226e 100644 --- a/mysql-test/lib/My/SafeProcess/safe_process.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process.cc @@ -45,6 +45,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include <sys/resource.h> #include <unistd.h> #include <stdarg.h> #include <stdio.h> @@ -149,7 +150,8 @@ int main(int argc, char* const argv[] ) char* const* child_argv= 0; pid_t own_pid= getpid(); pid_t parent_pid= getppid(); - + bool nocore = false; + /* Install signal handlers */ signal(SIGTERM, handle_signal); signal(SIGINT, handle_signal); @@ -181,6 +183,9 @@ int main(int argc, char* const argv[] ) start++; /* Step past = */ if ((parent_pid= atoi(start)) == 0) die("Invalid value '%s' passed to --parent-id", start); + } else if ( strcmp(arg, "--nocore") == 0 ) + { + nocore = true; // Don't allow the process to dump core } else die("Unknown option: %s", arg); @@ -218,6 +223,15 @@ int main(int argc, char* const argv[] ) // it and any childs(that hasn't changed group themself) setpgid(0, 0); + if (nocore) + { + struct rlimit corelim = { 0, 0 }; + if (setrlimit (RLIMIT_CORE, &corelim) < 0) + { + message("setrlimit failed, errno=%d", errno); + } + } + // Signal that child is ready buf= 37; write(pfd[1], &buf, 1); diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc index 640254875c9..4fb89f098ed 100755 --- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc +++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc @@ -77,14 +77,29 @@ static void message(const char* fmt, ...) static void die(const char* fmt, ...) { + DWORD last_err= GetLastError(); va_list args; fprintf(stderr, "%s: FATAL ERROR, ", safe_process_name); va_start(args, fmt); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); - if (int last_err= GetLastError()) - fprintf(stderr, "error: %d, %s\n", last_err, strerror(last_err)); + if (last_err) + { + char *message_text; + if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER + |FORMAT_MESSAGE_IGNORE_INSERTS, NULL, last_err , 0, (LPSTR)&message_text, + 0, NULL)) + { + fprintf(stderr,"error: %d, %s\n",last_err, message_text); + LocalFree(message_text); + } + else + { + /* FormatMessage failed, print error code only */ + fprintf(stderr,"error:%d\n", last_err); + } + } fflush(stderr); exit(1); } diff --git a/mysql-test/lib/mtr_gcov.pl b/mysql-test/lib/mtr_gcov.pl index 5049fdd6063..f531889b08d 100644 --- a/mysql-test/lib/mtr_gcov.pl +++ b/mysql-test/lib/mtr_gcov.pl @@ -22,40 +22,46 @@ use strict; sub gcov_prepare ($) { my ($dir)= @_; + print "Purging gcov information from '$dir'...\n"; - `find $dir -name \*.gcov \ - -or -name \*.da | xargs rm`; + system("find $dir -name \*.gcov -o -name \*.da" + . " -o -name \*.gcda | grep -v 'README.gcov\$' | xargs rm"); } -my @mysqld_src_dirs= - ( - "strings", - "mysys", - "include", - "extra", - "regex", - "isam", - "merge", - "myisam", - "myisammrg", - "heap", - "sql", - ); - +# +# Collect gcov statistics. +# Arguments: +# $dir basedir, normally source directory +# $gcov gcov utility program [path] name +# $gcov_msg message file name +# $gcov_err error file name +# sub gcov_collect ($$$) { my ($dir, $gcov, $gcov_msg, $gcov_err)= @_; + # Get current directory to return to later. my $start_dir= cwd(); - print "Collecting source coverage info...\n"; - -f $gcov_msg and unlink($gcov_msg); - -f $gcov_err and unlink($gcov_err); - foreach my $d ( @mysqld_src_dirs ) - { - chdir("$dir/$d"); - foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) - { - `$gcov $f 2>>$gcov_err >>$gcov_msg`; + print "Collecting source coverage info using '$gcov'...\n"; + -f "$start_dir/$gcov_msg" and unlink("$start_dir/$gcov_msg"); + -f "$start_dir/$gcov_err" and unlink("$start_dir/$gcov_err"); + + my @dirs= `find "$dir" -type d -print | sort`; + #print "List of directories:\n@dirs\n"; + + foreach my $d ( @dirs ) { + my $dir_reported= 0; + chomp($d); + chdir($d) or next; + + foreach my $f ( (glob("*.h"), glob("*.cc"), glob("*.c")) ) { + $f =~ /(.*)\.[ch]c?/; + -f "$1.gcno" or next; + if (!$dir_reported) { + print "Collecting in '$d'...\n"; + $dir_reported= 1; + } + system("$gcov $f 2>>$start_dir/$gcov_err >>$start_dir/$gcov_msg"); } chdir($start_dir); } diff --git a/mysql-test/lib/mtr_report.pm b/mysql-test/lib/mtr_report.pm index ce3fba87385..9c6ab35ee5e 100644 --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -69,6 +69,8 @@ sub _mtr_report_test_name ($) { print _name(), _timestamp(); printf "%-40s ", $tname; + + return $tname; } @@ -105,20 +107,48 @@ sub mtr_report_test_passed ($) { sub mtr_report_test ($) { my ($tinfo)= @_; - _mtr_report_test_name($tinfo); + my $test_name = _mtr_report_test_name($tinfo); my $comment= $tinfo->{'comment'}; my $logfile= $tinfo->{'logfile'}; my $warnings= $tinfo->{'warnings'}; my $result= $tinfo->{'result'}; + my $retry= $tinfo->{'retries'} ? "retry-" : ""; if ($result eq 'MTR_RES_FAILED'){ my $timest = format_time(); + 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. + for my $exp ( @$::experimental_test_cases ) { + if ( $exp ne $test_name ) { + # 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 + if ( $exp ne "" && substr($exp, -1, 1) eq "*" ) { + $exp = substr($exp, 0, length($exp) - 1); + if ( substr($test_name, 0, length($exp)) ne $exp ) { + # no match, try next entry + next; + } + # if yes, fall through to set the exp-fail status + } else { + # no match, try next entry + next; + } + } + $fail = "exp-fail"; + last; + } + } if ( $warnings ) { - mtr_report("[ fail ] Found warnings/errors in server log file!"); + mtr_report("[ $retry$fail ] Found warnings/errors in server log file!"); mtr_report(" Test ended at $timest"); mtr_report($warnings); return; @@ -126,14 +156,14 @@ sub mtr_report_test ($) { my $timeout= $tinfo->{'timeout'}; if ( $timeout ) { - mtr_report("[ fail ] timeout after $timeout seconds"); + mtr_report("[ $retry$fail ] timeout after $timeout seconds"); mtr_report(" Test ended at $timest"); mtr_report("\n$tinfo->{'comment'}"); return; } else { - mtr_report("[ fail ]\n Test ended at $timest"); + mtr_report("[ $retry$fail ]\n Test ended at $timest"); } if ( $logfile ) @@ -176,7 +206,7 @@ sub mtr_report_test ($) { { my $timer_str= $tinfo->{timer} || ""; $tot_real_time += ($timer_str/1000); - mtr_report("[ pass ] ", sprintf("%5s", $timer_str)); + mtr_report("[ ${retry}pass ] ", sprintf("%5s", $timer_str)); # Show any problems check-testcase found if ( defined $tinfo->{'check'} ) diff --git a/mysql-test/lib/mtr_unique.pm b/mysql-test/lib/mtr_unique.pm index 2ac172883a2..294a5d7b4d6 100644 --- a/mysql-test/lib/mtr_unique.pm +++ b/mysql-test/lib/mtr_unique.pm @@ -188,6 +188,8 @@ sub mtr_release_unique_id($) { flock SEM, LOCK_UN or warn "can't unlock $file.sem"; close SEM; + + delete $mtr_unique_ids{$$}; } |