This also removes some garbage variables from these module's namespaces.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Thu Dec 4 23:54:18 UTC 2025 on atb-devel-224
return os.path.join(bindir(), name)
+def read_config_h():
+ try:
+ config_h = os.environ["CONFIG_H"]
+ except KeyError:
+ config_h = binpath("default/include/config.h")
+
+ config = {}
+ with open(config_h) as f:
+ for line in f:
+ if line[:8] != '#define ':
+ continue
+ line = line[8:].rstrip()
+ if ' ' not in line:
+ k, v = (line, '')
+ else:
+ k, v = line.split(' ', 1)
+ config[k] = v
+
+ return config
+
+
# Split perl variable to allow $PERL to be set to e.g. "perl -W"
perl = os.getenv("PERL", "perl").split()
from selftesthelpers import planpythontestsuite, samba4srcdir
from selftesthelpers import plantestsuite, bbdir
from selftesthelpers import configuration, valgrindify
-from selftesthelpers import skiptestsuite
+from selftesthelpers import skiptestsuite, read_config_h
samba4bindir = bindir()
-try:
- config_h = os.environ["CONFIG_H"]
-except KeyError:
- config_h = os.path.join(samba4bindir, "default/include/config.h")
# check available features
-config_hash = dict()
-f = open(config_h, 'r')
-try:
- lines = f.readlines()
- config_hash = dict((x[0], ' '.join(x[1:]))
- for x in map(lambda line: line.strip().split(' ')[1:],
- list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
-finally:
- f.close()
+config_hash = read_config_h()
have_man_pages_support = ("XSLTPROC_MANPAGES" in config_hash)
with_pam = ("WITH_PAM" in config_hash)
from selftesthelpers import planpythontestsuite
from selftesthelpers import smbtorture3, configuration, smbclient3, smbtorture4
from selftesthelpers import net, wbinfo, dbwrap_tool, rpcclient
+from selftesthelpers import read_config_h
from selftesthelpers import smbget, smbcacls, smbcquotas
from selftesthelpers import smbtorture4_testsuites
from selftesthelpers import smbtorture4_options
return -1
return 0
-# find config.h
-try:
- config_h = os.environ["CONFIG_H"]
-except KeyError:
- samba4bindir = bindir()
- config_h = os.path.join(samba4bindir, "default/include/config.h")
bbdir = os.path.join(srcdir(), "testprogs/blackbox")
# check available features
-config_hash = dict()
-f = open(config_h, 'r')
-try:
- lines = f.readlines()
- config_hash = dict((x[0], ' '.join(x[1:]))
- for x in map(lambda line: line.strip().split(' ')[1:],
- filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines)))
-finally:
- f.close()
+config_hash = read_config_h()
linux_kernel_version = None
if platform.system() == 'Linux':
from selftesthelpers import plantestsuite_loadlist
from selftesthelpers import skiptestsuite, source4dir, valgrindify
from selftesthelpers import smbtorture4_options, smbtorture4_testsuites
-from selftesthelpers import smbtorture4, samba3srcdir
+from selftesthelpers import smbtorture4, samba3srcdir, read_config_h
print("OPTIONS %s" % " ".join(smbtorture4_options), file=sys.stderr)
options = creds + ' ' + auth_type + ' ' + auth_level
plantestsuite("samba4.ldb.ldap with options %r(ad_dc_default)" % options, "ad_dc_default", "%s/test_ldb.sh ldap $SERVER %s" % (bbdir, options))
-# see if we support ADS on the Samba3 side
-try:
- config_h = os.environ["CONFIG_H"]
-except KeyError:
- config_h = os.path.join(samba4bindir, "default/include/config.h")
-
-# check available features
-config_hash = dict()
-f = open(config_h, 'r')
-try:
- lines = f.readlines()
- config_hash = dict((x[0], ' '.join(x[1:]))
- for x in map(lambda line: line.strip().split(' ')[1:],
- list(filter(lambda line: (line[0:7] == '#define') and (len(line.split(' ')) > 2), lines))))
-finally:
- f.close()
+config_hash = read_config_h()
have_heimdal_support = ("SAMBA4_USES_HEIMDAL" in config_hash)
have_gnutls_fips_mode_support = ("HAVE_GNUTLS_FIPS_MODE_SUPPORTED" in config_hash)