summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Haslett <aaronhaslett@catalyst.net.nz>2019-05-28 17:22:10 +1200
committerKarolin Seeger <kseeger@samba.org>2019-08-28 07:36:29 +0000
commit3e9e7afc2599cd95d2b7b374575bb4b20fa1c060 (patch)
tree59e963bf26fef618db063a08b7735f18ee05e536
parentabc63d6eab0cbe76140f6c03f3f0385eb9a863e1 (diff)
downloadsamba-3e9e7afc2599cd95d2b7b374575bb4b20fa1c060.tar.gz
ldb: test for parse errors
Parse errors aren't passed up correctly by the tdb backend. This patch modifies a test to expose the issue, next patch will fix it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13959 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit 2de0aebed60b8e83508f50e5391ede618ce0e595)
-rw-r--r--lib/ldb/tests/ldb_kv_ops_test.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/ldb/tests/ldb_kv_ops_test.c b/lib/ldb/tests/ldb_kv_ops_test.c
index 30ce019fac8..4183f65bc57 100644
--- a/lib/ldb/tests/ldb_kv_ops_test.c
+++ b/lib/ldb/tests/ldb_kv_ops_test.c
@@ -202,6 +202,17 @@ static int parse(struct ldb_val key,
}
/*
+ * Parse function that just returns the int we pass it.
+ */
+static int parse_return(struct ldb_val key,
+ struct ldb_val data,
+ void *private_data)
+{
+ int *rcode = private_data;
+ return *rcode;
+}
+
+/*
* Test that data can be written to the kv store and be read back.
*/
static void test_add_get(void **state)
@@ -223,6 +234,7 @@ static void test_add_get(void **state)
};
struct ldb_val read;
+ int rcode;
int flags = 0;
TALLOC_CTX *tmp_ctx;
@@ -260,6 +272,17 @@ static void test_add_get(void **state)
assert_int_equal(sizeof(value), read.length);
assert_memory_equal(value, read.data, sizeof(value));
+ /*
+ * Now check that the error code we return in the
+ * parse function is returned by fetch_and_parse.
+ */
+ for (rcode=0; rcode<50; rcode++) {
+ ret = ltdb->kv_ops->fetch_and_parse(ltdb, key,
+ parse_return,
+ &rcode);
+ assert_int_equal(ret, rcode);
+ }
+
ret = ltdb->kv_ops->unlock_read(test_ctx->ldb->modules);
assert_int_equal(ret, 0);
talloc_free(tmp_ctx);