a9923e9fd16bd5e7e94ec6a17956280288f03186
[ira/wip.git] / selftest / output / buildfarm.pm
1 #!/usr/bin/perl
2 # Buildfarm output for selftest
3 # Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
4 #
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.
9
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.
14
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/>.
17
18 package output::buildfarm;
19
20 use Exporter;
21 @ISA = qw(Exporter);
22
23 use FindBin qw($RealBin);
24 use lib "$RealBin/..";
25
26 use Subunit qw(parse_results);
27 use BuildFarm;
28
29 use strict;
30
31 sub new($$$) {
32         my ($class, $statistics) = @_;
33         my $self = {
34                 test_output => {},
35                 statistics => $statistics,
36                 last_time => 0,
37                 start_time => undef,
38         };
39         bless($self, $class);
40 }
41
42 sub report_time($$)
43 {
44         my ($self, $time) = @_;
45
46         unless ($self->{start_time}) {
47                 $self->{start_time} = $time;
48         }
49
50         $self->{last_time} = $time;
51 }
52
53 sub start_testsuite($$)
54 {
55         my ($self, $name) = @_;
56
57         $self->{NAME} = $name;
58         $self->{START_TIME} = $self->{last_time};
59
60         my $duration = $self->{START_TIME} - $self->{start_time};
61         BuildFarm::start_testsuite($name, $duration);
62         $self->{test_output}->{$name} = "";
63 }
64
65 sub output_msg($$)
66 {
67         my ($self, $output) = @_;
68
69         $self->{test_output}->{$self->{NAME}} .= $output;
70 }
71
72 sub control_msg($$)
73 {
74         my ($self, $output) = @_;
75
76         $self->{test_output}->{$self->{NAME}} .= $output;
77 }
78
79 sub end_testsuite($$$$$$)
80 {
81         my ($self, $name, $result, $unexpected, $reason) = @_;
82
83         BuildFarm::end_testsuite($name, ($self->{last_time} - $self->{START_TIME}), 
84                                      (not $unexpected), $self->{test_output}->{$name}, 
85                                                          $reason);
86 }
87
88 sub start_test($$$)
89 {
90         my ($self, $testname) = @_;
91 }
92
93 sub end_test($$$$$)
94 {
95         my ($self, $testname, $result, $unexpected, $reason) = @_;
96
97         if ($unexpected) {
98                 $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n";
99         }
100 }
101
102 sub summary($)
103 {
104         my ($self) = @_;
105         
106         BuildFarm::summary($self->{last_time} - $self->{start_time});
107
108         print "TEST STATUS: $self->{statistics}->{SUITES_FAIL}\n";
109 }
110
111 sub skip_testsuite($$$)
112 {
113         my ($self, $name, $reason) = @_;
114
115         BuildFarm::skip_testsuite($name);
116 }
117
118 1;