[SCM] Samba Shared Repository - branch master updated -
694a579cb8d418a4feb441a77c0dc000023f2c6e
Jelmer Vernooij
jelmer at samba.org
Sun Oct 19 08:29:22 GMT 2008
The branch, master has been updated
via 694a579cb8d418a4feb441a77c0dc000023f2c6e (commit)
via 0fd0fc75c46b39a611c7f9a56081105714d73e36 (commit)
via 69d38a95c29498c0266cb98b911faa3e7240c787 (commit)
via 182a0e349082fd43ec410cd6ac512376748fa27d (commit)
from 2fc058bdb0dd7d6ed2ffb17f049a677709d8be74 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 694a579cb8d418a4feb441a77c0dc000023f2c6e
Merge: 2fc058bdb0dd7d6ed2ffb17f049a677709d8be74 0fd0fc75c46b39a611c7f9a56081105714d73e36
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Oct 19 10:20:37 2008 +0200
Merge branch 'selftest' of git://git.samba.org/jelmer/samba
commit 0fd0fc75c46b39a611c7f9a56081105714d73e36
Merge: 69d38a95c29498c0266cb98b911faa3e7240c787 47f7ef8f39ba482a7d6578ab82c9e0670381c4f8
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sat Oct 11 03:12:21 2008 +0200
Merge branch 'master' of ssh://git.samba.org/data/git/samba into selftest
Conflicts:
selftest/selftest.pl
commit 69d38a95c29498c0266cb98b911faa3e7240c787
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Thu Sep 18 19:53:05 2008 +0200
keep obsolete file in samba4 source directory.
commit 182a0e349082fd43ec410cd6ac512376748fa27d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Thu Sep 18 19:51:03 2008 +0200
Move selftest code to top-level.
-----------------------------------------------------------------------
Summary of changes:
selftest/README | 119 ++++
selftest/SocketWrapper.pm | 66 +++
selftest/Subunit.pm | 97 ++++
selftest/TODO | 2 +
selftest/output/buildfarm.pm | 120 ++++
selftest/output/html.pm | 354 ++++++++++++
selftest/output/plain.pm | 212 +++++++
selftest/output/testresults.css | 129 +++++
selftest/selftest.pl | 871 ++++++++++++++++++++++++++++
selftest/target/Kvm.pm | 167 ++++++
selftest/target/Samba3.pm | 434 ++++++++++++++
selftest/target/Samba4.pm | 956 +++++++++++++++++++++++++++++++
selftest/target/Windows.pm | 40 ++
selftest/test_samba4.pl | 20 +
selftest/test_subunit.pl | 7 +
source4/Makefile | 4 +-
source4/samba4-knownfail | 52 --
source4/samba4-quick | 38 --
source4/samba4-skip | 61 --
source4/samba4-slow | 7 -
source4/selftest/README | 119 ----
source4/selftest/SocketWrapper.pm | 66 ---
source4/selftest/Subunit.pm | 97 ----
source4/selftest/TODO | 2 -
source4/selftest/config.mk | 6 +-
source4/selftest/knownfail | 52 ++
source4/selftest/output/buildfarm.pm | 120 ----
source4/selftest/output/html.pm | 354 ------------
source4/selftest/output/plain.pm | 212 -------
source4/selftest/output/testresults.css | 129 -----
source4/selftest/quick | 38 ++
source4/selftest/samba4_tests.sh | 396 -------------
source4/selftest/selftest.pl | 871 ----------------------------
source4/selftest/skip | 61 ++
source4/selftest/slow | 7 +
source4/selftest/target/Kvm.pm | 167 ------
source4/selftest/target/Samba3.pm | 434 --------------
source4/selftest/target/Samba4.pm | 956 -------------------------------
source4/selftest/target/Windows.pm | 40 --
source4/selftest/test_samba4.pl | 20 -
source4/selftest/test_subunit.pl | 7 -
source4/selftest/tests.sh | 394 +++++++++++++
42 files changed, 4151 insertions(+), 4153 deletions(-)
create mode 100644 selftest/README
create mode 100644 selftest/SocketWrapper.pm
create mode 100644 selftest/Subunit.pm
create mode 100644 selftest/TODO
create mode 100644 selftest/output/buildfarm.pm
create mode 100644 selftest/output/html.pm
create mode 100644 selftest/output/plain.pm
create mode 100644 selftest/output/testresults.css
create mode 100755 selftest/selftest.pl
create mode 100644 selftest/target/Kvm.pm
create mode 100644 selftest/target/Samba3.pm
create mode 100644 selftest/target/Samba4.pm
create mode 100644 selftest/target/Windows.pm
create mode 100755 selftest/test_samba4.pl
create mode 100755 selftest/test_subunit.pl
delete mode 100644 source4/samba4-knownfail
delete mode 100644 source4/samba4-quick
delete mode 100644 source4/samba4-skip
delete mode 100644 source4/samba4-slow
delete mode 100644 source4/selftest/README
delete mode 100644 source4/selftest/SocketWrapper.pm
delete mode 100644 source4/selftest/Subunit.pm
delete mode 100644 source4/selftest/TODO
create mode 100644 source4/selftest/knownfail
delete mode 100644 source4/selftest/output/buildfarm.pm
delete mode 100644 source4/selftest/output/html.pm
delete mode 100644 source4/selftest/output/plain.pm
delete mode 100644 source4/selftest/output/testresults.css
create mode 100644 source4/selftest/quick
delete mode 100755 source4/selftest/samba4_tests.sh
delete mode 100755 source4/selftest/selftest.pl
create mode 100644 source4/selftest/skip
create mode 100644 source4/selftest/slow
delete mode 100644 source4/selftest/target/Kvm.pm
delete mode 100644 source4/selftest/target/Samba3.pm
delete mode 100644 source4/selftest/target/Samba4.pm
delete mode 100644 source4/selftest/target/Windows.pm
delete mode 100755 source4/selftest/test_samba4.pl
delete mode 100755 source4/selftest/test_subunit.pl
create mode 100755 source4/selftest/tests.sh
Changeset truncated at 500 lines:
diff --git a/selftest/README b/selftest/README
new file mode 100644
index 0000000..f8be20a
--- /dev/null
+++ b/selftest/README
@@ -0,0 +1,119 @@
+# vim: ft=rst
+
+This directory contains test scripts that are useful for running a
+bunch of tests all at once.
+
+Available testsuites
+====================
+The available testsuites are obtained from a script, usually
+selftest/samba{3,4}_tests.sh. This script should for each testsuite output
+the name of the test, the command to run and the environment that should be
+provided. Use the included "plantest" function to generate the required output.
+
+Testsuite behaviour
+================================
+
+Exit code
+------------
+The testsuites should exit with a non-zero exit code if at least one
+test failed. Skipped tests should not influence the exit code.
+
+Output format
+-------------
+Testsuites can simply use the exit code to indicate whether all of their
+tests have succeeded or one or more have failed. It is also possible to
+provide more granular information using the Subunit protocol.
+
+This protocol works by writing simple messages to standard output. Any
+messages that can not be interpreted by this protocol are considered comments
+for the last announced test.
+
+Accepted commands are:
+
+test
+~~~~~~~~~~~~
+test: <NAME>
+
+Announce that a new test with the specified name is starting
+
+success
+~~~~~~~~~~~~~~~
+success: <NAME>
+
+Announce that the test with the specified name is done and ran successfully.
+
+failure
+~~~~~~~~~~~~~~~
+failure: <NAME>
+failure: <NAME> [ REASON ]
+
+Announce that the test with the specified name failed. Optionally, it is
+possible to specify a reason it failed.
+
+skip
+~~~~~~~~~~~~
+skip: <NAME>
+skip: <NAME> [ REASON ]
+
+Announce that the test with the specified name was skipped. Optionally a
+reason can be specified.
+
+knownfail
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+knownfail: <NAME>
+knownfail: <NAME> [ REASON ]
+
+Announce that the test with the specified name was run and failed as expected.
+Alternatively it is also possible to simply return "failure:" here but
+specify in the samba4-knownfailures file that it is failing.
+
+Environments
+============
+Tests often need to run against a server with particular things set up,
+a "environment". This environment is provided by the test "target": Samba 3,
+Samba 4 or Windows.
+
+The following environments are currently available:
+
+ - none: No server set up, no variables set.
+ - dc: Domain controller set up. The following environment variables will
+ be set:
+
+ * USERNAME: Administrator user name
+ * PASSWORD: Administrator password
+ * DOMAIN: Domain name
+ * REALM: Realm name
+ * SERVER: DC host name
+ * SERVER_IP: DC IPv4 address
+ * NETBIOSNAME: DC NetBIOS name
+ * NETIOSALIAS: DC NetBIOS alias
+
+ - member: Domain controller and member server that is joined to it set up. The
+ following environment variables will be set:
+
+ * USERNAME: Domain administrator user name
+ * PASSWORD: Domain administrator password
+ * DOMAIN: Domain name
+ * REALM: Realm name
+ * SERVER: Name of the member server
+
+
+Running tests
+=============
+
+To run all the tests use::
+
+ make test
+
+To run a quick subset (aiming for about 1 minute of testing) run::
+
+ make quicktest
+
+To run a specific test, use this syntax::
+
+ make test TESTS=testname
+
+for example::
+
+ make test TESTS=samba4.BASE-DELETE
+
diff --git a/selftest/SocketWrapper.pm b/selftest/SocketWrapper.pm
new file mode 100644
index 0000000..e63605b
--- /dev/null
+++ b/selftest/SocketWrapper.pm
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+# Bootstrap Samba and run a number of tests against it.
+# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package SocketWrapper;
+
+use Exporter;
+ at ISA = qw(Exporter);
+ at EXPORT_OK = qw(setup_dir setup_pcap set_default_iface);
+
+use strict;
+use FindBin qw($RealBin);
+
+sub setup_dir($$)
+{
+ my ($dir, $pcap) = @_;
+ my $pcap_dir = undef;
+
+ if (defined($dir)) {
+ if ( -d $dir ) {
+ unlink <$dir/*>;
+ } else {
+ mkdir($dir, 0777);
+ }
+
+ if ($pcap) {
+ $pcap_dir = $dir."/pcap";
+
+ if ( -d $pcap_dir ) {
+ unlink <$pcap_dir/*>;
+ } else {
+ mkdir($pcap_dir, 0777);
+ }
+ }
+ }
+
+ if (defined($pcap_dir)) {
+ $ENV{SOCKET_WRAPPER_PCAP_DIR} = $pcap_dir;
+ } else {
+ delete $ENV{SOCKET_WRAPPER_PCAP_DIR};
+ }
+
+ if (defined($dir)) {
+ $ENV{SOCKET_WRAPPER_DIR} = $dir;
+ } else {
+ delete $ENV{SOCKET_WRAPPER_DIR};
+ }
+
+ return $dir;
+}
+
+sub setup_pcap($)
+{
+ my ($pcap_file) = @_;
+
+ $ENV{SOCKET_WRAPPER_PCAP_FILE} = $pcap_file;
+}
+
+sub set_default_iface($)
+{
+ my ($i) = @_;
+ $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = $i;
+}
+
+1;
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
new file mode 100644
index 0000000..05e51da
--- /dev/null
+++ b/selftest/Subunit.pm
@@ -0,0 +1,97 @@
+package Subunit;
+
+require Exporter;
+ at ISA = qw(Exporter);
+ at EXPORT_OK = qw(parse_results);
+
+use strict;
+
+sub parse_results($$$$$)
+{
+ my ($msg_ops, $statistics, $fh, $expecting_failure, $open_tests) = @_;
+ my $unexpected_ok = 0;
+ my $expected_fail = 0;
+ my $unexpected_fail = 0;
+ my $unexpected_err = 0;
+ my $orig_open_len = $#$open_tests;
+
+ while(<$fh>) {
+ if (/^test: (.+)\n/) {
+ $msg_ops->control_msg($_);
+ $msg_ops->start_test($open_tests, $1);
+ push (@$open_tests, $1);
+ } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) {
+ $msg_ops->control_msg($_);
+ 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($open_tests, $2, $1, 1, "reason interrupted");
+ return 1;
+ }
+ }
+ my $result = $1;
+ if ($1 eq "success" or $1 eq "successful") {
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ if ($expecting_failure->(join(".", @$open_tests) . ".$2")) {
+ $statistics->{TESTS_UNEXPECTED_OK}++;
+ $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
+ $unexpected_ok++;
+ } else {
+ $statistics->{TESTS_EXPECTED_OK}++;
+ $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
+ }
+ } elsif ($1 eq "failure") {
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ if ($expecting_failure->(join(".", @$open_tests) . ".$2")) {
+ $statistics->{TESTS_EXPECTED_FAIL}++;
+ $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
+ $expected_fail++;
+ } else {
+ $statistics->{TESTS_UNEXPECTED_FAIL}++;
+ $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
+ $unexpected_fail++;
+ }
+ } elsif ($1 eq "knownfail") {
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $statistics->{TESTS_EXPECTED_FAIL}++;
+ $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
+ } elsif ($1 eq "skip") {
+ $statistics->{TESTS_SKIP}++;
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
+ } elsif ($1 eq "error") {
+ $statistics->{TESTS_ERROR}++;
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $msg_ops->end_test($open_tests, $2, $1, 1, $reason);
+ $unexpected_err++;
+ }
+ } else {
+ $msg_ops->output_msg($_);
+ }
+ }
+
+ while ($#$open_tests > $orig_open_len) {
+ $msg_ops->end_test($open_tests, pop(@$open_tests), "error", 1,
+ "was started but never finished!");
+ $statistics->{TESTS_ERROR}++;
+ $unexpected_err++;
+ }
+
+ return 1 if $unexpected_err > 0;
+ return 1 if $unexpected_fail > 0;
+ return 1 if $unexpected_ok > 0 and $expected_fail > 0;
+ return 0 if $unexpected_ok > 0 and $expected_fail == 0;
+ return 0 if $expected_fail > 0;
+ return 1;
+}
+
+1;
diff --git a/selftest/TODO b/selftest/TODO
new file mode 100644
index 0000000..67776ff
--- /dev/null
+++ b/selftest/TODO
@@ -0,0 +1,2 @@
+- warn about unexpected successes
+- better way to detect that smbd has finished initialization
diff --git a/selftest/output/buildfarm.pm b/selftest/output/buildfarm.pm
new file mode 100644
index 0000000..cee6c1e
--- /dev/null
+++ b/selftest/output/buildfarm.pm
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+
+package output::buildfarm;
+
+use Exporter;
+ at ISA = qw(Exporter);
+
+use FindBin qw($RealBin);
+use lib "$RealBin/..";
+
+use Subunit qw(parse_results);
+
+use strict;
+
+sub new($$$) {
+ my ($class) = @_;
+ my $self = {
+ test_output => {},
+ start_time => time()
+ };
+ bless($self, $class);
+}
+
+sub start_testsuite($$)
+{
+ my ($self, $name) = @_;
+ my $out = "";
+
+ $self->{NAME} = $name;
+ $self->{START_TIME} = time();
+
+ my $duration = $self->{START_TIME} - $self->{start_time};
+ $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";
+
+ $self->{test_output}->{$name} = "";
+
+ print $out;
+}
+
+sub output_msg($$)
+{
+ my ($self, $output) = @_;
+
+ $self->{test_output}->{$self->{NAME}} .= $output;
+}
+
+sub control_msg($$)
+{
+ my ($self, $output) = @_;
+
+ $self->{test_output}->{$self->{NAME}} .= $output;
+}
+
+sub end_testsuite($$$$$$)
+{
+ my ($self, $name, $result, $unexpected, $reason) = @_;
+ my $out = "";
+
+ $out .= "TEST RUNTIME: " . (time() - $self->{START_TIME}) . "s\n";
+
+ if (not $unexpected) {
+ $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($$$)
+{
+ my ($self, $parents, $testname) = @_;
+
+ if ($#$parents == -1) {
+ $self->start_testsuite($testname);
+ }
+}
+
+sub end_test($$$$$)
+{
+ my ($self, $parents, $testname, $result, $unexpected, $reason) = @_;
+
+ if ($unexpected) {
+ $self->{test_output}->{$self->{NAME}} .= "UNEXPECTED($result): $testname\n";
+ }
+
+ if ($#$parents == -1) {
+ $self->end_testsuite($testname, $result, $unexpected, $reason);
+ }
+}
+
+sub summary($)
+{
+ my ($self) = @_;
+
+ print "DURATION: " . (time() - $self->{start_time}) . " seconds\n";
+}
+
+sub skip_testsuite($$$$)
+{
+ my ($self, $name, $reason) = @_;
+
+ print "SKIPPED: $name\n";
+}
+
+1;
diff --git a/selftest/output/html.pm b/selftest/output/html.pm
new file mode 100644
index 0000000..1049527
--- /dev/null
+++ b/selftest/output/html.pm
@@ -0,0 +1,354 @@
+#!/usr/bin/perl
+
+package output::html;
+use Exporter;
+ at ISA = qw(Exporter);
+
+use strict;
+use warnings;
+
+use FindBin qw($RealBin);
+use lib "$RealBin/..";
+
+use Subunit qw(parse_results);
+
+sub new($$$) {
+ my ($class, $dirname, $statistics) = @_;
+ my $self = {
+ dirname => $dirname,
+ active_test => undef,
+ local_statistics => {},
+ statistics => $statistics,
+ msg => "",
+ error_summary => {
+ skip => [],
+ expected_success => [],
+ unexpected_success => [],
+ expected_failure => [],
+ unexpected_failure => [],
+ skip_testsuites => [],
+ error => []
+ }
+ };
+
+ link("$RealBin/output/testresults.css", "$dirname/testresults.css");
+
+ open(INDEX, ">$dirname/index.html");
+
+ bless($self, $class);
+
+ $self->print_html_header("Samba Testsuite Run", *INDEX);
+
+ print INDEX " <center>";
+ print INDEX " <table>\n";
+ print INDEX " <tr>\n";
+ print INDEX " <td class=\"tableHead\">Test</td>\n";
+ print INDEX " <td class=\"tableHead\">Result</td>\n";
+ print INDEX " </tr>\n";
+
+ return $self;
+}
+
+sub print_html_header($$$)
+{
+ my ($self, $title, $fh) = @_;
+
+ print $fh "<html lang=\"en\">\n";
+ print $fh "<head>\n";
+ print $fh " <title>$title</title>\n";
+ print $fh " <link rel=\"stylesheet\" type=\"text/css\" href=\"testresults.css\"/>\n";
+ print $fh "</head>\n";
--
Samba Shared Repository
More information about the samba-cvs
mailing list