summaryrefslogtreecommitdiff
path: root/source4/selftest/output
diff options
context:
space:
mode:
Diffstat (limited to 'source4/selftest/output')
-rw-r--r--source4/selftest/output/buildfarm.pm95
-rw-r--r--source4/selftest/output/plain.pm101
2 files changed, 196 insertions, 0 deletions
diff --git a/source4/selftest/output/buildfarm.pm b/source4/selftest/output/buildfarm.pm
new file mode 100644
index 0000000000..11d65d7306
--- /dev/null
+++ b/source4/selftest/output/buildfarm.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+package output::buildfarm;
+
+use Exporter;
+@ISA = qw(Exporter);
+
+use strict;
+
+sub new($$) {
+ my ($class) = @_;
+ my $self = {
+ start => time(),
+ test_output => {}
+ };
+ bless($self, $class);
+}
+
+sub start_testsuite($$)
+{
+ my ($self, $state) = @_;
+ my $out = "";
+
+ $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
+ $out .= "Running test $state->{NAME} (level 0 stdout)\n";
+ $out .= "--==--==--==--==--==--==--==--==--==--==--\n";
+ $out .= scalar(localtime())."\n";
+ $out .= "SELFTEST RUNTIME: " . ($state->{START_TIME} - $self->{START_TIME}) . "s\n";
+ $out .= "NAME: $state->{NAME}\n";
+ $out .= "CMD: $state->{CMD}\n";
+
+ $self->{test_output}->{$state->{NAME}} = "";
+
+ print $out;
+}
+
+sub output_msg($$$)
+{
+ my ($self, $state, $output) = @_;
+
+ $self->{test_output}->{$state->{NAME}} .= $output;
+}
+
+sub end_testsuite($$$$$)
+{
+ my ($self, $state, $expected_ret, $ret, $envlog) = @_;
+ my $out = "";
+
+ $out .= "TEST RUNTIME: " . (time() - $state->{START_TIME}) . "s\n";
+
+ if ($ret == $expected_ret) {
+ $out .= "ALL OK\n";
+ } else {
+ $out .= "ERROR: $ret";
+ $out .= $self->{test_output}->{$state->{NAME}};
+ }
+
+ $out .= "PCAP FILE: $state->{PCAP_FILE}\n" if defined($state->{PCAP_FILE});
+
+ $out .= $envlog;
+
+ $out .= "==========================================\n";
+ if ($ret == $expected_ret) {
+ $out .= "TEST PASSED: $state->{NAME}\n";
+ } else {
+ $out .= "TEST FAILED: $state->{NAME} (status $ret)\n";
+ }
+ $out .= "==========================================\n";
+
+ print $out;
+}
+
+sub start_test($$$)
+{
+ my ($self, $state, $testname) = @_;
+}
+
+sub end_test($$$$$)
+{
+ my ($self, $state, $testname, $result, $expected) = @_;
+}
+
+sub summary($)
+{
+ my ($self) = @_;
+}
+
+sub missing_env($$$)
+{
+ my ($self, $name, $envname) = @_;
+
+ print "FAIL: $name (ENV[$envname] not available!)\n";
+}
+
+1;
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
new file mode 100644
index 0000000000..05a8bcce18
--- /dev/null
+++ b/source4/selftest/output/plain.pm
@@ -0,0 +1,101 @@
+#!/usr/bin/perl
+
+package output::plain;
+use Exporter;
+@ISA = qw(Exporter);
+
+use strict;
+
+sub new($$$$) {
+ my ($class, $verbose, $immediate, $statistics) = @_;
+ my $self = {
+ verbose => $verbose,
+ immediate => $immediate,
+ statistics => $statistics,
+ test_output => {},
+ suitesfailed => [],
+ start => time()
+ };
+ bless($self, $class);
+}
+
+sub output_msg($$$);
+
+sub start_testsuite($$)
+{
+ my ($self, $state) = @_;
+ my $out = "";
+
+ my $duration = $state->{START_TIME} - $self->{statistics}->{START_TIME};
+ $out .= "[$state->{INDEX}/$state->{TOTAL} in ".$duration."s";
+ $out .= sprintf(", %d errors", $self->{statistics}->{SUITES_FAIL}) if ($self->{statistics}->{SUITES_FAIL} > 0);
+ $out .= "] $state->{NAME}\n",
+
+ $self->{test_output}->{$state->{NAME}} = "" unless($self->{verbose});
+
+ $self->output_msg($state, "CMD: $state->{CMD}\n");
+
+ print $out;
+}
+
+sub output_msg($$$)
+{
+ my ($self, $state, $output) = @_;
+
+ if ($self->{verbose}) {
+ print $output;
+ } else {
+ $self->{test_output}->{$state->{NAME}} .= $output;
+ }
+}
+
+sub end_testsuite($$$$$)
+{
+ my ($self, $state, $expected_ret, $ret, $envlog) = @_;
+ my $out = "";
+
+ if ($ret != $expected_ret) {
+ $self->output_msg($state, "ERROR: $ret\n");
+ }
+
+ if ($ret != $expected_ret and $self->{immediate} and not $self->{verbose}) {
+ $out .= $self->{test_output}->{$state->{NAME}};
+ }
+
+ print $out;
+}
+
+sub start_test($$)
+{
+ my ($state, $testname) = @_;
+}
+
+sub end_test($$$$)
+{
+ my ($state, $testname, $result, $unexpected) = @_;
+}
+
+sub summary($)
+{
+ my ($self) = @_;
+
+ if (not $self->{immediate} and not $self->{verbose}) {
+ foreach (@{$self->{suitesfailed}}) {
+ print "===============================================================================\n";
+ print "FAIL: $_\n";
+ print $self->{test_output}->{$_};
+ print "\n";
+ }
+ }
+
+ print "FAILED ($self->{statistics}->{TESTS_UNEXPECTED_FAIL} failures and $self->{statistics}->{TESTS_ERROR} errors in $self->{statistics}->{SUITES_FAIL} testsuites)\n";
+}
+
+sub missing_env($$$)
+{
+ my ($self, $name, $envname) = @_;
+
+ print "FAIL: $name (ENV[$envname] not available!)\n";
+}
+
+1;