diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-06-13 16:38:24 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-06-13 18:19:03 +0200 |
commit | 51058213cb183bcb127f5bb275cbb781efc55e35 (patch) | |
tree | cdf9394eaba7e5ab2e784cd18518770469f99075 /source4/scripting | |
parent | 46037a816091506c4c89df6141d57b281728b395 (diff) | |
download | samba-51058213cb183bcb127f5bb275cbb781efc55e35.tar.gz samba-51058213cb183bcb127f5bb275cbb781efc55e35.tar.bz2 samba-51058213cb183bcb127f5bb275cbb781efc55e35.zip |
s4-test: Use smb.conf path set in environment rather than using
command-line options.
This is the first step towards supporting custom test runners.
Diffstat (limited to 'source4/scripting')
-rwxr-xr-x | source4/scripting/bin/subunitrun | 5 | ||||
-rw-r--r-- | source4/scripting/python/samba/ntacls.py | 2 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/__init__.py | 13 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/dcerpc/bare.py | 12 | ||||
-rw-r--r-- | source4/scripting/python/samba/tests/provision.py | 5 |
5 files changed, 20 insertions, 17 deletions
diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun index 35145b973c..a6337e505b 100755 --- a/source4/scripting/bin/subunitrun +++ b/source4/scripting/bin/subunitrun @@ -35,13 +35,10 @@ from subunit.run import SubunitTestRunner parser = optparse.OptionParser("subunitrun [options] <tests>") credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) -sambaopts = options.SambaOptions(parser) -parser.add_option_group(sambaopts) args = parser.parse_args()[1] -samba.tests.cmdline_loadparm = sambaopts.get_loadparm() -samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.cmdline_loadparm) +samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.env_loadparm()) runner = SubunitTestRunner() program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner) diff --git a/source4/scripting/python/samba/ntacls.py b/source4/scripting/python/samba/ntacls.py index cfdb2621c4..bbb792521e 100644 --- a/source4/scripting/python/samba/ntacls.py +++ b/source4/scripting/python/samba/ntacls.py @@ -32,7 +32,7 @@ def checkset_backend(lp, backend, eadbfile): if backend == "native": lp.set("posix:eadb", "") elif backend == "tdb": - if eadbfile != None: + if eadbfile is not None: lp.set("posix:eadb", eadbfile) else: os.path.abspath(os.path.join(lp.get("private dir"), "eadb.tdb")) diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py index ae7a707e35..a5459f44b5 100644 --- a/source4/scripting/python/samba/tests/__init__.py +++ b/source4/scripting/python/samba/tests/__init__.py @@ -22,6 +22,7 @@ import os import ldb import samba +from samba import param import tempfile import unittest @@ -90,14 +91,20 @@ class LdbExtensionTests(TestCaseInTempDir): os.unlink(path) -cmdline_loadparm = None +def env_loadparm(): + lp = param.LoadParm() + try: + lp.load(os.environ["SMB_CONF_PATH"]) + except KeyError: + raise Exception("SMB_CONF_PATH not set") + return lp + cmdline_credentials = None class RpcInterfaceTestCase(unittest.TestCase): def get_loadparm(self): - assert cmdline_loadparm is not None - return cmdline_loadparm + return env_loadparm() def get_credentials(self): return cmdline_credentials diff --git a/source4/scripting/python/samba/tests/dcerpc/bare.py b/source4/scripting/python/samba/tests/dcerpc/bare.py index 6cadad89f1..e6811b0a3d 100644 --- a/source4/scripting/python/samba/tests/dcerpc/bare.py +++ b/source4/scripting/python/samba/tests/dcerpc/bare.py @@ -20,7 +20,7 @@ from samba.dcerpc import ClientConnection from unittest import TestCase -from samba.tests import cmdline_loadparm +from samba.tests import env_loadparm class BareTestCase(TestCase): @@ -28,22 +28,22 @@ class BareTestCase(TestCase): def test_bare(self): # Connect to the echo pipe x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=cmdline_loadparm) + ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm()) self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4)) def test_alter_context(self): x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=cmdline_loadparm) + ("12345778-1234-abcd-ef00-0123456789ac", 1), lp_ctx=env_loadparm()) y = ClientConnection("ncalrpc:localhost", ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - basis_connection=x, lp_ctx=cmdline_loadparm) + basis_connection=x, lp_ctx=env_loadparm()) x.alter_context(("60a15ec5-4de8-11d7-a637-005056a20182", 1)) # FIXME: self.assertEquals("\x01\x00\x00\x00", x.request(0, chr(0) * 4)) def test_two_connections(self): x = ClientConnection("ncalrpc:localhost[DEFAULT]", - ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=cmdline_loadparm) + ("60a15ec5-4de8-11d7-a637-005056a20182", 1), lp_ctx=env_loadparm()) y = ClientConnection("ncalrpc:localhost", ("60a15ec5-4de8-11d7-a637-005056a20182", 1), - basis_connection=x, lp_ctx=cmdline_loadparm) + basis_connection=x, lp_ctx=env_loadparm()) self.assertEquals("\x01\x00\x00\x00", y.request(0, chr(0) * 4)) diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py index 45c237f373..22e4553f02 100644 --- a/source4/scripting/python/samba/tests/provision.py +++ b/source4/scripting/python/samba/tests/provision.py @@ -20,10 +20,9 @@ import os from samba.provision import setup_secretsdb, findnss import samba.tests +from samba.tests import env_loadparm import unittest -lp = samba.tests.cmdline_loadparm - setup_dir = "setup" def setup_path(file): return os.path.join(setup_dir, file) @@ -34,7 +33,7 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir): """ def test_setup_secretsdb(self): path = os.path.join(self.tempdir, "secrets.ldb") - ldb = setup_secretsdb(path, setup_path, None, None, lp=lp) + ldb = setup_secretsdb(path, setup_path, None, None, lp=env_loadparm()) try: self.assertEquals("LSA Secrets", ldb.searchone(basedn="CN=LSA Secrets", attribute="CN")) |