selftest: Remove unnecessary uses.
[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 BuildFarm;
27
28 use strict;
29
30 sub new($$$) {
31         my ($class, $statistics) = @_;
32         my $self = {
33                 test_output => {},
34                 statistics => $statistics,
35                 last_time => 0,
36                 start_time => undef,
37         };
38         bless($self, $class);
39 }
40
41 sub report_time($$)
42 {
43         my ($self, $time) = @_;
44
45         unless ($self->{start_time}) {
46                 $self->{start_time} = $time;
47         }
48
49         $self->{last_time} = $time;
50 }
51
52 sub start_testsuite($$)
53 {
54         my ($self, $name) = @_;
55
56         $self->{NAME} = $name;
57         $self->{START_TIME} = $self->{last_time};
58
59         my $duration = $self->{START_TIME} - $self->{start_time};
60         BuildFarm::start_testsuite($name, $duration);
61         $self->{test_output}->{$name} = "";
62 }
63
64 sub output_msg($$)
65 {
66         my ($self, $output) = @_;
67
68         $self->{test_output}->{$self->{NAME}} .= $output;
69 }
70
71 sub control_msg($$)
72 {
73         my ($self, $output) = @_;
74
75         $self->{test_output}->{$self->{NAME}} .= $output;
76 }
77
78 sub end_testsuite($$$$$$)
79 {
80         my ($self, $name, $result, $unexpected, $reason) = @_;
81
82         BuildFarm::end_testsuite($name, ($self->{last_time} - $self->{START_TIME}), 
83                                      (not $unexpected), $self->{test_output}->{$name}, 
84                                                          $reason);
85 }
86
87 sub start_test($$$)
88 {
89         my ($self, $testname) = @_;
90 }
91
92 sub end_test($$$$$)
93 {
94         my ($self, $testname, $result, $unexpected, $reason) = @_;
95
96         if ($unexpected) {
97                 $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n";
98         }
99 }
100
101 sub summary($)
102 {
103         my ($self) = @_;
104         
105         BuildFarm::summary($self->{last_time} - $self->{start_time});
106
107         print "TEST STATUS: $self->{statistics}->{SUITES_FAIL}\n";
108 }
109
110 sub skip_testsuite($$$)
111 {
112         my ($self, $name, $reason) = @_;
113
114         BuildFarm::skip_testsuite($name);
115 }
116
117 1;