selftest: Move LDB cmocka based unit tests to Samba testsuite
authorAndrew Bartlett <abartlet@samba.org>
Mon, 5 Feb 2024 02:29:51 +0000 (15:29 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Mar 2024 02:41:36 +0000 (02:41 +0000)
This allows skip and knownfail entries to be honoured, as well
as enabling the removal of the standalone LDB build system.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/ldb/wscript
selftest/tests.py

index 91bcb9ef06139024e4694756d479aa0c77f9e481..f89c5da7ab70c6983b2313643a5ad05b00f6b401 100644 (file)
@@ -610,48 +610,7 @@ def test(ctx):
     ret = samba_utils.RUN_COMMAND(cmd)
     print("testsuite returned %d" % ret)
 
-    cmocka_ret = 0
-    test_exes = ['test_ldb_qsort',
-                 'test_ldb_dn',
-                 'ldb_msg_test',
-                 'ldb_tdb_mod_op_test',
-                 'ldb_tdb_guid_mod_op_test',
-                 'ldb_tdb_kv_ops_test',
-                 'ldb_tdb_test',
-                 'ldb_match_test',
-                 'ldb_key_value_test',
-                 # we currently don't run ldb_key_value_sub_txn_tdb_test as it
-                 # tests the nested/sub transaction handling
-                 # on operations which the TDB backend does not currently
-                 # support
-                 # 'ldb_key_value_sub_txn_tdb_test'
-                 'ldb_parse_test',
-                 'ldb_filter_attrs_test',
-                 'ldb_filter_attrs_in_place_test',
-                 ]
-
-    # if LIB_LDAP and LIB_LBER defined, then we can test ldb_ldap backend
-    # behavior regression for bz#14413
-    if env.LIB_LDAP and env.LIB_LBER:
-        test_exes += ["lldb_ldap_test"]
-
-    if env.HAVE_LMDB:
-        test_exes += ['ldb_mdb_mod_op_test',
-                      'ldb_lmdb_test',
-                      # we don't want to run ldb_lmdb_size_test (which proves
-                      # we can fit > 4G of data into the DB), it would fill up
-                      # the disk on many of our test instances
-                      'ldb_mdb_kv_ops_test',
-                      'ldb_key_value_sub_txn_mdb_test',
-                      'ldb_lmdb_free_list_test']
-    else:
-        test_exes += ['ldb_no_lmdb_test']
-
-    for test_exe in test_exes:
-            cmd = os.path.join(Context.g_module.out, test_exe)
-            cmocka_ret = cmocka_ret or samba_utils.RUN_COMMAND(cmd)
-
-    sys.exit(ret or cmocka_ret)
+    sys.exit(ret)
 
 def dist():
     '''makes a tarball for distribution'''
index 52c0152e000631b75aad6f19b132284ac75b52a8..d6eb69391b0ed8ca54fda35dc6654aae7351ab88 100644 (file)
@@ -50,6 +50,8 @@ pam_set_items_so_path = config_hash.get("PAM_SET_ITEMS_SO_PATH")
 have_heimdal_support = "SAMBA4_USES_HEIMDAL" in config_hash
 using_system_gssapi = "USING_SYSTEM_GSSAPI" in config_hash
 have_lmdb = "HAVE_LMDB" in config_hash
+have_libldap = "HAVE_LIBLDAP" in config_hash
+have_liblber = "HAVE_LIBLBER" in config_hash
 
 planpythontestsuite("none", "samba.tests.source")
 planpythontestsuite("none", "samba.tests.source_chars")
@@ -98,6 +100,47 @@ planpythontestsuite("none", "index",
                     environ={'LC_ALL': 'tr_TR.UTF-8',
                              'HAVE_LMDB': str(int(have_lmdb))})
 
+# LDB cmocka tests
+
+ldb_test_exes = ['test_ldb_qsort',
+                 'test_ldb_dn',
+                 'ldb_msg_test',
+                 'ldb_tdb_mod_op_test',
+                 'ldb_tdb_guid_mod_op_test',
+                 'ldb_tdb_kv_ops_test',
+                 'ldb_tdb_test',
+                 'ldb_match_test',
+                 'ldb_key_value_test',
+                 # we currently don't run ldb_key_value_sub_txn_tdb_test as it
+                 # tests the nested/sub transaction handling
+                 # on operations which the TDB backend does not currently
+                 # support
+                 # 'ldb_key_value_sub_txn_tdb_test'
+                 'ldb_parse_test',
+                 'ldb_filter_attrs_test',
+                 'ldb_filter_attrs_in_place_test',
+                 ]
+# if LIB_LDAP and LIB_LBER defined, then we can test ldb_ldap backend
+# behavior regression for bz#14413
+if have_libldap and have_liblber:
+    ldb_test_exes += ["lldb_ldap_test"]
+
+if have_lmdb:
+    ldb_test_exes += ['ldb_mdb_mod_op_test',
+                      'ldb_lmdb_test',
+                      # we don't want to run ldb_lmdb_size_test (which proves
+                      # we can fit > 4G of data into the DB), it would fill up
+                      # the disk on many of our test instances
+                      'ldb_mdb_kv_ops_test',
+                      'ldb_key_value_sub_txn_mdb_test',
+                      'ldb_lmdb_free_list_test']
+else:
+    ldb_test_exes += ['ldb_no_lmdb_test']
+
+for ldb_test_exe in ldb_test_exes:
+    plantestsuite(f"ldb.unittests.{ldb_test_exe}", "none",
+                  [os.path.join(bindir(), f"default/lib/ldb/{ldb_test_exe}")])
+
 planpythontestsuite("none", "samba.tests.credentials")
 planpythontestsuite("none", "samba.tests.registry")
 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.auth")