svn commit: samba r21707 - in branches/SAMBA_4_0: . source source/build/smb_build source/lib/socket_wrapper source/script/tests source/torture source/torture/basic source/torture/raw testprogs/blackbox

jelmer at samba.org jelmer at samba.org
Mon Mar 5 21:28:56 GMT 2007


Author: jelmer
Date: 2007-03-05 21:28:55 +0000 (Mon, 05 Mar 2007)
New Revision: 21707

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21707

Log:
Finally merge my (long-living) perlselftest branch.

This changes the main selftest code to be in perl rather than in shell script.

The selftest script is now no longer a black box but a regular executable that takes 
--help.

This adds the following features:

 * "make test TESTS=foo" will run only the tests that match the regex "foo"
 * ability to deal with expected failures. the suite will not warn about tests 
   that fail and are known to fail, but will warn about other failing tests and 
   tests that are succeeding tests but incorrectly marked as failing.
 * ability to print a summary with all failures at the end of the run

It also opens up the way to the following features, which I hope to implement later:
 * "environments", for example having a complete domains with DCs and domain members 
 in a testenvironment
 * only set up smbd if necessary (not when running LOCAL tests, for example)
 * different mktestsetup scripts per target. except for the mktestsetup script, we can
   use the same infrastructure for samba 3 or windows.

Added:
   branches/SAMBA_4_0/source/script/tests/Samba4.pm
   branches/SAMBA_4_0/source/script/tests/SocketWrapper.pm
   branches/SAMBA_4_0/source/script/tests/testenv.pl
Removed:
   branches/SAMBA_4_0/source/script/tests/selftest.sh
   branches/SAMBA_4_0/source/script/tests/tests_net.sh
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/build/smb_build/makefile.pm
   branches/SAMBA_4_0/source/lib/socket_wrapper/config.m4
   branches/SAMBA_4_0/source/main.mk
   branches/SAMBA_4_0/source/samba4-knownfail
   branches/SAMBA_4_0/source/script/tests/mk-fedora-ds.sh
   branches/SAMBA_4_0/source/script/tests/mk-keyblobs.sh
   branches/SAMBA_4_0/source/script/tests/mk-openldap.sh
   branches/SAMBA_4_0/source/script/tests/mktestsetup.sh.share_ldb
   branches/SAMBA_4_0/source/script/tests/selftest.pl
   branches/SAMBA_4_0/source/script/tests/test_ejs.sh
   branches/SAMBA_4_0/source/script/tests/test_ldap.sh
   branches/SAMBA_4_0/source/script/tests/test_nbt.sh
   branches/SAMBA_4_0/source/script/tests/tests_quick.sh
   branches/SAMBA_4_0/source/script/tests/tests_xterm.sh
   branches/SAMBA_4_0/source/torture/basic/delaywrite.c
   branches/SAMBA_4_0/source/torture/raw/oplock.c
   branches/SAMBA_4_0/source/torture/smbtorture.c
   branches/SAMBA_4_0/source/torture/torture.c
   branches/SAMBA_4_0/source/torture/ui.c
   branches/SAMBA_4_0/source/torture/ui.h
   branches/SAMBA_4_0/testprogs/blackbox/test_ldb.sh


Changeset:

Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pm
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pm	2007-03-05 21:28:55 UTC (rev 21707)
@@ -157,7 +157,7 @@
 
 GCOV=$self->{config}->{GCOV}
 
-DEFAULT_TEST_TARGET=$self->{config}->{DEFAULT_TEST_TARGET}
+DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
 
 __EOD__
 );

Modified: branches/SAMBA_4_0/source/lib/socket_wrapper/config.m4
===================================================================
--- branches/SAMBA_4_0/source/lib/socket_wrapper/config.m4	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/lib/socket_wrapper/config.m4	2007-03-05 21:28:55 UTC (rev 21707)
@@ -1,7 +1,7 @@
 AC_ARG_ENABLE(socket-wrapper, 
 [  --enable-socket-wrapper         Turn on socket wrapper library (default=no)])
 
-DEFAULT_TEST_TARGET=test-noswrap
+DEFAULT_TEST_OPTIONS=
 HAVE_SOCKET_WRAPPER=no
 
 if eval "test x$developer = xyes"; then
@@ -10,9 +10,9 @@
     
 if eval "test x$enable_socket_wrapper = xyes"; then
         AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
-	DEFAULT_TEST_TARGET=test-swrap
+	DEFAULT_TEST_OPTIONS=--socket-wrapper
 	HAVE_SOCKET_WRAPPER=yes
 fi
 
