r25741: Simplify calls to Subunit functions.
[samba.git] / source / selftest / output / buildfarm.pm
1 #!/usr/bin/perl
2
3 package output::buildfarm;
4
5 use Exporter;
6 @ISA = qw(Exporter);
7
8 use strict;
9
10 sub new($$$$) {
11         my ($class, $statistics) = @_;
12         my $self = {
13                 statistics => $statistics,
14                 test_output => {}
15         };
16         bless($self, $class);
17 }
18
19 sub start_testsuite($$)
20 {
21         my ($self, $state) = @_;
22         my $out = "";
23
24         my $duration = $state->{START_TIME} - $self->{statistics}->{START_TIME};
25         $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
26         $out .= "Running test $state->{NAME} (level 0 stdout)\n";
27         $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
28         $out .= scalar(localtime())."\n";
29         $out .= "SELFTEST RUNTIME: " . $duration . "s\n";
30         $out .= "NAME: $state->{NAME}\n";
31         $out .= "CMD: $state->{CMD}\n";
32
33         $self->{test_output}->{$state->{NAME}} = "";
34
35         print $out;
36 }
37
38 sub output_msg($$$)
39 {
40         my ($self, $state, $output) = @_;
41
42         $self->{test_output}->{$state->{NAME}} .= $output;
43 }
44
45 sub control_msg($$$)
46 {
47         my ($self, $state, $output) = @_;
48
49         $self->{test_output}->{$state->{NAME}} .= $output;
50 }
51
52 sub end_testsuite($$$$$)
53 {
54         my ($self, $state, $expected_ret, $ret, $envlog) = @_;
55         my $out = "";
56
57         $out .= "TEST RUNTIME: " . (time() - $state->{START_TIME}) . "s\n";
58
59         if ($ret == $expected_ret) {
60                 $out .= "ALL OK\n";
61         } else {
62                 $out .= "ERROR: $ret\n";
63                 $out .= $self->{test_output}->{$state->{NAME}};
64         }
65
66         $out .= "PCAP FILE: $state->{PCAP_FILE}\n" if defined($state->{PCAP_FILE});
67
68         $out .= $envlog;
69
70         $out .= "==========================================\n";
71         if ($ret == $expected_ret) {
72                 $out .= "TEST PASSED: $state->{NAME}\n";
73         } else {
74                 $out .= "TEST FAILED: $state->{NAME} (status $ret)\n";
75         }
76         $out .= "==========================================\n";
77
78         print $out;
79 }
80
81 sub start_test($$$)
82 {
83         my ($self, $state, $testname) = @_;
84 }
85
86 sub end_test($$$$$$)
87 {
88         my ($self, $state, $testname, $result, $unexpected, $reason) = @_;
89
90         return unless ($unexpected);
91
92         $self->{test_output}->{$state->{NAME}} .= "UNEXPECTED($result): $testname\n";
93 }
94
95 sub summary($)
96 {
97         my ($self) = @_;
98 }
99
100 sub skip_testsuite($$$$)
101 {
102         my ($self, $name, $reason) = @_;
103
104         print "SKIPPED: $name\n";
105 }
106
107 1;