=== added file 'mysql-test/lib/Subunit.pm' --- /dev/null +++ b/mysql-test/lib/Subunit.pm @@ -0,0 +1,94 @@ +# Perl module for parsing and generating the Subunit protocol +# Copyright (C) 2008-2009 Jelmer Vernooij +# +# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause +# license at the users choice. A copy of both licenses are available in the +# project source as Apache-2.0 and BSD. You may not use this file except in +# compliance with one of these two licences. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# license you chose for the specific language governing permissions and +# limitations under that license. + +package Subunit; +use POSIX; + +use vars qw ( $VERSION ); + +$VERSION = '0.0.2'; + +use strict; +my $SUBUNIT_OUT= 'test_results.subunit'; +# reset the file +open(SUBUNITOUT, ">$SUBUNIT_OUT"); +close(SUBUNITOUT); + +sub subunit_start_test($) +{ + my ($testname) = @_; + open(SUBUNITOUT, ">>$SUBUNIT_OUT"); + print SUBUNITOUT "test: $testname\n"; + close(SUBUNITOUT); + return; +} + +sub subunit_end_test($$;$) +{ + my $name = shift; + my $result = shift; + my $reason = shift; + open(SUBUNITOUT, ">>$SUBUNIT_OUT"); + if ($reason) { + print SUBUNITOUT "$result: $name [\n"; + print SUBUNITOUT "$reason\n"; + print SUBUNITOUT "]\n"; + } else { + print SUBUNITOUT "$result: $name\n"; + } + close(SUBUNITOUT); + return; +} + +sub subunit_skip_test($;$) +{ + my $name = shift; + my $reason = shift; + subunit_end_test($name, "skip", $reason); +} + +sub subunit_fail_test($;$) +{ + my $name = shift; + my $reason = shift; + subunit_end_test($name, "failure", $reason); +} + +sub subunit_pass_test($;$) +{ + my $name = shift; + my $reason = shift; + subunit_end_test($name, "success", $reason); +} + +sub subunit_xfail_test($;$) +{ + my $name = shift; + my $reason = shift; + subunit_end_test($name, "xfail", $reason); +} + +sub report_time($) +{ + my ($time) = @_; + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time); + open(SUBUNITOUT, ">>$SUBUNIT_OUT"); + printf SUBUNITOUT "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, ($mon+1), $mday, $hour, $min, $sec; + close(SUBUNITOUT); + return; +} + + + +1; --- a/mysql-test/lib/mtr_report.pm +++ b/mysql-test/lib/mtr_report.pm @@ -27,9 +27,11 @@ mtr_warning mtr_error mtr_debug mtr_verbose mtr_verbose_restart mtr_report_test_passed mtr_report_test_skipped mtr_print + mtr_report_test_subunit mtr_report_test); use mtr_match; +use Subunit; use My::Platform; use POSIX qw[ _exit ]; use IO::Handle qw[ flush ]; @@ -225,6 +227,68 @@ } } +sub mtr_report_test_subunit ($) { + my ($tinfo)= @_; + my $subunit_testname= $tinfo->{name}; + $subunit_testname.= " '$tinfo->{combination}'" + if defined $tinfo->{combination}; + + + my $comment= $tinfo->{'comment'}; + my $logfile= $tinfo->{'logfile'}; + my $warnings= $tinfo->{'warnings'}; + my $result= $tinfo->{'result'}; + my $retry= $tinfo->{'retries'} ? "retry-" : ""; + + my $test_name_sub = $tinfo->{name}; + + if ($result eq 'MTR_RES_FAILED'){ + + my $timest = format_time(); + my $fail = "fail"; + + if ( $warnings ) + { + Subunit::subunit_start_test($subunit_testname); + Subunit::subunit_fail_test($subunit_testname, "Found warnings/errors in server log file!"); + return; + } + my $timeout= $tinfo->{'timeout'}; + if ( $timeout ) + { + Subunit::subunit_start_test($subunit_testname); + Subunit::subunit_fail_test($subunit_testname, "Timeout after $timeout seconds\n\n$tinfo->{'comment'}"); + return; + } + Subunit::subunit_start_test($subunit_testname); + Subunit::subunit_fail_test($subunit_testname, "Comment: $comment\n\nLogfile:\n$logfile"); + } + elsif ($result eq 'MTR_RES_SKIPPED') + { + if ( $tinfo->{'disable'} ) + { + $comment="DISABLED: $comment"; + } + # report into to subunit for Jenkins reporting + Subunit::subunit_start_test($subunit_testname); + Subunit::subunit_skip_test($subunit_testname, $comment); + } + elsif ($result eq 'MTR_RES_PASSED') + { + # Show any problems check-testcase found + if ( defined $tinfo->{'check'} ) + { + mtr_report($tinfo->{'check'}); + } + # report info to subunit for Jenkins reporting + # TODO: catch 'check-testcase' output?? + Subunit::report_time(time() - $tinfo->{timer}/1000); + Subunit::subunit_start_test($subunit_testname); + Subunit::report_time(time()); + Subunit::subunit_pass_test($subunit_testname); + } +} + sub mtr_report_stats ($$;$) { my ($prefix, $tests, $dont_error)= @_; --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -99,6 +99,7 @@ use mtr_results; use IO::Socket::INET; use IO::Select; +use Subunit; require "lib/mtr_process.pl"; require "lib/mtr_io.pl"; @@ -292,6 +293,7 @@ my $opt_valgrind_path; my $valgrind_reports= 0; my $opt_callgrind; +my $opt_helgrind; my %mysqld_logs; my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions. @@ -631,6 +633,7 @@ # Report test status mtr_report_test($result); + mtr_report_test_subunit($result); if ( $result->is_failed() ) { @@ -1144,6 +1147,7 @@ 'valgrind-option=s' => \@valgrind_args, 'valgrind-path=s' => \$opt_valgrind_path, 'callgrind' => \$opt_callgrind, + 'helgrind' => \$opt_helgrind, 'debug-sync-timeout=i' => \$opt_debug_sync_timeout, # Directories @@ -1705,11 +1709,18 @@ unless @valgrind_args; } + if ( $opt_helgrind ) + { + mtr_report("Turning on valgrind with helgrind for mysqld(s)"); + $opt_valgrind= 1; + $opt_valgrind_mysqld= 1; + } + if ( $opt_valgrind ) { # Set valgrind_options to default unless already defined push(@valgrind_args, @default_valgrind_args) - unless @valgrind_args; + unless @valgrind_args || $opt_helgrind; # Don't add --quiet; you will loose the summary reports. @@ -5831,6 +5842,10 @@ mtr_add_arg($args, "--tool=callgrind"); mtr_add_arg($args, "--base=$opt_vardir/log"); } + elsif ( $opt_helgrind ) + { + mtr_add_arg($args, "--tool=helgrind"); + } else { mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option