Rev 11686: Generalize handling of environments a bit. in
file:///home/jelmer/bzr.samba/4.0-envs/
Jelmer Vernooij
jelmer at samba.org
Wed Mar 7 00:28:40 GMT 2007
At file:///home/jelmer/bzr.samba/4.0-envs/
------------------------------------------------------------
revno: 11686
revision-id: jelmer at samba.org-20070307002826-696vbm9xbicktxhh
parent: jelmer at samba.org-20070306232050-g5jm91tqennsw1a5
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 4.0-envs
timestamp: Wed 2007-03-07 01:28:26 +0100
message:
Generalize handling of environments a bit.
added:
source/script/tests/TODO todo-20070306235556-368tkklzig1g0c99-1
source/script/tests/Windows.pm windows.pm-20070307001935-dmbansbt3gpgi44l-1
renamed:
source/script/tests/mktestsetup.sh => source/script/tests/mktestdc.sh svn-v2:16522 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2fmktestsetup.sh
source/script/tests/mktestsetup.sh.share_ldb => source/script/tests/mktestdc.sh.share_ldb svn-v2:17208 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2fmktestsetup.sh.share_ldb
modified:
source/script/tests/Samba4.pm svn-v2:21707 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2fSamba4.pm
source/script/tests/selftest.pl svn-v2:20693 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2fselftest.pl
source/script/tests/test_ejs.sh svn-v2:8269 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscript%2ftests%2ftest_ejs.sh
=== added file 'source/script/tests/TODO'
--- a/source/script/tests/TODO 1970-01-01 00:00:00 +0000
+++ b/source/script/tests/TODO 2007-03-07 00:28:26 +0000
@@ -0,0 +1,5 @@
+- warn about unexpected successes
+- support for environments
+- better way to detect that smbd has finished initialization
+- allow tests to specify what parameters they need
+ - UNC / DCERPC binding strings
=== added file 'source/script/tests/Windows.pm'
--- a/source/script/tests/Windows.pm 1970-01-01 00:00:00 +0000
+++ b/source/script/tests/Windows.pm 2007-03-07 00:28:26 +0000
@@ -0,0 +1,27 @@
+#!/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 Windows;
+
+use strict;
+use FindBin qw($RealBin);
+use POSIX;
+
+sub provision($$)
+{
+ my ($self, $prefix) = @_;
+
+ die ("Windows tests will not run without root privileges.")
+ if (`whoami` ne "root");
+
+ die("Environment variable WINTESTCONF has not been defined.\n".
+ "Windows tests will not run unconfigured.") if (not defined($ENV{WINTESTCONF}));
+
+ die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF});
+
+ $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win";
+}
+
+1;
=== renamed file 'source/script/tests/mktestsetup.sh' => 'source/script/tests/mktestdc.sh'
=== renamed file 'source/script/tests/mktestsetup.sh.share_ldb' => 'source/script/tests/mktestdc.sh.share_ldb'
=== modified file 'source/script/tests/Samba4.pm'
--- a/source/script/tests/Samba4.pm 2007-03-06 06:30:36 +0000
+++ b/source/script/tests/Samba4.pm 2007-03-07 00:28:26 +0000
@@ -13,6 +13,10 @@
use FindBin qw($RealBin);
use POSIX;
+sub new {
+ bless {};
+}
+
sub slapd_start($$)
{
my ($conf, $uri) = @_;
@@ -41,9 +45,9 @@
}
}
-sub smbd_check_or_start($$$$$$)
+sub smbd_check_or_start($$$$$$$)
{
- my ($bindir, $test_fifo, $test_log, $socket_wrapper_dir, $max_time, $conffile) = @_;
+ my ($self, $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
@@ -99,7 +103,7 @@
return $pid;
}
-sub wait_for_start()
+sub wait_for_start($)
{
# give time for nbt server to register its names
print "delaying for nbt name registration\n";
@@ -115,12 +119,12 @@
system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}");
}
-sub provision($)
+sub provision($$)
{
- my ($prefix) = @_;
+ my ($self, $prefix) = @_;
my %ret = ();
print "PROVISIONING...";
- open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup");
+ open(IN, "$RealBin/mktestdc.sh $prefix|") or die("Unable to setup");
while (<IN>) {
die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/);
$ret{$1} = $2;
@@ -136,4 +140,9 @@
die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAP_URI}");
}
+sub stop($)
+{
+ my ($self) = @_;
+}
+
1;
=== modified file 'source/script/tests/selftest.pl'
--- a/source/script/tests/selftest.pl 2007-03-06 06:30:36 +0000
+++ b/source/script/tests/selftest.pl 2007-03-07 00:28:26 +0000
@@ -375,30 +375,21 @@
my @torture_options = ();
-my $testenv_vars = {};
+die("Windows tests will not run with socket wrapper enabled.")
+ if ($opt_socket_wrapper and $opt_target eq "win");
+
+my $target;
if ($opt_target eq "samba4") {
- $testenv_vars = Samba4::provision($prefix);
+ $target = new Samba4();
} elsif ($opt_target eq "win") {
- die ("Windows tests will not run without root privileges.")
- if (`whoami` ne "root");
-
- die("Windows tests will not run with socket wrapper enabled.")
- if ($opt_socket_wrapper);
-
- die("Windows tests will not run quickly.") if ($opt_quick);
-
- die("Environment variable WINTESTCONF has not been defined.\n".
- "Windows tests will not run unconfigured.") if (not defined($ENV{WINTESTCONF}));
-
- die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF});
-
- $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win";
-} elsif ($opt_target eq "none") {
-} else {
- die("unknown target `$opt_target'");
+ $target = new Windows();
}
+my $testenv_vars;
+
+$testenv_vars = $target->provision("$prefix/dc");
+
foreach (keys %$testenv_vars) { $ENV{$_} = $testenv_vars->{$_}; }
if ($opt_socket_wrapper_pcap) {
@@ -443,9 +434,8 @@
close(SKIP);
}
-my $test_fifo = "$prefix/smbd_test.fifo";
-$ENV{SMBD_TEST_FIFO} = $test_fifo;
+$ENV{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo";
$ENV{SMBD_TEST_LOG} = "$prefix/smbd_test.log";
SocketWrapper::set_default_iface(1);
@@ -453,7 +443,7 @@
if (defined($ENV{SMBD_MAX_TIME})) {
$max_time = $ENV{SMBD_MAX_TIME};
}
-Samba4::smbd_check_or_start($bindir, $test_fifo, $ENV{SMBD_TEST_LOG},
+$target->smbd_check_or_start($bindir, $ENV{SMBD_TEST_FIFO}, $ENV{SMBD_TEST_LOG},
$socket_wrapper_dir, $max_time, $ENV{CONFFILE});
SocketWrapper::set_default_iface(6);
@@ -477,34 +467,30 @@
$ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
print "OPTIONS $ENV{TORTURE_OPTIONS}\n";
-open(DATA, ">$test_fifo");
+open(DATA, ">$ENV{SMBD_TEST_FIFO}");
my @todo = ();
-if ($opt_target eq "win") {
- system("$testsdir/test_win.sh");
-} else {
- if ($opt_quick) {
- open(IN, "$testsdir/tests_quick.sh|");
+if ($opt_quick) {
+ open(IN, "$testsdir/tests_quick.sh|");
+} else {
+ open(IN, "$testsdir/tests_all.sh|");
+}
+while (<IN>) {
+ if ($_ eq "-- TEST --\n") {
+ my $name = <IN>;
+ $name =~ s/\n//g;
+ my $cmdline = <IN>;
+ $cmdline =~ s/\n//g;
+ push (@todo, [$name, $cmdline])
+ if (not defined($tests) or $name =~ /$tests/);
} else {
- open(IN, "$testsdir/tests_all.sh|");
- }
- while (<IN>) {
- if ($_ eq "-- TEST --\n") {
- my $name = <IN>;
- $name =~ s/\n//g;
- my $cmdline = <IN>;
- $cmdline =~ s/\n//g;
- push (@todo, [$name, $cmdline])
- if (not defined($tests) or $name =~ /$tests/);
- } else {
- print;
- }
- }
- close(IN) or die("Error creating recipe");
+ print;
+ }
}
+close(IN) or die("Error creating recipe");
-Samba4::wait_for_start();
+$target->wait_for_start();
# start off with 0 failures
$ENV{failed} = 0;
@@ -536,6 +522,8 @@
print "\n";
+$target->stop();
+
close(DATA);
sleep(2);
=== modified file 'source/script/tests/test_ejs.sh'
--- a/source/script/tests/test_ejs.sh 2007-03-05 21:28:55 +0000
+++ b/source/script/tests/test_ejs.sh 2007-03-07 00:28:26 +0000
@@ -23,11 +23,11 @@
PATH=bin:$PATH
export PATH
-testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION
+testit "base.js" "$SCRIPTDIR/base.js" $CONFIGURATION
testit "samr.js" "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD
testit "echo.js" "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD
-testit "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser
-testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION
+testit "ejsnet.js" "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser
+testit "ldb.js" "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION
testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD
More information about the samba-cvs
mailing list