selftest/buildfarm: Don't assume that a reason being specified is an indication of...
[Samba/gebeck_regimport.git] / selftest / output / buildfarm.pm
blob8612cfbc76b4cb8fe2ebc69be6541437af71004e
1 #!/usr/bin/perl
2 # Buildfarm output for selftest
3 # Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package output::buildfarm;
20 use Exporter;
21 @ISA = qw(Exporter);
23 use FindBin qw($RealBin);
24 use lib "$RealBin/..";
26 use BuildFarm;
28 use strict;
30 sub new($$$) {
31 my ($class, $statistics) = @_;
32 my $self = {
33 test_output => {},
34 statistics => $statistics,
35 last_time => 0,
36 start_time => undef,
38 bless($self, $class);
41 sub testsuite_count($$)
45 sub report_time($$)
47 my ($self, $time) = @_;
49 unless ($self->{start_time}) {
50 $self->{start_time} = $time;
53 $self->{last_time} = $time;
56 sub start_testsuite($$)
58 my ($self, $name) = @_;
60 $self->{NAME} = $name;
61 $self->{START_TIME} = $self->{last_time};
63 my $duration = $self->{START_TIME} - $self->{start_time};
64 BuildFarm::start_testsuite($name, $duration);
65 $self->{test_output}->{$name} = "";
68 sub output_msg($$)
70 my ($self, $output) = @_;
72 if (defined($self->{NAME})) {
73 $self->{test_output}->{$self->{NAME}} .= $output;
74 } else {
75 print $output;
79 sub control_msg($$)
81 my ($self, $output) = @_;
83 if (defined($self->{NAME})) {
84 $self->{test_output}->{$self->{NAME}} .= $output;
85 } else {
86 print $output;
90 sub end_testsuite($$$$$)
92 my ($self, $name, $result, $reason) = @_;
94 my $unexpected;
95 if ($result eq "failure" or $result eq "fail" or $result eq "error") {
96 $unexpected = 1;
97 } else {
98 $unexpected = 0;
101 BuildFarm::end_testsuite($name, ($self->{last_time} - $self->{START_TIME}),
102 (not $unexpected), $self->{test_output}->{$name},
103 $reason);
104 if ($result ne "success") {
105 $self->{statistics}->{SUITES_FAIL}++;
107 $self->{NAME} = undef;
110 sub start_test($$$)
112 my ($self, $testname) = @_;
115 sub end_test($$$$$)
117 my ($self, $testname, $result, $unexpected, $reason) = @_;
119 if ($unexpected) {
120 $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n";
124 sub summary($)
126 my ($self) = @_;
128 BuildFarm::summary($self->{last_time} - $self->{start_time});
130 print "TEST STATUS: $self->{statistics}->{SUITES_FAIL}\n";
133 sub skip_testsuite($$$)
135 my ($self, $name, $reason) = @_;
137 BuildFarm::skip_testsuite($name);