[SCM] Samba Shared Repository - branch master updated
Jelmer Vernooij
jelmer at samba.org
Sun Mar 4 11:39:03 MST 2012
The branch, master has been updated
via c9d3807 selftest.py: Use testtools TestCase class.
via 82af4a7 selftest.py: Add dummy init file (required to run tests).
via e7d6d67 selftest.pl: Remove unused --verbose option.
via 01ba5cf selftest.py: Remove unused --verbose option.
via 8ae7615 selftest.py: Remove unused code, reconcile signal handlers.
via b5d9cd1 selftest.py: Fix handling of boolean options.
via aaa7cf6 selftest.py: Fix signal handling.
via 570dbf2 Run selftest.py tests.
via 7e5d98c selftest: Now runs again for tests that use environment 'none'.
via 3a6e4cf selftest.target: Add NoneTarget.
via cd9cf47 selftest.py: Finish conversion to python - now loads without syntax errors.
via 11c7ce3 selftest.testlist: Add RestrictedTestManager.from_path.
via 48155d1 selftest: More work on conversion to Python.
via d400619 selftest.testlist: Add docstrings.
via a50def8 selftest.testlist: Add manager for restricted test lists.
via 616139c Add TestListFilter definition.
via 4802561 selftest.testlist: Add read_testlist.
via 7a614ac selftest.testlist: Add read_test_regexes.
via 8b583dc selftest: Add testlist management module.
via 4d602fb selftest.target: Add Environment.get_vars.
via 646f6b2 selftest: Add tests for trying to reuse an environment that has gone down.
via 7060d68 selftest: Add tests for NoneEnvironment.
via aa7fa63 selftest.target: Test that environments are reused.
via 75eb57c selftest.target: Add tests for get_running_env.
via 0d50c4c selftest.target: Add tests for getlog_env.
via e7633d8 selftest.target: Add tests for check.
via c57ab7b selftest.target: Add tests for setup.
via 5f74fa3 selftest: Add base classes for Target/Environment and their management.
via 164d3f6 selftest.socket_wrapper: interface is an integer.
via 0cfb8e0 selftest.socket_wrapper: Add basic unit tests.
via adbd55e selftest.socket_wrapper: Add docstrings.
via 1d71ca9 Add test infrastructure for selftest.
via a6056e0 selftest: Add python version of socket wrapper utilities.
via fc7f494 selftest: Add selftest.py.
via 122374e kcc: Improve formatting of Python code to be more consistent with our other code.
from 4a8dfa4 libcli:smb: define SMB2_HDR_FLAG_REPLAY_OPERATION
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c9d380702cb8d1b2d393d7c369ec27adf4bb1060
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 18:00:54 2012 +0100
selftest.py: Use testtools TestCase class.
Autobuild-User: Jelmer Vernooij <jelmer at samba.org>
Autobuild-Date: Sun Mar 4 19:38:25 CET 2012 on sn-devel-104
commit 82af4a79b9c86c5c055158ab629a243e41c53249
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:53:59 2012 +0100
selftest.py: Add dummy init file (required to run tests).
commit e7d6d67bee048109105b0ab0d865d7746934c332
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:50:28 2012 +0100
selftest.pl: Remove unused --verbose option.
commit 01ba5cf689d1aea8fd19ac809767319cd0c1d401
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:50:21 2012 +0100
selftest.py: Remove unused --verbose option.
commit 8ae7615cf36b449fae39790d43c66f3cdf39f876
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:49:30 2012 +0100
selftest.py: Remove unused code, reconcile signal handlers.
commit b5d9cd1740dfcd766e5c62c35acfc56265dd7f6a
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:39:43 2012 +0100
selftest.py: Fix handling of boolean options.
commit aaa7cf67abe2d11b2a7de98964f25f17ce172705
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:32:56 2012 +0100
selftest.py: Fix signal handling.
commit 570dbf2ee0864c963c27108b4527fabe2f1b31d3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:30:26 2012 +0100
Run selftest.py tests.
commit 7e5d98c22cfe9107209176a9124e23ab16d80857
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:22:34 2012 +0100
selftest: Now runs again for tests that use environment 'none'.
commit 3a6e4cf2b1a88f3ab6631e75ca2e1be5273b2f8f
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 16:01:18 2012 +0100
selftest.target: Add NoneTarget.
commit cd9cf4797204f307defda7482360580558c5ee44
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 15:11:36 2012 +0100
selftest.py: Finish conversion to python - now loads without syntax errors.
commit 11c7ce35c0d3d645e26177351776d599083dfd9a
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 14:55:39 2012 +0100
selftest.testlist: Add RestrictedTestManager.from_path.
commit 48155d189aaf2ac8d4ddabf909fcae44e9321e13
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 05:00:55 2012 +0100
selftest: More work on conversion to Python.
commit d400619deec2bae2c9b394c72c20edfd46e4d197
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 04:19:26 2012 +0100
selftest.testlist: Add docstrings.
commit a50def839c9ead7f05ea90c093a64794f79ed243
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 04:16:16 2012 +0100
selftest.testlist: Add manager for restricted test lists.
commit 616139c01e03799f2cb047f78c60d3afc004d15e
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 04:01:28 2012 +0100
Add TestListFilter definition.
commit 4802561d690e63213cc2274a4b72ed278908bf97
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 03:24:10 2012 +0100
selftest.testlist: Add read_testlist.
commit 7a614ac7104cc59f6af70de1b0ba3eee472c3c21
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 03:12:35 2012 +0100
selftest.testlist: Add read_test_regexes.
commit 8b583dc64cc0510b4b8d64086ea72b2502249350
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 03:02:53 2012 +0100
selftest: Add testlist management module.
commit 4d602fb05dfc7d747f3aff90d9482313999a7092
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:38:15 2012 +0100
selftest.target: Add Environment.get_vars.
commit 646f6b2697147ebabe5ee985b13964d5e3f33ae1
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:37:42 2012 +0100
selftest: Add tests for trying to reuse an environment that has gone down.
commit 7060d68015b102fe3109683b387bd2218d9473d8
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:36:28 2012 +0100
selftest: Add tests for NoneEnvironment.
commit aa7fa63bfaf0757ac4ff4112825333fb4524ce95
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:32:26 2012 +0100
selftest.target: Test that environments are reused.
commit 75eb57cff5f041c3eea067a35647520481cd1516
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:31:32 2012 +0100
selftest.target: Add tests for get_running_env.
commit 0d50c4cf3c4bc8ca406cad4f6c30c0326ee19bad
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:30:42 2012 +0100
selftest.target: Add tests for getlog_env.
commit e7633d86c03c57b6fc8a4e5b4a26f7e9159c6ec7
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:29:34 2012 +0100
selftest.target: Add tests for check.
commit c57ab7ba9d7e25ac18d1e9883d3fc86a688fa7be
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:28:06 2012 +0100
selftest.target: Add tests for setup.
commit 5f74fa3511f0a545b63db142741320fc38126646
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:18:27 2012 +0100
selftest: Add base classes for Target/Environment and their management.
commit 164d3f66416932cbf70eba34559b6a854a213ff1
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 02:17:52 2012 +0100
selftest.socket_wrapper: interface is an integer.
commit 0cfb8e033c334f7685a6f566b0153b4e435a229d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:36:16 2012 +0100
selftest.socket_wrapper: Add basic unit tests.
commit adbd55ea5580d5a6a44269f26f7eb6481a40532d
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:36:01 2012 +0100
selftest.socket_wrapper: Add docstrings.
commit 1d71ca98b7d7ace2c8b27566b3e7d332dbd1cbdc
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:31:44 2012 +0100
Add test infrastructure for selftest.
commit a6056e07e087dd3ea614054129baa3dcc0f13fce
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:30:58 2012 +0100
selftest: Add python version of socket wrapper utilities.
commit fc7f49420bb6d1c8865c5c2b673119f23dd021f3
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:24:10 2012 +0100
selftest: Add selftest.py.
commit 122374e9996a62f6d7d9769495e058f67850a92a
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Sun Mar 4 01:05:23 2012 +0100
kcc: Improve formatting of Python code to be more consistent with our other code.
-----------------------------------------------------------------------
Summary of changes:
{buildtools/wafsamba => selftest}/__init__.py | 0
selftest/selftest.pl | 8 -
selftest/selftest.py | 651 +++++++++++++++++++++++++
selftest/socket_wrapper.py | 61 +++
selftest/target/__init__.py | 165 +++++++
selftest/testlist.py | 135 +++++
selftest/tests/__init__.py | 32 ++
selftest/tests/test_socket_wrapper.py | 36 ++
selftest/tests/test_target.py | 129 +++++
selftest/tests/test_testlist.py | 102 ++++
source4/scripting/bin/samba_kcc | 350 ++++++--------
source4/scripting/python/samba/kcc_utils.py | 150 +++----
source4/selftest/tests.py | 1 +
13 files changed, 1536 insertions(+), 284 deletions(-)
copy {buildtools/wafsamba => selftest}/__init__.py (100%)
create mode 100755 selftest/selftest.py
create mode 100644 selftest/socket_wrapper.py
create mode 100644 selftest/target/__init__.py
create mode 100644 selftest/testlist.py
create mode 100644 selftest/tests/__init__.py
create mode 100644 selftest/tests/test_socket_wrapper.py
create mode 100644 selftest/tests/test_target.py
create mode 100644 selftest/tests/test_testlist.py
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/__init__.py b/selftest/__init__.py
similarity index 100%
copy from buildtools/wafsamba/__init__.py
copy to selftest/__init__.py
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index 7328300..cdcd2e4 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -45,7 +45,6 @@ my $opt_socket_wrapper_keep_pcap = undef;
my $opt_one = 0;
my @opt_exclude = ();
my @opt_include = ();
-my $opt_verbose = 0;
my $opt_testenv = 0;
my $opt_list = 0;
my $ldap = undef;
@@ -213,7 +212,6 @@ Samba4 Specific:
Behaviour:
--quick run quick overall test
--one abort when the first test fails
- --verbose be verbose
--testenv run a shell in the requested test environment
--list list available tests
";
@@ -233,7 +231,6 @@ my $result = GetOptions (
'include=s' => \@opt_include,
'srcdir=s' => \$srcdir,
'bindir=s' => \$bindir,
- 'verbose' => \$opt_verbose,
'testenv' => \$opt_testenv,
'list' => \$opt_list,
'ldap:s' => \$ldap,
@@ -563,11 +560,6 @@ if ($opt_socket_wrapper) {
} else {
$ENV{SELFTEST_INTERFACES} = "";
}
-if ($opt_verbose) {
- $ENV{SELFTEST_VERBOSE} = "1";
-} else {
- $ENV{SELFTEST_VERBOSE} = "";
-}
if ($opt_quick) {
$ENV{SELFTEST_QUICK} = "1";
} else {
diff --git a/selftest/selftest.py b/selftest/selftest.py
new file mode 100755
index 0000000..e619515
--- /dev/null
+++ b/selftest/selftest.py
@@ -0,0 +1,651 @@
+#!/usr/bin/python -u
+# Bootstrap Samba and run a number of tests against it.
+# Copyright (C) 2005-2012 Jelmer Vernooij <jelmer at samba.org>
+# Copyright (C) 2007-2009 Stefan Metzmacher <metze at samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import atexit
+from cStringIO import StringIO
+import datetime
+import iso8601
+import os
+import sys
+import signal
+import shutil
+import subprocess
+import subunit
+import tempfile
+import traceback
+import warnings
+
+import optparse
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
+
+from selftest import (
+ socket_wrapper,
+ subunithelper,
+ testlist,
+ )
+from selftest.target import (
+ EnvironmentManager,
+ NoneTarget,
+ UnsupportedEnvironment,
+ )
+
+includes = ()
+excludes = ()
+
+def now():
+ return datetime.datetime.utcnow().replace(tzinfo=iso8601.iso8601.Utc())
+
+def read_excludes(fn):
+ excludes.extend(testlist.read_test_regexes(fn))
+
+def read_includes(fn):
+ includes.extend(testlist.read_test_regexes(fn))
+
+parser = optparse.OptionParser("TEST-REGEXES")
+parser.add_option("--target", type="choice", choices=["samba", "samba3", "none"], default="samba", help="Samba version to target")
+parser.add_option("--quick", help="run quick overall test", action="store_true", default=False)
+parser.add_option("--list", help="list available tests", action="store_true", default=False)
+parser.add_option("--socket-wrapper", help="enable socket wrapper", action="store_true", default=False)
+parser.add_option("--socket-wrapper-pcap", help="save traffic to pcap directories", type="str")
+parser.add_option("--socket-wrapper-keep-pcap", help="keep all pcap files, not just those for tests that failed", action="store_true", default=False)
+parser.add_option("--one", help="abort when the first test fails", action="store_true", default=False)
+parser.add_option("--exclude", action="callback", help="Add file to exclude files", callback=read_excludes)
+parser.add_option("--include", action="callback", help="Add file to include files", callback=read_includes)
+parser.add_option("--testenv", help="run a shell in the requested test environment", action="store_true", default=False)
+parser.add_option("--resetup-environment", help="Re-setup environment", action="store_true", default=False)
+parser.add_option("--binary-mapping", help="Map binaries to use", type=str)
+parser.add_option("--load-list", help="Load list of tests to load from a file", type=str)
+parser.add_option("--prefix", help="prefix to run tests in", type=str, default="./st")
+parser.add_option("--srcdir", type=str, default=".", help="source directory")
+parser.add_option("--bindir", type=str, default="./bin", help="binaries directory")
+parser.add_option("--testlist", type=str, action="append", help="file to read available tests from")
+parser.add_option("--ldap", help="back samba onto specified ldap server", choices=["openldap", "fedora-ds"], type="choice")
+
+opts, args = parser.parse_args()
+
+subunit_ops = subunithelper.SubunitOps(sys.stdout)
+
+def handle_signal(sig, frame):
+ sys.stderr.write("Exiting early because of signal %s.\n" % sig)
+ sys.exit(1)
+
+for sig in (signal.SIGINT, signal.SIGQUIT, signal.SIGTERm, signal.SIGPIPE):
+ signal.signal(sig, handle_signal)
+
+def skip(name):
+ return testlist.find_in_list(excludes, name)
+
+def setup_pcap(name):
+ if (not opts.socket_wrapper_pcap or
+ not os.environ.get("SOCKET_WRAPPER_PCAP_DIR")):
+ return
+
+ fname = "".join([x for x in name if x.isalnum() or x == '-'])
+
+ pcap_file = os.path.join(
+ os.environ["SOCKET_WRAPPER_PCAP_DIR"], "%s.pcap" % fname)
+
+ socket_wrapper.setup_pcap(pcap_file)
+ return pcap_file
+
+
+def cleanup_pcap(pcap_file, exit_code):
+ if not opts.socket_wrapper_pcap:
+ return
+ if opts.socket_wrapper_keep_pcap:
+ return
+ if exitcode == 0:
+ return
+ if pcap_file is None:
+ return
+
+ os.unlink(pcap_file)
+
+
+# expand strings from %ENV
+def expand_environment_strings(s):
+ # we use a reverse sort so we do the longer ones first
+ for k in sorted(os.environ.keys(), reverse=True):
+ v = os.environ[k]
+ s = s.replace("$%s" % k, v)
+ return s
+
+
+def run_testsuite(envname, name, cmd):
+ """Run a single testsuite.
+
+ :param envname: Name of the environment to ru nin
+ :param name: Name of the testsuite
+ :param cmd: Name of the (fully expanded) command to run
+ :return: exitcode of the command
+ """
+ pcap_file = setup_pcap(name)
+
+ subunit_ops.start_testsuite(name)
+ subunit_ops.progress(None, subunit.PROGRESS_PUSH)
+ subunit_ops.time(now())
+ try:
+ exitcode = subprocess.call(cmd, shell=True)
+ except Exception, e:
+ subunit_ops.time(now())
+ subunit_ops.progress(None, subunit.PROGRESS_POP)
+ subunit_ops.end_testsuite(name, "error", "Unable to run %r: %s" % (cmd, e))
+ sys.exit(1)
+
+ subunit_ops.time(now())
+ subunit_ops.progress(None, subunit.PROGRESS_POP)
+
+ envlog = env_manager.getlog_env(envname)
+ if envlog != "":
+ sys.stdout.write("envlog: %s\n" % envlog)
+
+ sys.stdout.write("command: %s\n" % cmd)
+ sys.stdout.write("expanded command: %s\n" % expand_environment_strings(cmd))
+
+ if exitcode == 0:
+ subunit_ops.end_testsuite(name, "success")
+ else:
+ subunit_ops.end_testsuite(name, "failure", "Exit code was %d" % exitcode)
+
+ cleanup_pcap(pcap_file, exitcode)
+
+ if not opts.socket_wrapper_keep_pcap and pcap_file is not None:
+ sys.stdout.write("PCAP FILE: %s\n" % pcap_file)
+
+ if exitcode != 0 and opts.one:
+ sys.exit(1)
+
+ return exitcode
+
+if opts.list and opts.testenv:
+ sys.stderr.write("--list and --testenv are mutually exclusive\n")
+ sys.exit(1)
+
+tests = args
+
+# quick hack to disable rpc validation when using valgrind - it is way too slow
+if not os.environ.get("VALGRIND"):
+ os.environ["VALIDATE"] = "validate"
+ os.environ["MALLOC_CHECK_"] = "2"
+
+# make all our python scripts unbuffered
+os.environ["PYTHONUNBUFFERED"] = "1"
+
+bindir_abs = os.path.abspath(opts.bindir)
+
+# Backwards compatibility:
+if os.environ.get("TEST_LDAP") == "yes":
+ if os.environ.get("FEDORA_DS_ROOT"):
+ ldap = "fedora-ds"
+ else:
+ ldap = "openldap"
+
+torture_maxtime = int(os.getenv("TORTURE_MAXTIME", "1200"))
+if opts.ldap:
+ # LDAP is slow
+ torture_maxtime *= 2
+
+prefix = os.path.normpath(opts.prefix)
+
+if prefix == "":
+ raise Exception("using an empty prefix isn't allowed")
+
+# Ensure we have the test prefix around.
+#
+# We need restrictive permissions on this as some subdirectories in this tree
+# will have wider permissions (ie 0777) and this would allow other users on the
+# host to subvert the test process.
+if not os.path.isdir(prefix):
+ os.mkdir(prefix, 0700)
+else:
+ os.chmod(prefix, 0700)
+
+prefix_abs = os.path.abspath(prefix)
+tmpdir_abs = os.path.abspath(os.path.join(prefix_abs, "tmp"))
+if not os.path.isdir(tmpdir_abs):
+ os.mkdir(tmpdir_abs, 0777)
+
+srcdir_abs = os.path.abspath(opts.srcdir)
+
+if prefix_abs == "":
+ raise Exception("using an empty absolute prefix isn't allowed")
+if prefix_abs == "/":
+ raise Exception("using '/' as absolute prefix isn't allowed")
+
+os.environ["PREFIX"] = prefix
+os.environ["KRB5CCNAME"] = os.path.join(prefix, "krb5ticket")
+os.environ["PREFIX_ABS"] = prefix_abs
+os.environ["SRCDIR"] = opts.srcdir
+os.environ["SRCDIR_ABS"] = srcdir_abs
+os.environ["BINDIR"] = bindir_abs
+
+tls_enabled = not opts.quick
+if tls_enabled:
+ os.environ["TLS_ENABLED"] = "yes"
+else:
+ os.environ["TLS_ENABLED"] = "no"
+
+def prefix_pathvar(name, newpath):
+ if name in os.environ:
+ os.environ[name] = "%s:%s" % (newpath, os.environ[name])
+ else:
+ os.environ[name] = newpath
+prefix_pathvar("PKG_CONFIG_PATH", os.path.join(bindir_abs, "pkgconfig"))
+prefix_pathvar("PYTHONPATH", os.path.join(bindir_abs, "python"))
+
+if opts.socket_wrapper_keep_pcap:
+ # Socket wrapper keep pcap implies socket wrapper pcap
+ opts.socket_wrapper_pcap = True
+
+if opts.socket_wrapper_pcap:
+ # Socket wrapper pcap implies socket wrapper
+ opts.socket_wrapper = True
+
+if opts.socket_wrapper:
+ socket_wrapper_dir = socket_wrapper.setup_dir(os.path.join(prefix_abs, "w"), opts.socket_wrapper_pcap)
+ sys.stdout.write("SOCKET_WRAPPER_DIR=%s\n" % socket_wrapper_dir)
+elif not opts.list:
+ if os.getuid() != 0:
+ warnings.warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports")
+
+testenv_default = "none"
+
+if opts.binary_mapping:
+ binary_mapping = dict([l.split(":") for l in opts.binary_mapping.split(",")])
+ os.environ["BINARY_MAPPING"] = opts.binary_mapping
+else:
+ binary_mapping = {}
+ os.environ["BINARY_MAPPING"] = ""
+
+# After this many seconds, the server will self-terminate. All tests
+# must terminate in this time, and testenv will only stay alive this
+# long
+
+server_maxtime = 7500
+if os.environ.get("SMBD_MAXTIME", ""):
+ server_maxtime = int(os.environ["SMBD_MAXTIME"])
+
+
+def has_socket_wrapper(bindir):
+ """Check if Samba has been built with socket wrapper support.
+ """
+ f = StringIO()
+ subprocess.check_call([os.path.join(bindir, "smbd"), "-b"], stdout=f)
+ for l in f.readlines():
+ if "SOCKET_WRAPPER" in l:
+ return True
+ return False
+
+
+if not opts.list:
+ if opts.target == "samba":
+ if opts.socket_wrapper and not has_socket_wrapper(opts.bindir):
+ sys.stderr.write("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....\n")
+ sys.exit(1)
+ testenv_default = "dc"
+ from selftest.target.samba import Samba
+ target = Samba(opts.bindir, binary_mapping, ldap, opts.srcdir, server_maxtime)
+ elif opts.target == "samba3":
+ if opts.socket_wrapper and not has_socket_wrapper(opts.bindir):
+ sys.stderr.write("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'. Exiting....\n")
+ sys.exit(1)
+ testenv_default = "member"
+ from selftest.target.samba3 import Samba3
+ target = Samba3(opts.bindir, binary_mapping, srcdir_abs, server_maxtime)
+ elif opts.target == "none":
+ testenv_default = "none"
+ target = NoneTarget()
+
+ env_manager = EnvironmentManager(target)
+ atexit.register(env_manager.teardown_all)
+
+interfaces = ",".join([
+ "127.0.0.11/8",
+ "127.0.0.12/8",
+ "127.0.0.13/8",
+ "127.0.0.14/8",
+ "127.0.0.15/8",
+ "127.0.0.16/8"])
+
+clientdir = os.path.join(prefix_abs, "client")
+
+conffile = os.path.join(clientdir, "client.conf")
+os.environ["SMB_CONF_PATH"] = conffile
+
+def write_clientconf(conffile, clientdir, vars):
+ if not os.path.isdir(clientdir):
+ os.mkdir(clientdir, 0777)
+
+ for n in ["private", "lockdir", "statedir", "cachedir"]:
+ p = os.path.join(clientdir, n)
+ if os.path.isdir(p):
+ shutil.rmtree(p)
+ os.mkdir(p, 0777)
+
+ # this is ugly, but the ncalrpcdir needs exactly 0755
+ # otherwise tests fail.
+ mask = os.umask(0022)
+
+ for n in ["ncalrpcdir", "ncalrpcdir/np"]:
+ p = os.path.join(clientdir, n)
+ if os.path.isdir(p):
+ shutil.rmtree(p)
+ os.mkdir(p, 0777)
+ os.umask(mask)
+
+ settings = {
+ "netbios name": "client",
+ "private dir": os.path.join(clientdir, "private"),
+ "lock dir": os.path.join(clientdir, "lockdir"),
+ "state directory": os.path.join(clientdir, "statedir"),
+ "cache directory": os.path.join(clientdir, "cachedir"),
+ "ncalrpc dir": os.path.join(clientdir, "ncalrpcdir"),
+ "name resolve order": "file bcast",
+ "panic action": os.path.join(os.path.dirname(__file__), "gdb_backtrace \%d"),
+ "max xmit": "32K",
+ "notify:inotify": "false",
+ "ldb:nosync": "true",
+ "system:anonymous": "true",
+ "client lanman auth": "Yes",
+ "log level": "1",
+ "torture:basedir": clientdir,
+ # We don't want to pass our self-tests if the PAC code is wrong
+ "gensec:require_pac": "true",
+ "resolv:host file": os.path.join(prefix_abs, "dns_host_file"),
+ # We don't want to run 'speed' tests for very long
+ "torture:timelimit": "1",
+ }
+
+ if "DOMAIN" in vars:
+ settings["workgroup"] = vars["DOMAIN"]
+ if "REALM" in vars:
+ settings["realm"] = vars["REALM"]
+ if opts.socket_wrapper:
+ settings["interfaces"] = interfaces
+
+ f = open(conffile, 'w')
+ try:
+ f.write("[global]\n")
+ for item in settings.iteritems():
+ f.write("\t%s = %s\n" % item)
+ finally:
+ f.close()
+
+todo = []
+
+if not opts.testlist:
+ sys.stderr.write("No testlists specified\n")
+ sys.exit(1)
+
+os.environ["SELFTEST_PREFIX"] = prefix_abs
+os.environ["SELFTEST_TMPDIR"] = tmpdir_abs
+os.environ["TEST_DATA_PREFIX"] = tmpdir_abs
+if opts.socket_wrapper:
+ os.environ["SELFTEST_INTERFACES"] = interfaces
+else:
+ os.environ["SELFTEST_INTERFACES"] = ""
+if opts.quick:
+ os.environ["SELFTEST_QUICK"] = "1"
+else:
+ os.environ["SELFTEST_QUICK"] = ""
+os.environ["SELFTEST_MAXTIME"] = str(torture_maxtime)
+
+
+def open_file_or_pipe(path, mode):
+ if path.endswith("|"):
+ return os.popen(path[:-1], mode)
+ return open(path, mode)
+
+available = []
+for fn in opts.testlist:
+ inf = open_file_or_pipe(fn, 'r')
+ try:
+ for testsuite in testlist.read_testlist(inf, sys.stdout):
+ if not testlist.should_run_test(tests, testsuite):
+ continue
+ name = testsuite[0]
+ if includes is not None and testlist.find_in_list(includes, name) is not None:
+ continue
+ available.append(testsuite)
+ finally:
+ inf.close()
+
+if opts.load_list:
+ restricted_mgr = testlist.RestrictedTestManager.from_path(opts.load_list)
+else:
+ restricted_mgr = None
+
+
+for testsuite in available:
+ name = testsuite[0]
+ skipreason = skip(name)
+ if restricted_mgr is not None:
+ match = restricted_mgr.should_run_testsuite(name)
+ if match == []:
+ continue
+ else:
+ match = None
+ if skipreason is not None:
+ if not opts.list:
+ subunit_ops.skip_testsuite(name, skipreason)
+ else:
+ todo.append(testsuite + (match,))
+
+if restricted_mgr is not None:
--
Samba Shared Repository
More information about the samba-cvs
mailing list