[SCM] Samba Shared Repository - branch master updated
Jelmer Vernooij
jelmer at samba.org
Tue Sep 14 02:53:30 MDT 2010
The branch, master has been updated
via dcadb90 subunit: Use RemoteError when passing errors to upstream subunit.
via 8e328c4 param: Add prototype for lpcfg_private_dir(), used by openchange.
via 1e5ea0b subunit.pm: Fold Subunit::Filter into Subunit, trim further.
via c0923cf subunit.pm: Remove output_msg/control_msg functions.
via 7d4968e selftest: Remove testsuite parsing.
via d3960f6 subunit.pm: Simplify subunit handling in perl.
via 49411fa subunit.pm: Pass through milliseconds in time reports.
via 9f3a43c selftest: Report times in milliseconds rather than seconds.
via d67eeaf subunit: Use standard subunit functions for reproducing subunit streams.
via d2fb9ce subunit: Remove unused methods.
via b61cc18 subunit: Use standard functions for addSuccess, addExpectedFail, addFailure, addSkip.
via c1fe7b4 subunit: Use standard addError method implementation.
via 881f610 subunit: Pass TestCase objects to startTest rather than test name strings.
via 1626dc2 subunit: Use subunit standard functions for handling time and progress.
via fb1c966 subunit: Use standard subunit test protocol client, use standard name for startTest.
via 8530d5a subunit: Initial work on using the standard TestResult class.
from 4c45e29 s3-waf: fix the build after privilege code changes.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit dcadb90bd3d678e45fa84c2899ec23bf604bffa8
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Tue Sep 14 03:47:04 2010 +0200
subunit: Use RemoteError when passing errors to upstream subunit.
commit 8e328c4e329221011a2f018c5c050dc6b642db70
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Tue Sep 14 02:36:51 2010 +0200
param: Add prototype for lpcfg_private_dir(), used by openchange.
commit 1e5ea0be8461ebde4fc52fedeebb0628e1eaf44d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Tue Sep 14 00:22:55 2010 +0200
subunit.pm: Fold Subunit::Filter into Subunit, trim further.
commit c0923cfac1a15efddaadfb851d0eab93eba31ef3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Tue Sep 14 00:09:46 2010 +0200
subunit.pm: Remove output_msg/control_msg functions.
commit 7d4968e161d5868b65dd5d8ef5bb0e391109c0b5
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Tue Sep 14 00:04:54 2010 +0200
selftest: Remove testsuite parsing.
commit d3960f6b406272cc37820fad04aed6ddfd4e6cce
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 23:56:26 2010 +0200
subunit.pm: Simplify subunit handling in perl.
commit 49411fa1079fc78cba4751d57a3c76096fc1b772
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 23:22:35 2010 +0200
subunit.pm: Pass through milliseconds in time reports.
commit 9f3a43c0182b8b13b2f4ff615b5aca816f4f05b3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 23:07:41 2010 +0200
selftest: Report times in milliseconds rather than seconds.
commit d67eeafc4de2bd5a90b7865a2910b03d6c5c1fca
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 22:29:38 2010 +0200
subunit: Use standard subunit functions for reproducing subunit streams.
commit d2fb9ce472909c9e481d7d81d699460c882480a9
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 22:13:15 2010 +0200
subunit: Remove unused methods.
commit b61cc18972616f33397745e20150613928e683a2
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 22:09:46 2010 +0200
subunit: Use standard functions for addSuccess, addExpectedFail,
addFailure, addSkip.
commit c1fe7b498a680a4f9d94e3633e6d9c566fb61fe4
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 21:55:22 2010 +0200
subunit: Use standard addError method implementation.
commit 881f610f06fc644bbbd146d939be5cd1adc19a73
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 21:42:32 2010 +0200
subunit: Pass TestCase objects to startTest rather than test name strings.
commit 1626dc2bc95ef1c17221ba1a6404a72e21fcfc5b
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 21:31:08 2010 +0200
subunit: Use subunit standard functions for handling time and progress.
commit fb1c96665201a8090bcf14db7a71a752e4cd7041
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 21:17:05 2010 +0200
subunit: Use standard subunit test protocol client, use standard name for startTest.
commit 8530d5afdee8fbc4d87398839d37c503dc05410d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Mon Sep 13 20:53:54 2010 +0200
subunit: Initial work on using the standard TestResult class.
-----------------------------------------------------------------------
Summary of changes:
lib/torture/torture.c | 3 +-
selftest/Subunit.pm | 123 ++++---------------------
selftest/Subunit/Filter.pm | 186 -------------------------------------
selftest/filter-subunit | 3 +-
selftest/format-subunit | 47 +++++++---
selftest/selftest.pl | 24 ++---
selftest/subunithelper.py | 221 ++++++++++++++++++++------------------------
source4/param/param.h | 1 +
8 files changed, 166 insertions(+), 442 deletions(-)
delete mode 100644 selftest/Subunit/Filter.pm
Changeset truncated at 500 lines:
diff --git a/lib/torture/torture.c b/lib/torture/torture.c
index 27b2bdc..0bf50cc 100644
--- a/lib/torture/torture.c
+++ b/lib/torture/torture.c
@@ -71,7 +71,7 @@ struct torture_context *torture_context_child(struct torture_context *parent)
subtorture->results = talloc_reference(subtorture, parent->results);
return subtorture;
-}
+}
/**
create a temporary directory.
@@ -343,7 +343,6 @@ static bool internal_torture_run_test(struct torture_context *context,
context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name);
}
-
context->active_tcase = tcase;
context->active_test = test;
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index 7a352bd..a94eecd 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -19,104 +19,40 @@ use POSIX;
require Exporter;
@ISA = qw(Exporter);
- at EXPORT_OK = qw(parse_results);
+ at EXPORT_OK = qw(filter_add_prefix);
use strict;
-sub parse_results($$$)
+sub filter_add_prefix($$)
{
- my ($msg_ops, $statistics, $fh) = @_;
- my $expected_fail = 0;
- my $open_tests = [];
+ my ($prefix, $fh) = @_;
while(<$fh>) {
if (/^test: (.+)\n/) {
- $msg_ops->control_msg($_);
- $msg_ops->start_test($1);
- push (@$open_tests, $1);
- } elsif (/^time: (\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)\n/) {
- $msg_ops->report_time(mktime($6, $5, $4, $3, $2-1, $1-1900));
- } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail|skip-testsuite|testsuite-failure|testsuite-xfail|testsuite-success|testsuite-error): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
- $msg_ops->control_msg($_);
+ Subunit::start_test($prefix.$1);
+ } elsif (/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ \t]*)( multipart)?\n/) {
my $result = $1;
- my $testname = $2;
+ my $testname = $prefix.$2;
my $reason = undef;
if ($3) {
$reason = "";
# reason may be specified in next lines
my $terminated = 0;
while(<$fh>) {
- $msg_ops->control_msg($_);
if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
}
-
+
unless ($terminated) {
- $statistics->{TESTS_ERROR}++;
- $msg_ops->end_test($testname, "error", 1,
- "reason ($result) interrupted\n");
- return 1;
+ print $reason;
+ $reason = "reason ($result) interrupted";
+ $result = "error";
}
}
- if ($result eq "success" or $result eq "successful") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_EXPECTED_OK}++;
- $msg_ops->end_test($testname, "success", 0, $reason);
- } elsif ($result eq "xfail" or $result eq "knownfail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_EXPECTED_FAIL}++;
- $msg_ops->end_test($testname, "xfail", 0, $reason);
- $expected_fail++;
- } elsif ($result eq "failure" or $result eq "fail") {
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $statistics->{TESTS_UNEXPECTED_FAIL}++;
- $msg_ops->end_test($testname, "failure", 1, $reason);
- } elsif ($result eq "skip") {
- $statistics->{TESTS_SKIP}++;
- # Allow tests to be skipped without prior announcement of test
- my $last = pop(@$open_tests);
- if (defined($last) and $last ne $testname) {
- push (@$open_tests, $testname);
- }
- $msg_ops->end_test($testname, "skip", 0, $reason);
- } elsif ($result eq "error") {
- $statistics->{TESTS_ERROR}++;
- pop(@$open_tests); #FIXME: Check that popped value == $testname
- $msg_ops->end_test($testname, "error", 1, $reason);
- } elsif ($result eq "skip-testsuite") {
- $msg_ops->skip_testsuite($testname);
- } elsif ($result eq "testsuite-success") {
- $msg_ops->end_testsuite($testname, "success", $reason);
- } elsif ($result eq "testsuite-failure") {
- $msg_ops->end_testsuite($testname, "failure", $reason);
- } elsif ($result eq "testsuite-xfail") {
- $msg_ops->end_testsuite($testname, "xfail", $reason);
- } elsif ($result eq "testsuite-error") {
- $msg_ops->end_testsuite($testname, "error", $reason);
- }
- } elsif (/^testsuite: (.*)\n/) {
- $msg_ops->start_testsuite($1);
+ Subunit::end_test($testname, $result, $reason);
} else {
- $msg_ops->output_msg($_);
+ print $_;
}
}
-
- while ($#$open_tests+1 > 0) {
- $msg_ops->end_test(pop(@$open_tests), "error", 1,
- "was started but never finished!\n");
- $statistics->{TESTS_ERROR}++;
- }
-
- # if the Filter module is in use, it will have the right counts
- if (defined($msg_ops->{total_error})) {
- $statistics->{TESTS_ERROR} = $msg_ops->{total_error};
- $statistics->{TESTS_UNEXPECTED_FAIL} = $msg_ops->{total_fail};
- $statistics->{TESTS_EXPECTED_FAIL} = $msg_ops->{total_xfail};
- }
-
- return 1 if $statistics->{TESTS_ERROR} > 0;
- return 1 if $statistics->{TESTS_UNEXPECTED_FAIL} > 0;
-
- return 0;
}
sub start_test($)
@@ -140,39 +76,16 @@ sub end_test($$;$)
}
}
-sub skip_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "skip", $reason);
-}
-
-sub fail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "fail", $reason);
-}
-
-sub success_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "success", $reason);
-}
-
-sub xfail_test($;$)
-{
- my $name = shift;
- my $reason = shift;
- end_test($name, "xfail", $reason);
-}
-
sub report_time($)
{
my ($time) = @_;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
- printf "time: %04d-%02d-%02d %02d:%02d:%02d\n", $year+1900, $mon+1, $mday, $hour, $min, $sec;
+ $sec = ($time - int($time) + $sec);
+ my $msg = sprintf("%f", $sec);
+ if (substr($msg, 1, 1) eq ".") {
+ $msg = "0" . $msg;
+ }
+ printf "time: %04d-%02d-%02d %02d:%02d:%s\n", $year+1900, $mon+1, $mday, $hour, $min, $msg;
}
sub progress_pop()
diff --git a/selftest/Subunit/Filter.pm b/selftest/Subunit/Filter.pm
deleted file mode 100644
index 4a94f25..0000000
--- a/selftest/Subunit/Filter.pm
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/usr/bin/perl
-# Filter a subunit stream
-# Copyright (C) Jelmer Vernooij <jelmer at samba.org>
-# Published under the GNU GPL, v3 or later
-
-package Subunit::Filter;
-
-use strict;
-
-sub read_test_regexes($)
-{
- my ($name) = @_;
- my @ret = ();
- open(LF, "<$name") or die("unable to read $name: $!");
- while (<LF>) {
- chomp;
- next if (/^#/);
- next if (/^$/);
- if (/^(.*?)([ \t]+)\#([\t ]*)(.*?)$/) {
- push (@ret, [$1, $4]);
- } else {
- s/^(.*?)([ \t]+)\#([\t ]*)(.*?)$//;
- push (@ret, [$_, undef]);
- }
- }
- close(LF);
- return @ret;
-}
-
-sub find_in_list($$)
-{
- my ($list, $fullname) = @_;
-
- foreach (@$list) {
- if ($fullname =~ /$$_[0]/) {
- return ($$_[1]) if ($$_[1]);
- return "";
- }
- }
-
- return undef;
-}
-
-sub control_msg()
-{
- # We regenerate control messages, so ignore this
-}
-
-sub report_time($$)
-{
- my ($self, $time) = @_;
- Subunit::report_time($time);
-}
-
-sub output_msg($$)
-{
- my ($self, $msg) = @_;
- unless(defined($self->{output})) {
- print $msg;
- } else {
- $self->{output}.=$msg;
- }
-}
-
-sub start_test($$)
-{
- my ($self, $testname) = @_;
-
- if (defined($self->{prefix})) {
- $testname = $self->{prefix}.$testname;
- }
-
- if ($self->{strip_ok_output}) {
- $self->{output} = "";
- }
-
- Subunit::start_test($testname);
-}
-
-sub end_test($$$$$)
-{
- my ($self, $testname, $result, $unexpected, $reason) = @_;
-
- if (defined($self->{prefix})) {
- $testname = $self->{prefix}.$testname;
- }
-
- if (($result eq "fail" or $result eq "failure") and not $unexpected) {
- $result = "xfail";
- $self->{xfail_added}++;
- $self->{total_xfail}++;
- }
- my $xfail_reason = find_in_list($self->{expected_failures}, $testname);
- if (defined($xfail_reason) and ($result eq "fail" or $result eq "failure")) {
- $result = "xfail";
- $self->{xfail_added}++;
- $self->{total_xfail}++;
- $reason .= $xfail_reason;
- }
-
- if ($result eq "fail" or $result eq "failure") {
- $self->{fail_added}++;
- $self->{total_fail}++;
- }
-
- if ($result eq "error") {
- $self->{error_added}++;
- $self->{total_error}++;
- }
-
- if ($self->{strip_ok_output}) {
- unless ($result eq "success" or $result eq "xfail" or $result eq "skip") {
- print $self->{output}
- }
- }
- $self->{output} = undef;
-
- Subunit::end_test($testname, $result, $reason);
-}
-
-sub skip_testsuite($;$)
-{
- my ($self, $name, $reason) = @_;
- Subunit::skip_testsuite($name, $reason);
-}
-
-sub start_testsuite($;$)
-{
- my ($self, $name) = @_;
- Subunit::start_testsuite($name);
-
- $self->{error_added} = 0;
- $self->{fail_added} = 0;
- $self->{xfail_added} = 0;
-}
-
-sub end_testsuite($$;$)
-{
- my ($self, $name, $result, $reason) = @_;
- my $xfail = 0;
-
- $xfail = 1 if ($self->{xfail_added} > 0);
- $xfail = 0 if ($self->{fail_added} > 0);
- $xfail = 0 if ($self->{error_added} > 0);
-
- if ($xfail and ($result eq "fail" or $result eq "failure")) {
- $result = "xfail";
- }
-
- if ($self->{fail_added} > 0 and $result ne "failure") {
- $result = "failure";
- $reason = "Subunit/Filer Reason" unless defined($reason);
- $reason .= "\n failures[$self->{fail_added}]";
- }
-
- if ($self->{error_added} > 0 and $result ne "error") {
- $result = "error";
- $reason = "Subunit/Filer Reason" unless defined($reason);
- $reason .= "\n errors[$self->{error_added}]";
- }
-
- Subunit::end_testsuite($name, $result, $reason);
-}
-
-sub testsuite_count($$)
-{
- my ($self, $count) = @_;
- Subunit::testsuite_count($count);
-}
-
-sub new {
- my ($class, $prefix, $expected_failures, $strip_ok_output) = @_;
-
- my $self = {
- prefix => $prefix,
- expected_failures => $expected_failures,
- strip_ok_output => $strip_ok_output,
- xfail_added => 0,
- total_xfail => 0,
- total_error => 0,
- total_fail => 0
- };
- bless($self, $class);
-}
-
-1;
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
index 923d5cf..f5ab660 100755
--- a/selftest/filter-subunit
+++ b/selftest/filter-subunit
@@ -43,7 +43,8 @@ def handle_sigint(sig, stack):
sys.exit(0)
signal.signal(signal.SIGINT, handle_sigint)
-msg_ops = subunithelper.FilterOps(opts.prefix, expected_failures,
+out = subunithelper.SubunitOps(sys.stdout)
+msg_ops = subunithelper.FilterOps(out, opts.prefix, expected_failures,
opts.strip_passed_output)
sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
diff --git a/selftest/format-subunit b/selftest/format-subunit
index b4509ab..0d16032 100755
--- a/selftest/format-subunit
+++ b/selftest/format-subunit
@@ -15,8 +15,9 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../lib/testtools"))
import subunithelper
import subunit
-def format_time(t):
- minutes, seconds = divmod(t, 60)
+
+def format_time(delta):
+ minutes, seconds = divmod(delta.seconds, 60)
hours, minutes = divmod(minutes, 60)
ret = ""
if hours:
@@ -27,10 +28,11 @@ def format_time(t):
return ret
-class PlainFormatter(object):
+class PlainFormatter(subunithelper.TestsuiteEnabledTestResult):
def __init__(self, summaryfile, verbose, immediate, statistics,
totaltests=None):
+ super(PlainFormatter, self).__init__()
self.verbose = verbose
self.immediate = immediate
self.statistics = statistics
@@ -44,6 +46,7 @@ class PlainFormatter(object):
self.name = None
self._progress_level = 0
self.totalsuites = totaltests
+ self.last_time = None
def progress(self, offset, whence):
if whence == subunit.PROGRESS_POP:
@@ -56,28 +59,26 @@ class PlainFormatter(object):
elif whence == subunit.PROGRESS_CUR:
raise NotImplementedError
- def report_time(self, time):
+ def time(self, dt):
if self.start_time is None:
- self.start_time = time
- self.last_time = time
+ self.start_time = dt
+ self.last_time = dt
def start_testsuite(self, name):
self.index += 1
self.name = name
- testsuite_start_time = self.last_time
-
- duration = testsuite_start_time - self.start_time
if not self.verbose:
- self.test_output[name] = ""
+ self.test_output[name] = ""
out = "[%d" % self.index
if self.totalsuites is not None:
out += "/%d" % self.totalsuites
- out += " in " + format_time(duration)
+ if self.start_time is not None:
+ out += " in " + format_time(self.last_time - self.start_time)
if self.suitesfailed:
out += ", %d errors" % (len(self.suitesfailed),)
- out += "] %s" % name
+ out += "] %s" % name
if self.immediate:
sys.stdout.write(out + "\n")
else:
@@ -121,9 +122,24 @@ class PlainFormatter(object):
sys.stdout.write(out)
- def start_test(self, testname):
+ def startTest(self, test):
pass
+ def addSuccess(self, test):
+ self.end_test(test.id(), "success", False)
+
+ def addError(self, test, details=None):
+ self.end_test(test.id(), "error", True, details)
+
+ def addFailure(self, test, details=None):
+ self.end_test(test.id(), "failure", True, details)
+
+ def addSkip(self, test, details=None):
+ self.end_test(test.id(), "skip", False, details)
+
+ def addExpectedFail(self, test, details=None):
+ self.end_test(test.id(), "xfail", False, details)
+
def end_test(self, testname, result, unexpected, reason=None):
if not unexpected:
self.test_output[self.name] = ""
@@ -135,9 +151,12 @@ class PlainFormatter(object):
'success': '.'}.get(result, "?(%s)" % result))
return
+ if not self.name in self.test_output:
+ self.test_output[self.name] = ""
+
--
Samba Shared Repository
More information about the samba-cvs
mailing list