summaryrefslogtreecommitdiff
path: root/source4/selftest
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-08-11 22:14:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:01:40 -0500
commit7ce6a75f4b7c0fc282fbc0d4387843a278430eb1 (patch)
tree08c508d867c5052e773f91efee8a0f5e6512f77d /source4/selftest
parentbc13766a76c88e45117c8a1fd95a08d2c96789cd (diff)
downloadsamba-7ce6a75f4b7c0fc282fbc0d4387843a278430eb1.tar.gz
samba-7ce6a75f4b7c0fc282fbc0d4387843a278430eb1.tar.bz2
samba-7ce6a75f4b7c0fc282fbc0d4387843a278430eb1.zip
r24338: Add callbacks for starting and finishing tests.
(This used to be commit 824833b59a1c9c829cea4e5c4bfd2387b1bc7a2f)
Diffstat (limited to 'source4/selftest')
-rwxr-xr-xsource4/selftest/selftest.pl55
-rwxr-xr-xsource4/selftest/subunit-summary70
2 files changed, 114 insertions, 11 deletions
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 6e952dcb2b..9d4426a6e3 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -183,7 +183,7 @@ sub getlog_env($);
my $test_output = {};
-sub buildfarm_start_msg($)
+sub buildfarm_start_testsuite($)
{
my ($state) = @_;
my $out = "";
@@ -208,7 +208,7 @@ sub buildfarm_output_msg($$)
$test_output->{$state->{NAME}} .= $output;
}
-sub buildfarm_end_msg($$$)
+sub buildfarm_end_testsuite($$$)
{
my ($state, $expected_ret, $ret) = @_;
my $out = "";
@@ -237,15 +237,27 @@ sub buildfarm_end_msg($$$)
print $out;
}
+sub buildfarm_start_test($$)
+{
+ my ($state, $testname) = @_;
+}
+
+sub buildfarm_end_test($$$$)
+{
+ my ($state, $testname, $result, $expected) = @_;
+}
+
my $buildfarm_msg_ops = {
- start_msg => \&buildfarm_start_msg,
+ start_testsuite => \&buildfarm_start_testsuite,
output_msg => \&buildfarm_output_msg,
- end_msg => \&buildfarm_end_msg
+ end_testsuite => \&buildfarm_end_testsuite,
+ start_test => \&buildfarm_start_test,
+ end_test => \&buildfarm_end_test,
};
sub plain_output_msg($$);
-sub plain_start_msg($)
+sub plain_start_testsuite($)
{
my ($state) = @_;
my $out = "";
@@ -272,7 +284,7 @@ sub plain_output_msg($$)
}
}
-sub plain_end_msg($$$)
+sub plain_end_testsuite($$$)
{
my ($state, $expected_ret, $ret) = @_;
my $out = "";
@@ -294,10 +306,22 @@ sub plain_end_msg($$$)
print $out;
}
+sub plain_start_test($$)
+{
+ my ($state, $testname) = @_;
+}
+
+sub plain_end_test($$$$)
+{
+ my ($state, $testname, $result, $expected) = @_;
+}
+
my $plain_msg_ops = {
- start_msg => \&plain_start_msg,
+ start_testsuite => \&plain_start_testsuite,
output_msg => \&plain_output_msg,
- end_msg => \&plain_end_msg
+ end_testsuite => \&plain_end_testsuite,
+ start_test => \&plain_start_test,
+ end_test => \&plain_end_test,
};
sub setup_pcap($)
@@ -344,48 +368,57 @@ sub run_test($$$$$$)
setup_pcap($msg_state);
- $msg_ops->{start_msg}->($msg_state);
+ $msg_ops->{start_testsuite}->($msg_state);
open(RESULT, "$cmd 2>&1|");
while (<RESULT>) {
$msg_ops->{output_msg}->($msg_state, $_);
if (/^test: (.+)\n/) {
$open_tests->{$1} = 1;
+ $msg_ops->{start_test}->($msg_state, $1);
} elsif (/^(success|failure|skip|error): (.*?)( \[)?\n/) {
my $result = $1;
if ($1 eq "success") {
delete $open_tests->{$2};
if (expecting_failure("$name/$2")) {
$statistics->{TESTS_UNEXPECTED_OK}++;
+ $msg_ops->{end_test}->($msg_state, $2, $1, 1);
} else {
$statistics->{TESTS_EXPECTED_OK}++;
+ $msg_ops->{end_test}->($msg_state, $2, $1, 0);
}
} elsif ($1 eq "failure") {
delete $open_tests->{$2};
if (expecting_failure("$name/$2")) {
$statistics->{TESTS_EXPECTED_FAIL}++;
+ $msg_ops->{end_test}->($msg_state, $2, $1, 0);
$expected_ret = 0;
} else {
print "n:$name/$2\n";
$statistics->{TESTS_UNEXPECTED_FAIL}++;
+ $msg_ops->{end_test}->($msg_state, $2, $1, 1);
}
} elsif ($1 eq "skip") {
delete $open_tests->{$2};
+ $msg_ops->{end_test}->($msg_state, $2, $1, 0);
} elsif ($1 eq "error") {
$statistics->{TESTS_ERROR}++;
delete $open_tests->{$2};
+ $msg_ops->{end_test}->($msg_state, $2, $1, 1);
}
}
}
+
foreach (keys %$open_tests) {
- $msg_ops->{output_msg}->($msg_state, "$_ was started but never finished!\n");
+ $msg_ops->{end_test}->($msg_state, $_, "error", 1);
+ $msg_ops->{output_msg}->($msg_state, "$_ was started but never finished!");
$statistics->{TESTS_ERROR}++;
}
my $ret = close(RESULT);
cleanup_pcap($msg_state, $expected_ret, $ret);
- $msg_ops->{end_msg}->($msg_state, $expected_ret, $ret);
+ $msg_ops->{end_testsuite}->($msg_state, $expected_ret, $ret);
if ($ret != $expected_ret) {
push(@$suitesfailed, $name);
diff --git a/source4/selftest/subunit-summary b/source4/selftest/subunit-summary
new file mode 100755
index 0000000000..aec50ed02a
--- /dev/null
+++ b/source4/selftest/subunit-summary
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+# Simple subunit parser
+# (C) 2006 Jelmer Vernooij <jelmer@samba.org>
+
+use strict;
+use Getopt::Long;
+
+my $numtests = 0;
+my $numfails = 0;
+my $numskips = 0;
+my $numsuccess = 0;
+
+my $opt_help = 0;
+my $opt_progress = 0;
+
+my $result = GetOptions (
+ 'help|h|?' => \$opt_help,
+ 'progress' => \$opt_progress
+ );
+
+if (not $result) {
+ exit(1);
+}
+
+if ($opt_help) {
+ print "subunit output summarizer\n";
+ print "Copyright (C) 2006 Jelmer Vernooij <jelmer\@samba.org>\n";
+ print "\n";
+ print "Usage: subunit-summary [OPTION]\n";
+ print " --help Print this help message\n";
+ print "\n";
+ exit(0);
+}
+
+while(<STDIN>) {
+ next unless (/^(.+): (.+?)( \[)?$/);
+ if ($1 eq "test") {
+ $numtests++;
+ } elsif ($1 eq "error") {
+ print "E" if ($opt_progress);
+ } elsif ($1 eq "failure") {
+ $numfails++;
+ print "F" if ($opt_progress);
+ } elsif ($1 eq "success") {
+ $numsuccess++;
+ print "." if ($opt_progress);
+ } elsif ($1 eq "skip") {
+ $numskips++;
+ print "I" if ($opt_progress);
+ } elsif ($1 eq "testsuite") {
+ if ($opt_progress) {
+ if ($numtests) { print "\n"; }
+ print "$2: ";
+ }
+ }
+}
+
+print "\n" if ($opt_progress);
+
+if ($numtests == 0) {
+ print "No tests run\n";
+ exit(0);
+}
+
+printf("%d%%: %d tests, %d succeeded, %d failed, %d skipped\n",
+ ($numsuccess / $numtests * 100),
+ $numtests,
+ $numsuccess,
+ $numfails,
+ $numskips);