summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ntdb/test/api-83-openhook.c10
-rw-r--r--lib/ntdb/test/external-agent.c17
-rw-r--r--lib/ntdb/test/external-agent.h2
-rw-r--r--lib/ntdb/test/run-57-die-during-transaction.c5
-rw-r--r--lib/ntdb/test/run-lockall.c16
-rw-r--r--lib/ntdb/test/run-remap-in-read_traverse.c4
6 files changed, 36 insertions, 18 deletions
diff --git a/lib/ntdb/test/api-83-openhook.c b/lib/ntdb/test/api-83-openhook.c
index 9f474c9ab8..666b4b8d8f 100644
--- a/lib/ntdb/test/api-83-openhook.c
+++ b/lib/ntdb/test/api-83-openhook.c
@@ -11,6 +11,8 @@
#include "external-agent.h"
#include "logging.h"
+#define KEY_STR "key"
+
static enum NTDB_ERROR clear_if_first(int fd, void *arg)
{
/* We hold a lock offset 4 always, so we can tell if anyone is holding it.
@@ -45,7 +47,7 @@ int main(int argc, char *argv[])
struct ntdb_context *ntdb;
struct agent *agent;
union ntdb_attribute cif;
- NTDB_DATA key = ntdb_mkdata("key", 3);
+ NTDB_DATA key = ntdb_mkdata(KEY_STR, strlen(KEY_STR));
int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP,
NTDB_CONVERT, NTDB_NOMMAP|NTDB_CONVERT };
@@ -74,7 +76,8 @@ int main(int argc, char *argv[])
/* Agent should not clear it, since it's still open. */
ok1(external_agent_operation(agent, OPEN_WITH_HOOK,
"run-83-openhook.ntdb") == SUCCESS);
- ok1(external_agent_operation(agent, FETCH, "key") == SUCCESS);
+ ok1(external_agent_operation(agent, FETCH, KEY_STR "=" KEY_STR)
+ == SUCCESS);
ok1(external_agent_operation(agent, CLOSE, "") == SUCCESS);
/* Still exists for us too. */
@@ -85,7 +88,8 @@ int main(int argc, char *argv[])
ok1(external_agent_operation(agent, OPEN_WITH_HOOK,
"run-83-openhook.ntdb") == SUCCESS);
- ok1(external_agent_operation(agent, FETCH, "key") == FAILED);
+ ok1(external_agent_operation(agent, FETCH, KEY_STR "=" KEY_STR)
+ == FAILED);
ok1(external_agent_operation(agent, CLOSE, "") == SUCCESS);
ok1(tap_log_messages == 0);
diff --git a/lib/ntdb/test/external-agent.c b/lib/ntdb/test/external-agent.c
index 098d0cb595..46654c2e64 100644
--- a/lib/ntdb/test/external-agent.c
+++ b/lib/ntdb/test/external-agent.c
@@ -45,11 +45,12 @@ static enum NTDB_ERROR clear_if_first(int fd, void *arg)
static enum agent_return do_operation(enum operation op, const char *name)
{
- NTDB_DATA k;
+ NTDB_DATA k, d;
enum agent_return ret;
NTDB_DATA data;
enum NTDB_ERROR ecode;
union ntdb_attribute cif;
+ const char *eq;
if (op != OPEN && op != OPEN_WITH_HOOK && !ntdb) {
diag("external: No ntdb open!");
@@ -58,7 +59,15 @@ static enum agent_return do_operation(enum operation op, const char *name)
diag("external: %s", operation_name(op));
- k = ntdb_mkdata(name, strlen(name));
+ eq = strchr(name, '=');
+ if (eq) {
+ k = ntdb_mkdata(name, eq - name);
+ d = ntdb_mkdata(eq + 1, strlen(eq+1));
+ } else {
+ k = ntdb_mkdata(name, strlen(name));
+ d.dsize = 0;
+ d.dptr = NULL;
+ }
locking_would_block = 0;
switch (op) {
@@ -99,7 +108,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
ret = FAILED;
} else if (ecode < 0) {
ret = OTHER_FAILURE;
- } else if (!ntdb_deq(data, k)) {
+ } else if (!ntdb_deq(data, d)) {
ret = OTHER_FAILURE;
external_agent_free(data.dptr);
} else {
@@ -108,7 +117,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
}
break;
case STORE:
- ret = ntdb_store(ntdb, k, k, 0) == 0 ? SUCCESS : OTHER_FAILURE;
+ ret = ntdb_store(ntdb, k, d, 0) == 0 ? SUCCESS : OTHER_FAILURE;
break;
case TRANSACTION_START:
ret = ntdb_transaction_start(ntdb) == 0 ? SUCCESS : OTHER_FAILURE;
diff --git a/lib/ntdb/test/external-agent.h b/lib/ntdb/test/external-agent.h
index c6b83d5b49..559a92cd03 100644
--- a/lib/ntdb/test/external-agent.h
+++ b/lib/ntdb/test/external-agent.h
@@ -29,7 +29,7 @@ enum agent_return {
/* Ask the external agent to try to do an operation.
* name == ntdb name for OPEN/OPEN_WITH_CLEAR_IF_FIRST,
- * record name for FETCH/STORE (store stores name as data too)
+ * <key>=<data> for FETCH/STORE.
*/
enum agent_return external_agent_operation(struct agent *handle,
enum operation op,
diff --git a/lib/ntdb/test/run-57-die-during-transaction.c b/lib/ntdb/test/run-57-die-during-transaction.c
index 98ec9dd63a..eb81c996cf 100644
--- a/lib/ntdb/test/run-57-die-during-transaction.c
+++ b/lib/ntdb/test/run-57-die-during-transaction.c
@@ -184,7 +184,8 @@ reset:
return false;
}
- ret = external_agent_operation(agent, op, KEY_STRING);
+ ret = external_agent_operation(agent, op,
+ KEY_STRING "=" KEY_STRING);
if (ret != SUCCESS) {
diag("Step %u op %s failed = %s", current,
operation_name(op),
@@ -237,7 +238,7 @@ reset:
if (ret != SUCCESS)
errx(1, "Agent failed to open: %s", agent_return_name(ret));
- ret = external_agent_operation(agent, FETCH, KEY_STRING);
+ ret = external_agent_operation(agent, FETCH, KEY_STRING "=" KEY_STRING);
if (ret != SUCCESS)
errx(1, "Agent failed find key: %s", agent_return_name(ret));
diff --git a/lib/ntdb/test/run-lockall.c b/lib/ntdb/test/run-lockall.c
index 964164e20b..c4bfb0e5cd 100644
--- a/lib/ntdb/test/run-lockall.c
+++ b/lib/ntdb/test/run-lockall.c
@@ -13,6 +13,7 @@
#include "logging.h"
#define TEST_DBNAME "run-lockall.ntdb"
+#define KEY_STR "key"
#undef fcntl
@@ -40,26 +41,29 @@ int main(int argc, char *argv[])
ok1(ret == SUCCESS);
ok1(ntdb_lockall(ntdb) == NTDB_SUCCESS);
- ok1(external_agent_operation(agent, STORE, "key")
+ ok1(external_agent_operation(agent, STORE, KEY_STR "=" KEY_STR)
== WOULD_HAVE_BLOCKED);
- ok1(external_agent_operation(agent, FETCH, "key")
+ ok1(external_agent_operation(agent, FETCH, KEY_STR "=" KEY_STR)
== WOULD_HAVE_BLOCKED);
/* Test nesting. */
ok1(ntdb_lockall(ntdb) == NTDB_SUCCESS);
ntdb_unlockall(ntdb);
ntdb_unlockall(ntdb);
- ok1(external_agent_operation(agent, STORE, "key") == SUCCESS);
+ ok1(external_agent_operation(agent, STORE, KEY_STR "=" KEY_STR)
+ == SUCCESS);
ok1(ntdb_lockall_read(ntdb) == NTDB_SUCCESS);
- ok1(external_agent_operation(agent, STORE, "key")
+ ok1(external_agent_operation(agent, STORE, KEY_STR "=" KEY_STR)
== WOULD_HAVE_BLOCKED);
- ok1(external_agent_operation(agent, FETCH, "key") == SUCCESS);
+ ok1(external_agent_operation(agent, FETCH, KEY_STR "=" KEY_STR)
+ == SUCCESS);
ok1(ntdb_lockall_read(ntdb) == NTDB_SUCCESS);
ntdb_unlockall_read(ntdb);
ntdb_unlockall_read(ntdb);
- ok1(external_agent_operation(agent, STORE, "key") == SUCCESS);
+ ok1(external_agent_operation(agent, STORE, KEY_STR "=" KEY_STR)
+ == SUCCESS);
ok1(external_agent_operation(agent, CLOSE, NULL) == SUCCESS);
ntdb_close(ntdb);
}
diff --git a/lib/ntdb/test/run-remap-in-read_traverse.c b/lib/ntdb/test/run-remap-in-read_traverse.c
index 2d817c2d73..0e963fc5b1 100644
--- a/lib/ntdb/test/run-remap-in-read_traverse.c
+++ b/lib/ntdb/test/run-remap-in-read_traverse.c
@@ -18,8 +18,8 @@ static unsigned add_records_to_grow(struct agent *agent, int fd, ntdb_len_t size
unsigned int i;
for (i = 0; !file_larger(fd, size); i++) {
- char data[20];
- sprintf(data, "%i", i);
+ char data[50];
+ sprintf(data, "%i=%i", i, i);
if (external_agent_operation(agent, STORE, data) != SUCCESS)
return 0;
}