Rev 11292: Add documentation, initial support for the buildfarm in file:///home/jelmer/bzr.samba/4.0-perlselftest/

Jelmer Vernooij jelmer at samba.org
Wed Jan 24 16:00:24 GMT 2007


------------------------------------------------------------
revno: 11292
revision-id: jelmer at samba.org-20070124160007-unjqs7exmgubw5df
parent: jelmer at samba.org-20070124120547-lbfekqf9uurf0die
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-perlselftest
timestamp: Wed 2007-01-24 17:00:07 +0100
message:
  Add documentation, initial support for the buildfarm
modified:
  source/script/tests/selftest.pl svn-v2:20693 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2fselftest.pl
=== modified file 'source/script/tests/selftest.pl'
--- a/source/script/tests/selftest.pl	2007-01-22 23:49:29 +0000
+++ b/source/script/tests/selftest.pl	2007-01-24 16:00:07 +0000
@@ -2,6 +2,82 @@
 # 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.
+
+=pod
+
+=head1 NAME
+
+selftest - Samba test runner
+
+=head1 SYNOPSIS
+
+selftest --help
+
+selftest [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--one] PREFIX
+
+=head1 DESCRIPTION
+
+A simple test runner.
+
+=head1 OPTIONS
+
+=over 4
+
+=item I<--help>
+
+Show list of available options.
+		
+=item I<--target samba4|samba3|win>
+
+Specify test target against which to run. Default is 'samba4'.
+
+=item I<--quick>
+
+Run only a limited number of tests. Intended to run in about 30 seconds on 
+moderately recent systems.
+		
+=item I<--socket-wrapper>
+
+Use socket wrapper library for communication with server. Only works 
+when the server is running locally.
+
+Will prevent TCP and UDP ports being opened on the local host but 
+(transparently) redirects these calls to use unix domain sockets.
+
+=item I<--one>
+
+Abort as soon as one test fails.
+
+=back
+
+=head1 ENVIRONMENT
+
+=over 4
+
+=item I<SMBD_VALGRIND>
+
+=item I<TORTURE_MAXTIME>
+
+=item I<VALGRIND>
+
+=item I<TEST_LDAP>
+
+=item I<TLS_ENABLED>
+
+=item I<srcdir>
+
+=back
+
+=head1 LICENSE
+
+selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
+
+=head1 AUTHOR
+
+Jelmer Vernooij
+
+=cut
+
 use strict;
 use warnings;
 
@@ -11,6 +87,12 @@
 use POSIX;
 use Cwd;
 
+my $opt_help = 0;
+my $opt_target = "samba4";
+my $opt_quick = 0;
+my $opt_socket_wrapper = 0;
+my $opt_one = 0;
+
 sub slapd_start($$) {
 	my ($conf, $uri) = @_;
     my $oldpath = $ENV{PATH};
@@ -91,12 +173,58 @@
 	exit $failed;
 }
 
+my $totalfailed = 0;
+my $start = time();
+
+sub run_test_buildfarm($$$$)
+{
+	my ($name, $cmd, $i, $total) = @_;
+	print "--==--==--==--==--==--==--==--==--==--==--\n";
+	print "Running test $name (level 0 stdout)\n";
+	print "--==--==--==--==--==--==--==--==--==--==--\n";
+	system("date");
+	print "Testing $name";
+
+	system($cmd);
+
+#	print "SMBD is down! Skipping: $cmd\n";
+#	print "==========================================\n";
+#	print "TEST SKIPPED: $name (reason SMBD is down)\n";
+#	print "==========================================\n";
+#
+	print "ALL OK: $cmd\n";
+	print "==========================================\n";
+	print "TEST PASSED: $name\n";
+	print "==========================================\n";
+
+	my $ret = 0;
+	if ($ret != 0) {
+		$totalfailed++;
+	}
+}
+
+sub run_test_plain($$$$)
+{
+	my ($name, $cmd, $i, $total) = @_;
+	my $err = "";
+	if ($totalfailed > 0) { $err = ", $totalfailed errors"; }
+	printf "[$i/$total in " . (time() - $start)."s$err] $name\n";
+	open(RESULT, "$cmd 2>/dev/null|");
+	while (<RESULT>) { }
+	close(RESULT);
+	my $ret = 0;
+	if ($ret != 0) {
+		$totalfailed++;
+		exit(1) if ($opt_one);
+	}
+}
+
 sub ShowHelp()
 {
 	print "Samba test runner
 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
 
-Usage: $Script PREFIX
+Usage: $Script [OPTIONS] PREFIX
 
 Generic options:
  --help                     this help page
@@ -108,11 +236,6 @@
 	exit(0);
 }
 