-AC_SUBST(DEFAULT_TEST_TARGET)
+AC_SUBST(DEFAULT_TEST_OPTIONS)
 AC_SUBST(HAVE_SOCKET_WRAPPER)

Modified: branches/SAMBA_4_0/source/main.mk
===================================================================
--- branches/SAMBA_4_0/source/main.mk	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/main.mk	2007-03-05 21:28:55 UTC (rev 21707)
@@ -282,49 +282,56 @@
 	-rm -f $(MANPAGES)
 
 check:: test
-test: $(DEFAULT_TEST_TARGET)
 
-SELFTEST = builddir=$(builddir) srcdir=$(srcdir) \
-	    $(srcdir)/script/tests/selftest.sh ${selftest_prefix}
+SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail 
 
+test: all libraries
+	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --immediate
+
+testone: all libraries
+	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --one
+
 test-swrap: all libraries
-	$(SELFTEST) all SOCKET_WRAPPER
+	$(SELFTEST) --socket-wrapper --immediate $(TESTS) 
 
 test-noswrap: all libraries
-	$(SELFTEST) all
+	$(SELFTEST) --immediate $(TESTS)
 
+quicktestone: all
+	$(SELFTEST) --quick --socket-wrapper --one $(TESTS)
+
 quicktest: all
