mirror of
https://github.com/samba-team/samba.git
synced 2025-09-20 17:44:21 +03:00
selftest: Factor generic functionality for buildfarm output into a
separate perl module.
This commit is contained in:
65
selftest/BuildFarm.pm
Normal file
65
selftest/BuildFarm.pm
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
# Convenience functions for writing output expected by the buildfarm
|
||||||
|
# Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
|
||||||
|
# Published under the GNU GPL, v3 or later
|
||||||
|
|
||||||
|
package BuildFarm;
|
||||||
|
|
||||||
|
use Exporter;
|
||||||
|
@ISA = qw(Exporter);
|
||||||
|
@EXPORT_OK = qw(start_testsuite end_testsuite skip_testsuite summary);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
sub start_testsuite($$)
|
||||||
|
{
|
||||||
|
my ($name, $duration) = @_;
|
||||||
|
my $out = "";
|
||||||
|
|
||||||
|
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
|
||||||
|
$out .= "Running test $name (level 0 stdout)\n";
|
||||||
|
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
|
||||||
|
$out .= scalar(localtime())."\n";
|
||||||
|
$out .= "SELFTEST RUNTIME: " . $duration . "s\n";
|
||||||
|
$out .= "NAME: $name\n";
|
||||||
|
|
||||||
|
print $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub end_testsuite($$$$$)
|
||||||
|
{
|
||||||
|
my ($name, $duration, $ok, $output, $reason) = @_;
|
||||||
|
my $out = "";
|
||||||
|
|
||||||
|
$out .= "TEST RUNTIME: " . $duration . "s\n";
|
||||||
|
if ($ok) {
|
||||||
|
$out .= "ALL OK\n";
|
||||||
|
} else {
|
||||||
|
$out .= "ERROR: $reason\n";
|
||||||
|
}
|
||||||
|
$out .= "==========================================\n";
|
||||||
|
if ($ok) {
|
||||||
|
$out .= "TEST PASSED: $name\n";
|
||||||
|
} else {
|
||||||
|
$out .= "TEST FAILED: $name (status $reason)\n";
|
||||||
|
}
|
||||||
|
$out .= "==========================================\n";
|
||||||
|
|
||||||
|
print $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub skip_testsuite($)
|
||||||
|
{
|
||||||
|
my ($name) = @_;
|
||||||
|
|
||||||
|
print "SKIPPED: $name\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub summary($)
|
||||||
|
{
|
||||||
|
my ($duration) = @_;
|
||||||
|
|
||||||
|
print "DURATION: " . $duration . " seconds\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
@@ -24,6 +24,7 @@ use FindBin qw($RealBin);
|
|||||||
use lib "$RealBin/..";
|
use lib "$RealBin/..";
|
||||||
|
|
||||||
use Subunit qw(parse_results);
|
use Subunit qw(parse_results);
|
||||||
|
use BuildFarm;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
@@ -31,30 +32,33 @@ sub new($$$) {
|
|||||||
my ($class) = @_;
|
my ($class) = @_;
|
||||||
my $self = {
|
my $self = {
|
||||||
test_output => {},
|
test_output => {},
|
||||||
start_time => time()
|
last_time => 0,
|
||||||
|
start_time => undef,
|
||||||
};
|
};
|
||||||
bless($self, $class);
|
bless($self, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub report_time($$)
|
||||||
|
{
|
||||||
|
my ($self, $time) = @_;
|
||||||
|
|
||||||
|
unless ($self->{start_time}) {
|
||||||
|
$self->{start_time} = $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{last_time} = $time;
|
||||||
|
}
|
||||||
|
|
||||||
sub start_testsuite($$)
|
sub start_testsuite($$)
|
||||||
{
|
{
|
||||||
my ($self, $name) = @_;
|
my ($self, $name) = @_;
|
||||||
my $out = "";
|
|
||||||
|
|
||||||
$self->{NAME} = $name;
|
$self->{NAME} = $name;
|
||||||
$self->{START_TIME} = time();
|
$self->{START_TIME} = $self->{last_time};
|
||||||
|
|
||||||
my $duration = $self->{START_TIME} - $self->{start_time};
|
my $duration = $self->{START_TIME} - $self->{start_time};
|
||||||
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
|
BuildFarm::start_testsuite($name, $duration);
|
||||||
$out .= "Running test $name (level 0 stdout)\n";
|
|
||||||
$out .= "--==--==--==--==--==--==--==--==--==--==--\n";
|
|
||||||
$out .= scalar(localtime())."\n";
|
|
||||||
$out .= "SELFTEST RUNTIME: " . $duration . "s\n";
|
|
||||||
$out .= "NAME: $name\n";
|
|
||||||
|
|
||||||
$self->{test_output}->{$name} = "";
|
$self->{test_output}->{$name} = "";
|
||||||
|
|
||||||
print $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub output_msg($$)
|
sub output_msg($$)
|
||||||
@@ -74,26 +78,10 @@ sub control_msg($$)
|
|||||||
sub end_testsuite($$$$$$)
|
sub end_testsuite($$$$$$)
|
||||||
{
|
{
|
||||||
my ($self, $name, $result, $unexpected, $reason) = @_;
|
my ($self, $name, $result, $unexpected, $reason) = @_;
|
||||||
my $out = "";
|
|
||||||
|
|
||||||
$out .= "TEST RUNTIME: " . (time() - $self->{START_TIME}) . "s\n";
|
BuildFarm::end_testsuite($name, ($self->{last_time} - $self->{START_TIME}),
|
||||||
|
(not $unexpected), $self->{test_output}->{$name},
|
||||||
if (not $unexpected) {
|
$reason);
|
||||||
$out .= "ALL OK\n";
|
|
||||||
} else {
|
|
||||||
$out .= "ERROR: $reason\n";
|
|
||||||
$out .= $self->{test_output}->{$name};
|
|
||||||
}
|
|
||||||
|
|
||||||
$out .= "==========================================\n";
|
|
||||||
if (not $unexpected) {
|
|
||||||
$out .= "TEST PASSED: $name\n";
|
|
||||||
} else {
|
|
||||||
$out .= "TEST FAILED: $name (status $reason)\n";
|
|
||||||
}
|
|
||||||
$out .= "==========================================\n";
|
|
||||||
|
|
||||||
print $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub start_test($$$)
|
sub start_test($$$)
|
||||||
@@ -122,14 +110,14 @@ sub summary($)
|
|||||||
{
|
{
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
print "DURATION: " . (time() - $self->{start_time}) . " seconds\n";
|
BuildFarm::summary($self->{last_time} - $self->{start_time});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub skip_testsuite($$$$)
|
sub skip_testsuite($$$)
|
||||||
{
|
{
|
||||||
my ($self, $name, $reason) = @_;
|
my ($self, $name, $reason) = @_;
|
||||||
|
|
||||||
print "SKIPPED: $name\n";
|
BuildFarm::skip_testsuite($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Reference in New Issue
Block a user