1 === added file 'mysql-test/lib/Subunit.pm'
3 +++ b/mysql-test/lib/Subunit.pm
5 +# Perl module for parsing and generating the Subunit protocol
6 +# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
8 +# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
9 +# license at the users choice. A copy of both licenses are available in the
10 +# project source as Apache-2.0 and BSD. You may not use this file except in
11 +# compliance with one of these two licences.
13 +# Unless required by applicable law or agreed to in writing, software
14 +# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
15 +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 +# license you chose for the specific language governing permissions and
17 +# limitations under that license.
22 +use vars qw ( $VERSION );
27 +my $SUBUNIT_OUT= 'test_results.subunit';
29 +open(SUBUNITOUT, ">$SUBUNIT_OUT");
32 +sub subunit_start_test($)
34 + my ($testname) = @_;
35 + open(SUBUNITOUT, ">>$SUBUNIT_OUT");
36 + print SUBUNITOUT "test: $testname\n";
41 +sub subunit_end_test($$;$)
46 + open(SUBUNITOUT, ">>$SUBUNIT_OUT");
48 + print SUBUNITOUT "$result: $name [\n";
49 + print SUBUNITOUT "$reason\n";
50 + print SUBUNITOUT "]\n";
52 + print SUBUNITOUT "$result: $name\n";
58 +sub subunit_skip_test($;$)
62 + subunit_end_test($name, "skip", $reason);
65 +sub subunit_fail_test($;$)
69 + subunit_end_test($name, "failure", $reason);
72 +sub subunit_pass_test($;$)
76 + subunit_end_test($name, "success", $reason);
79 +sub subunit_xfail_test($;$)
83 + subunit_end_test($name, "xfail", $reason);
89 + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
90 + open(SUBUNITOUT, ">>$SUBUNIT_OUT");
91 + printf SUBUNITOUT "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, ($mon+1), $mday, $hour, $min, $sec;
99 --- a/mysql-test/lib/mtr_report.pm
100 +++ b/mysql-test/lib/mtr_report.pm
102 mtr_warning mtr_error mtr_debug mtr_verbose
103 mtr_verbose_restart mtr_report_test_passed
104 mtr_report_test_skipped mtr_print
105 + mtr_report_test_subunit
111 use POSIX qw[ _exit ];
112 use IO::Handle qw[ flush ];
117 +sub mtr_report_test_subunit ($) {
119 + my $subunit_testname= $tinfo->{name};
120 + $subunit_testname.= " '$tinfo->{combination}'"
121 + if defined $tinfo->{combination};
124 + my $comment= $tinfo->{'comment'};
125 + my $logfile= $tinfo->{'logfile'};
126 + my $warnings= $tinfo->{'warnings'};
127 + my $result= $tinfo->{'result'};
128 + my $retry= $tinfo->{'retries'} ? "retry-" : "";
130 + my $test_name_sub = $tinfo->{name};
132 + if ($result eq 'MTR_RES_FAILED'){
134 + my $timest = format_time();
139 + Subunit::subunit_start_test($subunit_testname);
140 + Subunit::subunit_fail_test($subunit_testname, "Found warnings/errors in server log file!");
143 + my $timeout= $tinfo->{'timeout'};
146 + Subunit::subunit_start_test($subunit_testname);
147 + Subunit::subunit_fail_test($subunit_testname, "Timeout after $timeout seconds\n\n$tinfo->{'comment'}");
150 + Subunit::subunit_start_test($subunit_testname);
151 + Subunit::subunit_fail_test($subunit_testname, "Comment: $comment\n\nLogfile:\n$logfile");
153 + elsif ($result eq 'MTR_RES_SKIPPED')
155 + if ( $tinfo->{'disable'} )
157 + $comment="DISABLED: $comment";
159 + # report into to subunit for Jenkins reporting
160 + Subunit::subunit_start_test($subunit_testname);
161 + Subunit::subunit_skip_test($subunit_testname, $comment);
163 + elsif ($result eq 'MTR_RES_PASSED')
165 + # Show any problems check-testcase found
166 + if ( defined $tinfo->{'check'} )
168 + mtr_report($tinfo->{'check'});
170 + # report info to subunit for Jenkins reporting
171 + # TODO: catch 'check-testcase' output??
172 + Subunit::report_time(time() - $tinfo->{timer}/1000);
173 + Subunit::subunit_start_test($subunit_testname);
174 + Subunit::report_time(time());
175 + Subunit::subunit_pass_test($subunit_testname);
180 sub mtr_report_stats ($$;$) {
181 my ($prefix, $tests, $dont_error)= @_;
182 --- a/mysql-test/mysql-test-run.pl
183 +++ b/mysql-test/mysql-test-run.pl
186 use IO::Socket::INET;
190 require "lib/mtr_process.pl";
191 require "lib/mtr_io.pl";
193 my $opt_valgrind_path;
194 my $valgrind_reports= 0;
198 my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
203 mtr_report_test($result);
204 + mtr_report_test_subunit($result);
206 if ( $result->is_failed() ) {
208 @@ -1144,6 +1147,7 @@
209 'valgrind-option=s' => \@valgrind_args,
210 'valgrind-path=s' => \$opt_valgrind_path,
211 'callgrind' => \$opt_callgrind,
212 + 'helgrind' => \$opt_helgrind,
213 'debug-sync-timeout=i' => \$opt_debug_sync_timeout,
216 @@ -1705,11 +1709,18 @@
217 unless @valgrind_args;
220 + if ( $opt_helgrind )
222 + mtr_report("Turning on valgrind with helgrind for mysqld(s)");
224 + $opt_valgrind_mysqld= 1;
229 # Set valgrind_options to default unless already defined
230 push(@valgrind_args, @default_valgrind_args)
231 - unless @valgrind_args;
232 + unless @valgrind_args || $opt_helgrind;
234 # Don't add --quiet; you will loose the summary reports.
236 @@ -5831,6 +5842,10 @@
237 mtr_add_arg($args, "--tool=callgrind");
238 mtr_add_arg($args, "--base=$opt_vardir/log");
240 + elsif ( $opt_helgrind )
242 + mtr_add_arg($args, "--tool=helgrind");
246 mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option