const char *lockfile; /* lockfile is separate */
const char *dbpath;
+ char *debug_string;
};
static void unlink_old_db(struct ldbtest_ctx *test_ctx)
static void ldb_debug_string(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap)
{
+ struct ldbtest_ctx *test_ctx =
+ talloc_get_type_abort(context, struct ldbtest_ctx);
if (level <= LDB_DEBUG_WARNING) {
- *((char **)context) = talloc_vasprintf(NULL, fmt, ap);
+ test_ctx->debug_string = talloc_vasprintf(test_ctx, fmt, ap);
}
}
struct ldbtest_ctx *test_ctx = talloc_get_type_abort(*state,
struct ldbtest_ctx);
TALLOC_CTX *tmp_ctx;
- char *debug_string = NULL;
char *p = NULL;
/* The GUID mode is not compatible with this test */
return;
#endif
- ldb_set_debug(test_ctx->ldb, ldb_debug_string, &debug_string);
+ ldb_set_debug(test_ctx->ldb, ldb_debug_string, test_ctx);
tmp_ctx = talloc_new(test_ctx);
assert_non_null(tmp_ctx);
ret = ldb_add(test_ctx->ldb, msg02);
assert_int_equal(ret, LDB_ERR_CONSTRAINT_VIOLATION);
- assert_non_null(debug_string);
+ assert_non_null(test_ctx->debug_string);
p = strstr(
- debug_string,
+ test_ctx->debug_string,
"unique index violation on cn "
"in dc=test02, conflicts with dc=test01 in "
"@INDEX:CN:test_unique_index");
assert_non_null(p);
- TALLOC_FREE(debug_string);
+ TALLOC_FREE(test_ctx->debug_string);
talloc_free(tmp_ctx);
}
struct ldbtest_ctx *test_ctx = talloc_get_type_abort(*state,
struct ldbtest_ctx);
TALLOC_CTX *tmp_ctx;
- char *debug_string = NULL;
/* The GUID mode is not compatible with this test */
#ifdef GUID_IDX
return;
#endif
- ldb_set_debug(test_ctx->ldb, ldb_debug_string, &debug_string);
+ ldb_set_debug(test_ctx->ldb, ldb_debug_string, test_ctx);
tmp_ctx = talloc_new(test_ctx);
assert_non_null(tmp_ctx);
ret = ldb_add(test_ctx->ldb, msg02);
assert_int_equal(ret, LDB_ERR_ENTRY_ALREADY_EXISTS);
- assert_null(debug_string);
+ assert_null(test_ctx->debug_string);
talloc_free(tmp_ctx);
}
struct ldbtest_ctx *test_ctx = talloc_get_type_abort(*state,
struct ldbtest_ctx);
TALLOC_CTX *tmp_ctx;
- char *debug_string = NULL;
char *p = NULL;
- ldb_set_debug(test_ctx->ldb, ldb_debug_string, &debug_string);
+ ldb_set_debug(test_ctx->ldb, ldb_debug_string, test_ctx);
tmp_ctx = talloc_new(test_ctx);
assert_non_null(tmp_ctx);
ret = ldb_add(test_ctx->ldb, msg02);
assert_int_equal(ret, LDB_ERR_CONSTRAINT_VIOLATION);
- assert_non_null(debug_string);
+ assert_non_null(test_ctx->debug_string);
p = strstr(
- debug_string,
+ test_ctx->debug_string,
"unique index violation on cn in dc=test02, conflicts with "
"objectUUID 0123456789abcdef in @INDEX:CN:test_unique_index");
assert_non_null(p);
- TALLOC_FREE(debug_string);
+ TALLOC_FREE(test_ctx->debug_string);
talloc_free(tmp_ctx);
- ldb_set_debug(test_ctx->ldb, NULL, NULL);
}
static void test_ldb_guid_index_duplicate_dn_logging(void **state)
struct ldbtest_ctx *test_ctx = talloc_get_type_abort(*state,
struct ldbtest_ctx);
TALLOC_CTX *tmp_ctx;
- char *debug_string = NULL;
- ldb_set_debug(test_ctx->ldb, ldb_debug_string, &debug_string);
+ ldb_set_debug(test_ctx->ldb, ldb_debug_string, test_ctx);
tmp_ctx = talloc_new(test_ctx);
assert_non_null(tmp_ctx);
ret = ldb_add(test_ctx->ldb, msg02);
assert_int_equal(ret, LDB_ERR_ENTRY_ALREADY_EXISTS);
- assert_null(debug_string);
+ assert_null(test_ctx->debug_string);
talloc_free(tmp_ctx);
- ldb_set_debug(test_ctx->ldb, NULL, NULL);
}
static void test_ldb_talloc_destructor_transaction_cleanup(void **state)