The branch, master has been updated
       via  209cac897ba selftest: use common and simpler code to read config.h
       via  1cc5e3f3a01 s3:selftest:tests.py: remove unused imports
      from  32cd874892d vfs_ceph_new: proper failure-handling in chdir and getwd

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 209cac897ba5b7d87cb553a342240ab8cc2d9e50
Author: Douglas Bagnall <[email protected]>
Date:   Wed Dec 3 15:07:03 2025 +1300

    selftest: use common and simpler code to read config.h
    
    This also removes some garbage variables from these module's namespaces.
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Jennifer Sutton <[email protected]>
    
    Autobuild-User(master): Douglas Bagnall <[email protected]>
    Autobuild-Date(master): Thu Dec  4 23:54:18 UTC 2025 on atb-devel-224

commit 1cc5e3f3a019b3c0c51f521da887dcaa02b639c4
Author: Douglas Bagnall <[email protected]>
Date:   Wed Dec 3 15:03:13 2025 +1300

    s3:selftest:tests.py: remove unused imports
    
    Signed-off-by: Douglas Bagnall <[email protected]>
    Reviewed-by: Jennifer Sutton <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 selftest/selftesthelpers.py | 21 +++++++++++++++++++++
 selftest/tests.py           | 16 ++--------------
 source3/selftest/tests.py   | 23 +++++------------------
 source4/selftest/tests.py   | 19 ++-----------------
 4 files changed, 30 insertions(+), 49 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py
index 54f007addbe..f0345c4e2f6 100644
--- a/selftest/selftesthelpers.py
+++ b/selftest/selftesthelpers.py
@@ -45,6 +45,27 @@ def binpath(name):
     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()
 
diff --git a/selftest/tests.py b/selftest/tests.py
index 4838bfd176f..ae6a16bf014 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -23,24 +23,12 @@ from selftesthelpers import bindir, srcdir, python
 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)
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 8ec0fa32da2..02046bcf1cb 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -28,9 +28,10 @@ from selftesthelpers import bindir, srcdir, scriptdir, 
binpath
 from selftesthelpers import plantestsuite, samba3srcdir
 from selftesthelpers import planpythontestsuite
 from selftesthelpers import smbtorture3, configuration, smbclient3, smbtorture4
-from selftesthelpers import net, wbinfo, dbwrap_tool, rpcclient, python
-from selftesthelpers import smbget, smbcacls, smbcquotas, ntlm_auth3
-from selftesthelpers import valgrindify, smbtorture4_testsuites
+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
 from selftesthelpers import smbcontrol
 from selftesthelpers import smbstatus
@@ -71,25 +72,11 @@ def compare_versions(version1, version2):
             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':
diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py
index 70ab36c868a..0035c9509bb 100755
--- a/source4/selftest/tests.py
+++ b/source4/selftest/tests.py
@@ -28,7 +28,7 @@ from selftesthelpers import planpythontestsuite, 
planperltestsuite
 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)
@@ -99,22 +99,7 @@ for auth_type in ['', '-k no', '-k yes']:
         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)


-- 
Samba Shared Repository

Reply via email to