ldb_mod_op_test: Make sure that closing the database frees locks
authorGary Lockyer <gary@catalyst.net.nz>
Mon, 22 Jan 2018 22:03:16 +0000 (11:03 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 7 Mar 2018 03:38:02 +0000 (04:38 +0100)
Without the destructor firing, this test used to pass, but now we show
that we must be able to open a new ldb handle.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Mar  7 04:38:02 CET 2018 on sn-devel-144

lib/ldb/tests/ldb_mod_op_test.c

index 425a984ed5de1dcf34de38c5baea9b688baef008..b91130252a7614063267347140149d702a6d3814 100644 (file)
@@ -3662,6 +3662,35 @@ static void test_ldb_talloc_destructor_transaction_cleanup(void **state)
         * Trigger the destructor
         */
        TALLOC_FREE(test_ctx->ldb);
+
+       /*
+        * Now ensure that a new connection can be opened
+        */
+       {
+               TALLOC_CTX *tctx = talloc_new(test_ctx);
+               struct ldbtest_ctx *ctx = talloc_zero(tctx, struct ldbtest_ctx);
+               struct ldb_dn *basedn;
+               struct ldb_result *result = NULL;
+               int ret;
+
+               ldbtest_setup((void *)&ctx);
+
+               basedn = ldb_dn_new_fmt(tctx, ctx->ldb, "dc=test");
+               assert_non_null(basedn);
+
+               ret = ldb_search(ctx->ldb,
+                                tctx,
+                                &result,
+                                basedn,
+                                LDB_SCOPE_BASE,
+                                NULL,
+                                NULL);
+               assert_int_equal(ret, 0);
+               assert_non_null(result);
+               assert_int_equal(result->count, 0);
+
+               ldbtest_teardown((void *)&ctx);
+       }
 }