-	$(SELFTEST) quick SOCKET_WRAPPER
+	$(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
 
 testenv: all libraries
-	$(SELFTEST) xterm SOCKET_WRAPPER
+	$(srcdir)/script/tests/testenv.pl 
 
 valgrindtest: valgrindtest-quick
 
 valgrindtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(SELFTEST) quick SOCKET_WRAPPER
+	$(SELFTEST) --quick --immediate --socket-wrapper
 
 valgrindtest-all: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(SELFTEST) all SOCKET_WRAPPER
+	$(SELFTEST) --immediate --socket-wrapper
 
 valgrindtest-env: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e valgrind -q --db-attach=yes --num-callers=30" \
 	VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
-	$(SELFTEST) xterm SOCKET_WRAPPER
+	$(srcdir)/script/tests/testenv.pl
 
 gdbtest: gdbtest-quick
 
 gdbtest-quick: all
 	SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-	$(SELFTEST) quick SOCKET_WRAPPER
+	$(SELFTEST) --immediate --quick --socket-wrapper
 
 gdbtest-all: all libraries
 	SMBD_VALGRIND="xterm -n smbd -e gdb --args " \
-	$(SELFTEST) all SOCKET_WRAPPER
+	$(SELFTEST) --immediate --socket-wrapper
 
 wintest: all
 	$(SELFTEST) win

Modified: branches/SAMBA_4_0/source/samba4-knownfail
===================================================================
--- branches/SAMBA_4_0/source/samba4-knownfail	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/samba4-knownfail	2007-03-05 21:28:55 UTC (rev 21707)
@@ -1,3 +1,5 @@
-LOCAL-REGISTRY-*
-LOCAL-RESOLVE-async
-LOCAL-ICONV-next_codepoint()
+LOCAL-REGISTRY/(nt4|ldb|dir) # Not implemented yet
+LOCAL-RESOLVE/async
+LOCAL-ICONV/next_codepoint()
+BASE-DELAYWRITE/finfo update on close
+RAW-OPLOCK/OPLOCK

Added: branches/SAMBA_4_0/source/script/tests/Samba4.pm
===================================================================
--- branches/SAMBA_4_0/source/script/tests/Samba4.pm	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/script/tests/Samba4.pm	2007-03-05 21:28:55 UTC (rev 21707)
@@ -0,0 +1,139 @@
+#!/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 Samba4;
+
+use Exporter;
+ at ISA = qw(Exporter);
+ at EXPORT_OK = qw(slapd_start slapd_stop smbd_check_or_start provision);
+
+use strict;
+use FindBin qw($RealBin);
+use POSIX;
+
+sub slapd_start($$)
+{
+	my ($conf, $uri) = @_;
+	if (defined($ENV{FEDORA_DS_PREFIX})) {
+		system("$ENV{FEDORA_DS_PREFIX}/lib/fedora-ds/ds_newinst.pl $ENV{FEDORA_DS_INF}") or die("Unable to provision fedora ds ldapd");
+	} else {
+		my $oldpath = $ENV{PATH};
+		$ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
+		# running slapd in the background means it stays in the same process group, so it can be
+		# killed by timelimit
+		system("slapd -d0 -f $conf -h $uri &");
+		$ENV{PATH} = $oldpath;
+	}
+    return $? >> 8;
+}
+
+sub slapd_stop()
+{
+	if (defined($ENV{FEDORA_DS_PREFIX})) {
+		system("$ENV{LDAPDIR}/slapd-samba4/stop-slapd");
+	} else {
+		open(IN, "<$ENV{PIDDIR}/slapd.pid") or 
+			die("unable to open slapd pid file");
+		kill 9, <IN>;
+		close(IN);
+	}
+}
+
+sub smbd_check_or_start($$$$$$) 
+{
+	my ($bindir, $test_fifo, $test_log, $socket_wrapper_dir, $max_time, $conffile) = @_;
+	return 0 if ( -p $test_fifo );
+
+	warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless
+		defined($socket_wrapper_dir) or $< == 0;
+
+	if (defined($socket_wrapper_dir)) {
+		if ( -d $socket_wrapper_dir ) {
+			unlink <$socket_wrapper_dir/*>;
+		} else {
+			mkdir($socket_wrapper_dir);
+		}
+	}
+
+	unlink($test_fifo);
+	POSIX::mkfifo($test_fifo, 0700);
+	unlink($test_log);
+	
+	my $valgrind = "";
+	if (defined($ENV{SMBD_VALGRIND})) {
+		$valgrind = $ENV{SMBD_VALGRIND};
+	} 
+
+	print "STARTING SMBD...";
+	my $pid = fork();
+	if ($pid == 0) {
+		open STDIN, $test_fifo;
+		open STDOUT, ">$test_log";
+		open STDERR, '>&STDOUT';
+		my $optarg = "";
+		if (defined($max_time)) {
+			$optarg = "--maximum-runtime=$max_time ";
+		}
+		my $ret = system("$valgrind $bindir/smbd $optarg -s $conffile -M single -i --leak-report-full");
+		if ($? == -1) {
+			print "Unable to start smbd: $ret: $!\n";
+			exit 1;
+		}
+		unlink($test_fifo);
+		unlink(<$socket_wrapper_dir/*>) if (defined($socket_wrapper_dir) and -d $socket_wrapper_dir);
+		my $exit = $? >> 8;
+		if ( $ret == 0 ) {
+			print "smbd exits with status $exit\n";
+		} elsif ( $ret & 127 ) {
+			print "smbd got signal ".($ret & 127)." and exits with $exit!\n";
+		} else {
+			$ret = $? >> 8;
+			print "smbd failed with status $exit!\n";
+		}
+		exit $exit;
+	}
+	print "DONE\n";
+
+	return $pid;
+}
+
+sub wait_for_start()
+{
+	# give time for nbt server to register its names
+	print "delaying for nbt name registration\n";
+	sleep(4);
+
+	# This will return quickly when things are up, but be slow if we 
+	# need to wait for (eg) SSL init 
+	system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
+	system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{SERVER}");
+	system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}");
+	system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
+	system("bin/nmblookup $ENV{CONFIGURATION} $ENV{NETBIOSNAME}");
+	system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
+}
+
+sub provision($)
+{
+	my ($prefix) = @_;
+	my %ret = ();
+	print "PROVISIONING...";
+	open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup");
+	while (<IN>) {
+		die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/);
+		$ret{$1} = $2;
+	}
+	close(IN);
+	return \%ret;
+}
+
+sub provision_ldap($$)
+{
+	my ($bindir, $setupdir) = @_;
+    system("$bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAPI}") or
+		die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAPI}");
+}
+
+1;

Added: branches/SAMBA_4_0/source/script/tests/SocketWrapper.pm
===================================================================
--- branches/SAMBA_4_0/source/script/tests/SocketWrapper.pm	2007-03-05 20:09:27 UTC (rev 21706)
+++ branches/SAMBA_4_0/source/script/tests/SocketWrapper.pm	2007-03-05 21:28:55 UTC (rev 21707)
@@ -0,0 +1,34 @@
+#!/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) = @_;
+	$ENV{SOCKET_WRAPPER_DIR} = $dir;
+	return $dir;
+}
+
+sub setup_pcap($)
+{
+	my ($pcap_file) = @_;
+
+}
+
+sub set_default_iface($)
+{
+	my ($i) = @_;
+	$ENV{SOCKET_WRAPPER_DEFAULT_IFACE} = $i;
+}
+
+1;

Modified: branches/SAMBA_4_0/source/script/tests/mk-fedora-ds.sh
===================================================================




More information about the samba-cvs mailing list