-my $opt_help = 0;
-my $opt_target = "samba4";
-my $opt_quick = 0;
-my $opt_socket_wrapper = 0;
-my $opt_one = 0;
 
 my $result = GetOptions (
 	    'help|h|?' => \$opt_help,
@@ -160,6 +283,8 @@
 my $testsdir = "$srcdir/script/tests";
 
 my $tls_enabled = not $opt_quick;
+my $from_build_farm = (defined($ENV{RUN_FROM_BUILD_FARM}) and 
+                      ($ENV{RUN_FROM_BUILD_FARM} eq "yes"));
 
 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
 $ENV{LD_LDB_MODULE_PATH} = "$old_pwd/bin/modules/ldb";
@@ -236,18 +361,17 @@
 $ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = 6;
 $ENV{TORTURE_INTERFACES} = '127.0.0.6/8,127.0.0.7/8,127.0.0.8/8,127.0.0.9/8,127.0.0.10/8,127.0.0.11/8';
 
-my @torture_options = ("--option=interfaces=$ENV{TORTURE_INTERFACES} $ENV{CONFIGURATION}");
+my @torture_options = ();
+push (@torture_options, "--option=interfaces=$ENV{TORTURE_INTERFACES}");
+push (@torture_options, $ENV{CONFIGURATION});
 # ensure any one smbtorture call doesn't run too long
 push (@torture_options, "--maximum-runtime=$torture_maxtime");
 push (@torture_options, "--target=$opt_target");
-push (@torture_options, "--option=torture:progress=no") 
-	if (defined($ENV{RUN_FROM_BUILD_FARM}) and $ENV{RUN_FROM_BUILD_FARM} eq "yes");
+push (@torture_options, "--option=torture:progress=no") if ($from_build_farm);
 
 $ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
 print "OPTIONS $ENV{TORTURE_OPTIONS}\n";
 
-my $start = time();
-
 open(DATA, ">$test_fifo");
 
 # give time for nbt server to register its names
@@ -264,7 +388,6 @@
 
 # start off with 0 failures
 $ENV{failed} = 0;
-my $totalfailed = 0;
 
 my @todo = ();
 
@@ -293,24 +416,16 @@
 my $total = $#todo + 1;
 my $i = 0;
 $| = 1;
-$result = {};
 
 foreach (@todo) {
 	$i++;
-	my $err = "";
-	if ($totalfailed > 0) { $err = ", $totalfailed errors"; }
-	printf "[$i/$total in " . (time() - $start)."s$err] $$_[0]\n";
 	my $cmd = $$_[1];
 	$cmd =~ s/([\(\)])/\\$1/g;
 	my $name = $$_[0];
-	$result->{$name} = "";
-	open(RESULT, "$cmd 2>/dev/null|");
-	while (<RESULT>) { $result->{$name}.=$_; }
-	close(RESULT);
-	my $ret = 0;
-	if ($ret != 0) {
-		$totalfailed++;
-		exit(1) if ($opt_one);
+	if ($from_build_farm) {
+		run_test_buildfarm($name, $cmd, $i, $total);
+	} else {
+		run_test_plain($name, $cmd, $i, $total);
 	}
 }
 



More information about the samba-cvs mailing list