]> git.pld-linux.org Git - packages/mysql.git/blob - subunit.patch
- rel. 2
[packages/mysql.git] / subunit.patch
1 === added file 'mysql-test/lib/Subunit.pm'
2 --- /dev/null
3 +++ b/mysql-test/lib/Subunit.pm
4 @@ -0,0 +1,94 @@
5 +# Perl module for parsing and generating the Subunit protocol
6 +# Copyright (C) 2008-2009 Jelmer Vernooij <jelmer@samba.org>
7 +#
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.
12 +#
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.
18 +
19 +package Subunit;
20 +use POSIX;
21 +
22 +use vars qw ( $VERSION );
23 +
24 +$VERSION = '0.0.2';
25 +
26 +use strict;
27 +my $SUBUNIT_OUT= 'test_results.subunit';
28 +# reset the file
29 +open(SUBUNITOUT, ">$SUBUNIT_OUT");
30 +close(SUBUNITOUT);
31 +
32 +sub subunit_start_test($)
33 +{
34 +       my ($testname) = @_;
35 +        open(SUBUNITOUT, ">>$SUBUNIT_OUT");
36 +       print SUBUNITOUT "test: $testname\n";
37 +        close(SUBUNITOUT);
38 +        return;
39 +}
40 +
41 +sub subunit_end_test($$;$)
42 +{
43 +       my $name = shift;
44 +       my $result = shift;
45 +       my $reason = shift;
46 +        open(SUBUNITOUT, ">>$SUBUNIT_OUT");
47 +       if ($reason) {
48 +               print SUBUNITOUT "$result: $name [\n";
49 +               print SUBUNITOUT "$reason\n";
50 +               print SUBUNITOUT "]\n";
51 +       } else {
52 +               print SUBUNITOUT "$result: $name\n";
53 +       }
54 +        close(SUBUNITOUT);
55 +        return;
56 +}
57 +
58 +sub subunit_skip_test($;$)
59 +{
60 +       my $name = shift;
61 +       my $reason = shift;
62 +       subunit_end_test($name, "skip", $reason);
63 +}
64 +
65 +sub subunit_fail_test($;$)
66 +{
67 +       my $name = shift;
68 +       my $reason = shift;
69 +       subunit_end_test($name, "failure", $reason);
70 +}
71 +
72 +sub subunit_pass_test($;$)
73 +{
74 +       my $name = shift;
75 +       my $reason = shift;
76 +       subunit_end_test($name, "success", $reason);
77 +}
78 +
79 +sub subunit_xfail_test($;$)
80 +{
81 +       my $name = shift;
82 +       my $reason = shift;
83 +       subunit_end_test($name, "xfail", $reason);
84 +}
85 +
86 +sub report_time($)
87 +{
88 +       my ($time) = @_;
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;
92 +        close(SUBUNITOUT);
93 +        return;
94 +}
95 +
96 +
97 +
98 +1;
99 --- a/mysql-test/lib/mtr_report.pm
100 +++ b/mysql-test/lib/mtr_report.pm
101 @@ -27,9 +27,11 @@
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
106                 mtr_report_test);
107  
108  use mtr_match;
109 +use Subunit;
110  use My::Platform;
111  use POSIX qw[ _exit ];
112  use IO::Handle qw[ flush ];
113 @@ -225,6 +227,68 @@
114    }
115  }
116  
117 +sub mtr_report_test_subunit ($) {
118 +  my ($tinfo)= @_;
119 +  my $subunit_testname= $tinfo->{name};
120 +  $subunit_testname.= " '$tinfo->{combination}'"
121 +    if defined $tinfo->{combination};
122 +
123 +
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-" : "";
129 +
130 +  my $test_name_sub = $tinfo->{name};
131 +
132 +  if ($result eq 'MTR_RES_FAILED'){
133 +
134 +    my $timest = format_time();
135 +    my $fail = "fail";
136 +
137 +    if ( $warnings )
138 +    {
139 +      Subunit::subunit_start_test($subunit_testname);
140 +      Subunit::subunit_fail_test($subunit_testname, "Found warnings/errors in server log file!");
141 +      return;
142 +    }
143 +    my $timeout= $tinfo->{'timeout'};
144 +    if ( $timeout )
145 +    {
146 +      Subunit::subunit_start_test($subunit_testname);
147 +      Subunit::subunit_fail_test($subunit_testname, "Timeout after $timeout seconds\n\n$tinfo->{'comment'}");
148 +      return;
149 +    }
150 +    Subunit::subunit_start_test($subunit_testname);
151 +    Subunit::subunit_fail_test($subunit_testname, "Comment: $comment\n\nLogfile:\n$logfile");
152 +  }
153 +  elsif ($result eq 'MTR_RES_SKIPPED')
154 +  {
155 +    if ( $tinfo->{'disable'} )
156 +    {
157 +      $comment="DISABLED: $comment";
158 +    }
159 +    # report into to subunit for Jenkins reporting
160 +    Subunit::subunit_start_test($subunit_testname);
161 +    Subunit::subunit_skip_test($subunit_testname, $comment);
162 +  }
163 +  elsif ($result eq 'MTR_RES_PASSED')
164 +  {
165 +    # Show any problems check-testcase found
166 +    if ( defined $tinfo->{'check'} )
167 +    {
168 +      mtr_report($tinfo->{'check'});
169 +    }
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);
176 +  }
177 +}
178 +
179  
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
184 @@ -99,6 +99,7 @@
185  use mtr_results;
186  use IO::Socket::INET;
187  use IO::Select;
188 +use Subunit;
189  
190  require "lib/mtr_process.pl";
191  require "lib/mtr_io.pl";
192 @@ -292,6 +293,7 @@
193  my $opt_valgrind_path;
194  my $valgrind_reports= 0;
195  my $opt_callgrind;
196 +my $opt_helgrind;
197  my %mysqld_logs;
198  my $opt_debug_sync_timeout= 300; # Default timeout for WAIT_FOR actions.
199  
200 @@ -631,6 +633,7 @@
201  
202           # Report test status
203           mtr_report_test($result);
204 +         mtr_report_test_subunit($result);
205  
206           if ( $result->is_failed() ) {
207  
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,
214  
215              # Directories
216 @@ -1705,11 +1709,18 @@
217        unless @valgrind_args;
218    }
219  
220 +  if ( $opt_helgrind )
221 +  {
222 +    mtr_report("Turning on valgrind with helgrind for mysqld(s)");
223 +    $opt_valgrind= 1;
224 +    $opt_valgrind_mysqld= 1;
225 +  }
226 +
227    if ( $opt_valgrind )
228    {
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;
233  
234      # Don't add --quiet; you will loose the summary reports.
235  
236 @@ -5831,6 +5842,10 @@
237      mtr_add_arg($args, "--tool=callgrind");
238      mtr_add_arg($args, "--base=$opt_vardir/log");
239    }
240 +  elsif ( $opt_helgrind )
241 +  {
242 +    mtr_add_arg($args, "--tool=helgrind");
243 +  }
244    else
245    {
246      mtr_add_arg($args, "--tool=memcheck"); # From >= 2.1.2 needs this option
This page took 0.080609 seconds and 3 git commands to generate.