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 | |
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.
-rw-r--r-- | source4/auth/gensec/tests/bindings.py | 4 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/tests/samba3sam.py | 29 | ||||
-rwxr-xr-x | source4/lib/ldb/tests/python/dsdb_schema_info.py | 4 | ||||
-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 | ||||
-rwxr-xr-x | source4/selftest/tests.sh | 16 |
9 files changed, 47 insertions, 43 deletions
diff --git a/source4/auth/gensec/tests/bindings.py b/source4/auth/gensec/tests/bindings.py index f88fa82ae1..b9d80e4f9e 100644 --- a/source4/auth/gensec/tests/bindings.py +++ b/source4/auth/gensec/tests/bindings.py @@ -25,14 +25,14 @@ the functionality, that's already done in other tests. import unittest from samba import gensec -from samba.tests import cmdline_loadparm +from samba.tests import env_loadparm class CredentialsTests(unittest.TestCase): def setUp(self): settings = {} settings["target_hostname"] = "localhost" - settings["lp_ctx"] = cmdline_loadparm + settings["lp_ctx"] = env_loadparm() self.gensec = gensec.Security.start_client(settings) def test_info(self): diff --git a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py index cc1a86ed4a..aa428d19e7 100644 --- a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py +++ b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py @@ -24,13 +24,12 @@ import os import ldb -from ldb import SCOPE_DEFAULT, SCOPE_BASE, SCOPE_SUBTREE +from ldb import SCOPE_DEFAULT, SCOPE_BASE from samba import Ldb, substitute_var -from samba.tests import LdbTestCase, TestCaseInTempDir, cmdline_loadparm +from samba.tests import TestCaseInTempDir, env_loadparm import samba.dcerpc.security import samba.ndr from samba.auth import system_session -from samba import param datadir = os.path.join(os.path.dirname(__file__), "../../../../../testdata/samba3") @@ -60,9 +59,10 @@ class MapBaseTestCase(TestCaseInTempDir): "modules": "*:"}) def setUp(self): - cmdline_loadparm.set("sid generator", "backend") - cmdline_loadparm.set("workgroup", "TESTS") - cmdline_loadparm.set("netbios name", "TESTS") + self.lp = env_loadparm() + self.lp.set("sid generator", "backend") + self.lp.set("workgroup", "TESTS") + self.lp.set("netbios name", "TESTS") super(MapBaseTestCase, self).setUp() def make_dn(basedn, rdn): @@ -79,8 +79,9 @@ class MapBaseTestCase(TestCaseInTempDir): class Target: """Simple helper class that contains data for a specific SAM connection.""" - def __init__(self, basedn, dn): - self.db = Ldb(lp=cmdline_loadparm, session_info=system_session()) + + def __init__(self, basedn, dn, lp): + self.db = Ldb(lp=lp, session_info=system_session()) self.basedn = basedn self.basedn_casefold = ldb.Dn(self.db, basedn).get_casefold() self.substvars = {"BASEDN": self.basedn} @@ -106,8 +107,8 @@ class MapBaseTestCase(TestCaseInTempDir): def modify_ldif(self, ldif): self.db.modify_ldif(self.subst(ldif)) - self.samba4 = Target("dc=vernstok,dc=nl", make_s4dn) - self.samba3 = Target("cn=Samba3Sam", make_dn) + self.samba4 = Target("dc=vernstok,dc=nl", make_s4dn, self.lp) + self.samba3 = Target("cn=Samba3Sam", make_dn, self.lp) self.samba3.connect() self.samba4.connect() @@ -129,13 +130,13 @@ class Samba3SamTestCase(MapBaseTestCase): def setUp(self): super(Samba3SamTestCase, self).setUp() - ldb = Ldb(self.ldburl, lp=cmdline_loadparm, session_info=system_session()) + ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session()) self.samba3.setup_data("samba3.ldif") ldif = read_datafile("provision_samba3sam.ldif") ldb.add_ldif(self.samba4.subst(ldif)) self.setup_modules(ldb, self.samba3, self.samba4) del ldb - self.ldb = Ldb(self.ldburl, lp=cmdline_loadparm, session_info=system_session()) + self.ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session()) def test_search_non_mapped(self): """Looking up by non-mapped attribute""" @@ -296,12 +297,12 @@ class MapTestCase(MapBaseTestCase): def setUp(self): super(MapTestCase, self).setUp() - ldb = Ldb(self.ldburl, lp=cmdline_loadparm, session_info=system_session()) + ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session()) ldif = read_datafile("provision_samba3sam.ldif") ldb.add_ldif(self.samba4.subst(ldif)) self.setup_modules(ldb, self.samba3, self.samba4) del ldb - self.ldb = Ldb(self.ldburl, lp=cmdline_loadparm, session_info=system_session()) + self.ldb = Ldb(self.ldburl, lp=self.lp, session_info=system_session()) def test_map_search(self): """Running search tests on mapped data.""" diff --git a/source4/lib/ldb/tests/python/dsdb_schema_info.py b/source4/lib/ldb/tests/python/dsdb_schema_info.py index f0c8c14d6d..976d67024a 100755 --- a/source4/lib/ldb/tests/python/dsdb_schema_info.py +++ b/source4/lib/ldb/tests/python/dsdb_schema_info.py @@ -198,7 +198,7 @@ systemOnly: FALSE ######################################################################################## if not "DC_SERVER" in os.environ.keys(): - raise AssertionError, "Please supply TARGET_DC in environment" + raise AssertionError("Please supply TARGET_DC in environment") ldb_url = os.environ["DC_SERVER"] ldb_options = [] @@ -211,7 +211,7 @@ if not "://" in ldb_url: ldb_options = ["modules:paged_searches"] ldb = Ldb(url=ldb_url, - lp=samba.tests.cmdline_loadparm, + lp=samba.tests.env_loadparm(), session_info=system_session(), credentials=samba.tests.cmdline_credentials, options=ldb_options) 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")) diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index 769e1695d4..2480b6006a 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -490,20 +490,20 @@ plantestsuite "samba3sam.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/dsdb plantestsuite "subunit.python" none $SUBUNITRUN subunit plantestsuite "rpcecho.python" dc:local $SUBUNITRUN samba.tests.dcerpc.rpcecho plantestsuite "winreg.python" dc:local $SUBUNITRUN -U\$USERNAME%\$PASSWORD samba.tests.dcerpc.registry -plantestsuite "ldap.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN plantestsuite "schemaInfo.python" dc PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/ldb/tests/python/" $SUBUNITRUN dsdb_schema_info -U"\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD" plantestsuite "urgent_replication.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/urgent_replication.py \$PREFIX_ABS/dc/private/sam.ldb -plantestsuite "ldap_schema.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap_schema.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantestsuite "ldap.possibleInferiors.python" dc $PYTHON $samba4srcdir/dsdb/samdb/ldb_modules/tests/possibleinferiors.py $CONFIGURATION ldap://\$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantestsuite "ldap.secdesc.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/sec_descriptor.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantestsuite "ldap.acl.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/acl.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN -plantestsuite "ldap.passwords.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/passwords.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap_schema.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap_schema.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap.possibleInferiors.python" dc $PYTHON $samba4srcdir/dsdb/samdb/ldb_modules/tests/possibleinferiors.py ldap://\$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap.secdesc.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/sec_descriptor.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap.acl.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/acl.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "ldap.passwords.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/passwords.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN plantestsuite "xattr.python" none $SUBUNITRUN samba.tests.xattr plantestsuite "ntacls.python" none $SUBUNITRUN samba.tests.ntacls -plantestsuite "deletetest.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/deletetest.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN +plantestsuite "deletetest.python" dc PYTHONPATH="$PYTHONPATH:../lib/subunit/python:../lib/testtools" $PYTHON $samba4srcdir/lib/ldb/tests/python/deletetest.py \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN plantestsuite "blackbox.samba3dump" none $PYTHON $samba4srcdir/scripting/bin/samba3dump $samba4srcdir/../testdata/samba3 rm -rf $PREFIX/upgrade -plantestsuite "blackbox.upgrade" none $PYTHON $samba4srcdir/setup/upgrade_from_s3 $CONFIGURATION --targetdir=$PREFIX/upgrade $samba4srcdir/../testdata/samba3 ../testdata/samba3/smb.conf +plantestsuite "blackbox.upgrade" none $PYTHON $samba4srcdir/setup/upgrade_from_s3 --targetdir=$PREFIX/upgrade $samba4srcdir/../testdata/samba3 ../testdata/samba3/smb.conf rm -rf $PREFIX/provision mkdir $PREFIX/provision plantestsuite "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" |