Support reporting current time in selftest output.
[samba.git] / selftest / output / subunit.pm
1 #!/usr/bin/perl
2 # Subunit output for selftest
3 # Copyright (C) 2009 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::subunit;
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
28 use strict;
29
30 sub new($) {
31         my ($class) = @_;
32         my $self = { };
33         bless($self, $class);
34 }
35
36 sub report_time($$)
37 {
38         my ($self, $time) = @_;
39         my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
40         printf "time: %04d-%02d-%02d %02d:%02d:%02dZ\n", $year+1900, $mon, $mday, $hour, $min, $sec;
41 }
42
43 sub start_testsuite($$)
44 {
45         my ($self, $name) = @_;
46
47         $self->{NAME} = $name;
48         
49         print "test: $self->{NAME}\n";
50 }
51
52 sub output_msg($$)
53 {
54         my ($self, $output) = @_;
55
56         print $output;
57 }
58
59 sub control_msg($$)
60 {
61         my ($self, $output) = @_;
62 }
63
64 sub end_testsuite($$$$$$)
65 {
66         my ($self, $name, $result, $unexpected, $reason) = @_;
67
68         if ($result eq "failure" and not $unexpected) { $result = "xfail"; }
69
70         if ($reason) {
71                 print "$result: $name [ $reason ]\n";
72         } else {
73                 print "$result: $name\n";
74         }
75 }
76
77 sub start_test($$$)
78 {
79         my ($self, $parents, $testname) = @_;
80
81         print "test: $testname\n";
82 }
83
84 sub end_test($$$$$)
85 {
86         my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
87
88         if ($result eq "fail" and not $unexpected) { $result = "xfail"; }
89
90         if ($reason) {
91                 print "$result: $testname [ $reason ]\n";
92         } else {
93                 print "$result: $testname\n";
94         }
95 }
96
97 sub summary($)
98 {
99         my ($self) = @_;
100 }
101
102 sub skip_testsuite($$$$)
103 {
104         my ($self, $name, $reason) = @_;
105
106         print "skip: $name\n";
107 }
108
109 1;