1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-24 04:23:53 +03:00

python: make source_tree_topdir() test-only

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Douglas Bagnall
2025-03-19 12:04:26 +13:00
committed by Ralph Boehme
parent 38d113a4d3
commit 24fb3bb874
5 changed files with 15 additions and 14 deletions

View File

@@ -31,16 +31,6 @@ from samba import _glue
from samba._ldb import Ldb as _Ldb from samba._ldb import Ldb as _Ldb
def source_tree_topdir():
"""Return the top level source directory."""
paths = ["../../..", "../../../.."]
for p in paths:
topdir = os.path.normpath(os.path.join(os.path.dirname(__file__), p))
if os.path.exists(os.path.join(topdir, 'source4')):
return topdir
raise RuntimeError("unable to find top level source directory")
class Ldb(_Ldb): class Ldb(_Ldb):
"""Simple Samba-specific LDB subclass that takes care """Simple Samba-specific LDB subclass that takes care
of setting up the modules dir, credentials pointers, etc. of setting up the modules dir, credentials pointers, etc.

View File

@@ -65,6 +65,16 @@ LDB_ERR_LUT = {v: k for k, v in vars(ldb).items() if k.startswith('ERR_')}
RE_CAMELCASE = re.compile(r"([_\-])+") RE_CAMELCASE = re.compile(r"([_\-])+")
def source_tree_topdir():
"""Return the top level source directory."""
paths = ["../../..", "../../../.."]
for p in paths:
topdir = os.path.normpath(os.path.join(os.path.dirname(__file__), p))
if os.path.exists(os.path.join(topdir, 'source4')):
return topdir
raise RuntimeError("unable to find top level source directory")
def ldb_err(v): def ldb_err(v):
if isinstance(v, ldb.LdbError): if isinstance(v, ldb.LdbError):
v = v.args[0] v = v.args[0]

View File

@@ -24,7 +24,7 @@ import time
import errno import errno
import samba.ndr as ndr import samba.ndr as ndr
from samba import credentials from samba import credentials
from samba.tests import TestCase from samba.tests import TestCase, source_tree_topdir
from samba.dcerpc import dns from samba.dcerpc import dns
from samba.tests.subunitrun import SubunitOptions, TestProgram from samba.tests.subunitrun import SubunitOptions, TestProgram
import samba.getopt as options import samba.getopt as options
@@ -170,7 +170,7 @@ class TestDnsForwarding(DNSTest):
def start_toy_server(self, host, port, id): def start_toy_server(self, host, port, id):
python = sys.executable python = sys.executable
p = subprocess.Popen([python, p = subprocess.Popen([python,
os.path.join(samba.source_tree_topdir(), os.path.join(source_tree_topdir(),
'python/samba/tests/' 'python/samba/tests/'
'dns_forwarder_helpers/server.py'), 'dns_forwarder_helpers/server.py'),
host, str(port), id]) host, str(port), id])

View File

@@ -240,7 +240,7 @@ class SmbDotConfTests(TestCase):
finally: finally:
f.close() f.close()
self.topdir = os.path.abspath(samba.source_tree_topdir()) self.topdir = os.path.abspath(samba.tests.source_tree_topdir())
try: try:
self.documented = set(get_documented_parameters(self.topdir)) self.documented = set(get_documented_parameters(self.topdir))

View File

@@ -21,6 +21,7 @@
import os, pwd, grp import os, pwd, grp
import ldb import ldb
import samba import samba
from samba.tests import source_tree_topdir
from samba.tests.samba_tool.base import SambaToolCmdTest from samba.tests.samba_tool.base import SambaToolCmdTest
import shutil import shutil
from samba.netcmd.gpo import get_gpo_dn, get_gpo_info from samba.netcmd.gpo import get_gpo_dn, get_gpo_info
@@ -1879,7 +1880,7 @@ class GpoCmdTestCase(SambaToolCmdTest):
except IndexError: except IndexError:
self.fail("Failed to find GUID in output: %s" % out) self.fail("Failed to find GUID in output: %s" % out)
self.backup_path = os.path.join(samba.source_tree_topdir(), 'source4', self.backup_path = os.path.join(source_tree_topdir(), 'source4',
'selftest', 'provisions', 'selftest', 'provisions',
'generalized-gpo-backup') 'generalized-gpo-backup')