r26547: Make testsuites less special during subunit handling.
[kai/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, $name, $state) = @_;
22         my $out = "";
23
24         my $duration = $state->{START_TIME} - $self->{statistics}->{START_TIME};
25         $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
26         $out .= "Running test $name (level 0 stdout)\n";
27         $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
28         $out .= scalar(localtime())."\n";
29         $out .= "SELFTEST RUNTIME: " . $duration . "s\n";
30         $out .= "NAME: $name\n";
31         $out .= "CMD: $state->{CMD}\n";
32
33         $self->{test_output}->{$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, $name, $state, $result, $unexpected, $reason) = @_;
55         my $out = "";
56
57         $out .= "TEST RUNTIME: " . (time() - $state->{START_TIME}) . "s\n";
58
59         if (not $unexpected) {
60                 $out .= "ALL OK\n";
61         } else {
62                 $out .= "ERROR: $reason\n";
63                 $out .= $self->{test_output}->{$name};
64         }
65
66         $out .= "PCAP FILE: $state->{PCAP_FILE}\n" if defined($state->{PCAP_FILE});
67
68         $out .= "==========================================\n";
69         if (not $unexpected) {
70                 $out .= "TEST PASSED: $name\n";
71         } else {
72                 $out .= "TEST FAILED: $name (status $reason)\n";
73         }
74         $out .= "==========================================\n";
75
76         print $out;
77 }
78
79 sub start_test($$$$)
80 {
81         my ($self, $state, $parents, $testname) = @_;
82
83         if ($#$parents == -1) {
84                 $self->start_testsuite($testname, $state);
85         }
86 }
87
88 sub end_test($$$$$$)
89 {
90         my ($self, $state, $parents, $testname, $result, $unexpected, $reason) = @_;
91
92         if ($unexpected) {
93                 $self->{test_output}->{$state->{NAME}} .= "UNEXPECTED($result): $testname\n";
94         }
95
96         if ($#$parents == -1) {
97                 $self->end_testsuite($testname, $state, $result, $unexpected, $reason); 
98         }
99 }
100
101 sub summary($)
102 {
103         my ($self) = @_;
104 }
105
106 sub skip_testsuite($$$$)
107 {
108         my ($self, $name, $reason) = @_;
109
110         print "SKIPPED: $name\n";
111 }
112
113 1;