summaryrefslogtreecommitdiff
path: root/lib/tdb2/test
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:50:13 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-09-14 07:50:13 +0930
commitf68a56ce8f38cc1768d8c2dca84f456f4ecfc625 (patch)
tree640d6e029579d212598615727dc03567c2d6476f /lib/tdb2/test
parentcbad6e2c140e59a6ec653bcfe773599a57a5042f (diff)
downloadsamba-f68a56ce8f38cc1768d8c2dca84f456f4ecfc625.tar.gz
samba-f68a56ce8f38cc1768d8c2dca84f456f4ecfc625.tar.bz2
samba-f68a56ce8f38cc1768d8c2dca84f456f4ecfc625.zip
tdb2: unify tdb1_store into tdb_store
Switch on the TDB_VERSION1 flag. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (Imported from CCAN commit 98c754ffe65bc335f66161d6cc8705d4ea2710ec)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c4
-rw-r--r--lib/tdb2/test/run-tdb1-check.c2
-rw-r--r--lib/tdb2/test/run-tdb1-corrupt.c2
-rw-r--r--lib/tdb2/test/run-tdb1-die-during-transaction.c4
-rw-r--r--lib/tdb2/test/run-tdb1-endian.c12
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c6
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c2
-rw-r--r--lib/tdb2/test/run-tdb1-nested-traverse.c2
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c2
-rw-r--r--lib/tdb2/test/run-tdb1-open-during-transaction.c2
-rw-r--r--lib/tdb2/test/run-tdb1-readonly-check.c7
-rw-r--r--lib/tdb2/test/run-tdb1-summary.c4
-rw-r--r--lib/tdb2/test/run-tdb1-traverse-in-transaction.c2
-rw-r--r--lib/tdb2/test/run-tdb1-wronghash-fail.c2
-rw-r--r--lib/tdb2/test/run-tdb1.c12
-rw-r--r--lib/tdb2/test/tdb1-external-agent.c5
16 files changed, 35 insertions, 35 deletions
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 9194d3a319..0f299a32fe 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
orig_data.dsize = strlen("world");
orig_data.dptr = (void *)"world";
- ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS);
data = tdb1_fetch(tdb, key);
ok1(data.dsize == strlen("world"));
@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
/* Transactions should work. */
ok1(tdb1_transaction_start(tdb) == 0);
- ok1(tdb1_store(tdb, key, orig_data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS);
data = tdb1_fetch(tdb, key);
ok1(data.dsize == strlen("world"));
diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c
index 8a0532c4be..d2360f02fd 100644
--- a/lib/tdb2/test/run-tdb1-check.c
+++ b/lib/tdb2/test/run-tdb1-check.c
@@ -26,7 +26,7 @@ int main(int argc, char *argv[])
data.dsize = strlen("world");
data.dptr = (void *)"world";
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c
index f87afd8a6a..373f079512 100644
--- a/lib/tdb2/test/run-tdb1-corrupt.c
+++ b/lib/tdb2/test/run-tdb1-corrupt.c
@@ -58,7 +58,7 @@ static void check_test(struct tdb_context *tdb)
for (key.dsize = 1; key.dsize <= 5; key.dsize++) {
ksize += key.dsize;
dsize += data.dsize;
- if (tdb1_store(tdb, key, data, TDB_INSERT) != 0)
+ if (tdb_store(tdb, key, data, TDB_INSERT) != TDB_SUCCESS)
abort();
}
diff --git a/lib/tdb2/test/run-tdb1-die-during-transaction.c b/lib/tdb2/test/run-tdb1-die-during-transaction.c
index 4f54f6cbc6..f42513953a 100644
--- a/lib/tdb2/test/run-tdb1-die-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-die-during-transaction.c
@@ -155,7 +155,7 @@ reset:
/* Put key for agent to fetch. */
key.dsize = strlen(KEY_STRING);
key.dptr = (void *)KEY_STRING;
- if (tdb1_store(tdb, key, key, TDB_INSERT) != 0)
+ if (tdb_store(tdb, key, key, TDB_INSERT) != TDB_SUCCESS)
return false;
/* This is the key we insert in transaction. */
@@ -173,7 +173,7 @@ reset:
if (tdb1_transaction_start(tdb) != 0)
return false;
- if (tdb1_store(tdb, key, key, TDB_INSERT) != 0)
+ if (tdb_store(tdb, key, key, TDB_INSERT) != TDB_SUCCESS)
return false;
if (tdb1_transaction_commit(tdb) != 0)
diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c
index 5e529ce2d0..bb5acf627b 100644
--- a/lib/tdb2/test/run-tdb1-endian.c
+++ b/lib/tdb2/test/run-tdb1-endian.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(13);
+ plan_tests(11);
tdb = tdb_open("run-endian.tdb1",
TDB_VERSION1|TDB_CONVERT,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -25,12 +25,10 @@ int main(int argc, char *argv[])
data.dsize = strlen("world");
data.dptr = (void *)"world";
- ok1(tdb1_store(tdb, key, data, TDB_MODIFY) < 0);
- ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) < 0);
- ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
- ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_EXISTS);
+ ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_SUCCESS);
data = tdb1_fetch(tdb, key);
ok1(data.dsize == strlen("world"));
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index 350c78b2b4..13ec5d826f 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
- ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS);
tdb_close(tdb);
/* Should not have marked rwlocks field. */
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
- ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS);
tdb_close(tdb);
/* Should have marked rwlocks field. */
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
- ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS);
tdb_close(tdb);
/* FIXME: Should have marked rwlocks field. */
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index 63fa1de79f..6a10b46b1b 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_start(tdb) == 0);
data.dptr = (void *)"world";
data.dsize = strlen("world");
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
data = tdb1_fetch(tdb, key);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-traverse.c b/lib/tdb2/test/run-tdb1-nested-traverse.c
index 0225620083..ef19911d14 100644
--- a/lib/tdb2/test/run-tdb1-nested-traverse.c
+++ b/lib/tdb2/test/run-tdb1-nested-traverse.c
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
data.dptr = (void *)"world";
data.dsize = strlen("world");
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
tdb1_traverse(tdb, traverse1, NULL);
tdb1_traverse_read(tdb, traverse1, NULL);
tdb_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
index a418556d19..94c125dcad 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -25,7 +25,7 @@ static bool prepare_entries(struct tdb_context *tdb)
data.dsize = strlen("world");
data.dptr = (void *)"world";
- if (tdb1_store(tdb, key, data, 0) != 0)
+ if (tdb_store(tdb, key, data, 0) != TDB_SUCCESS)
return false;
}
return true;
diff --git a/lib/tdb2/test/run-tdb1-open-during-transaction.c b/lib/tdb2/test/run-tdb1-open-during-transaction.c
index fd3a48086c..879d790647 100644
--- a/lib/tdb2/test/run-tdb1-open-during-transaction.c
+++ b/lib/tdb2/test/run-tdb1-open-during-transaction.c
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
data.dptr = (void *)"world";
data.dsize = strlen("world");
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
ok1(tdb1_transaction_commit(tdb) == 0);
ok(!errors, "We had %u open errors", errors);
diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c
index 9bc9a93a7f..6e1b57323c 100644
--- a/lib/tdb2/test/run-tdb1-readonly-check.c
+++ b/lib/tdb2/test/run-tdb1-readonly-check.c
@@ -16,7 +16,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(11);
+ plan_tests(10);
tdb = tdb_open("run-readonly-check.tdb1",
TDB_VERSION1,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
data.dsize = strlen("world");
data.dptr = (void *)"world";
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
/* We are also allowed to do a check inside a transaction. */
@@ -39,8 +39,7 @@ int main(int argc, char *argv[])
TDB_DEFAULT, O_RDONLY, 0, &tap_log_attr);
ok1(tdb);
- ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == -1);
- ok1(tdb_error(tdb) == TDB_ERR_RDONLY);
+ ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
ok1(tdb_close(tdb) == 0);
diff --git a/lib/tdb2/test/run-tdb1-summary.c b/lib/tdb2/test/run-tdb1-summary.c
index 45b4737286..5107b8e436 100644
--- a/lib/tdb2/test/run-tdb1-summary.c
+++ b/lib/tdb2/test/run-tdb1-summary.c
@@ -26,8 +26,10 @@ int main(int argc, char *argv[])
for (j = 0; j < 500; j++) {
/* Make sure padding varies to we get some graphs! */
data.dsize = j % (sizeof(j) + 1);
- if (tdb1_store(tdb, key, data, TDB_REPLACE) != 0)
+ if (tdb_store(tdb, key, data, TDB_REPLACE)
+ != TDB_SUCCESS) {
fail("Storing in tdb");
+ }
}
summary = tdb1_summary(tdb);
diff --git a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
index 27df05ebb3..90783198d9 100644
--- a/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
+++ b/lib/tdb2/test/run-tdb1-traverse-in-transaction.c
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
data.dptr = (void *)"world";
data.dsize = strlen("world");
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
ok1(external_agent_operation1(agent, OPEN, tdb->name) == SUCCESS);
diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c
index 61d56d6c8a..c7e789f2ca 100644
--- a/lib/tdb2/test/run-tdb1-wronghash-fail.c
+++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
- ok1(tdb1_store(tdb, d, d, TDB_INSERT) == 0);
+ ok1(tdb_store(tdb, d, d, TDB_INSERT) == TDB_SUCCESS);
tdb_close(tdb);
/* Fail to open with different hash. */
diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c
index 2d551dc538..584d7d6504 100644
--- a/lib/tdb2/test/run-tdb1.c
+++ b/lib/tdb2/test/run-tdb1.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(10);
+ plan_tests(8);
tdb = tdb_open("run.tdb1", TDB_VERSION1,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -24,12 +24,10 @@ int main(int argc, char *argv[])
data.dsize = strlen("world");
data.dptr = (void *)"world";
- ok1(tdb1_store(tdb, key, data, TDB_MODIFY) < 0);
- ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) == 0);
- ok1(tdb1_store(tdb, key, data, TDB_INSERT) < 0);
- ok1(tdb_error(tdb) == TDB_ERR_EXISTS);
- ok1(tdb1_store(tdb, key, data, TDB_MODIFY) == 0);
+ ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_NOEXIST);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
+ ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_ERR_EXISTS);
+ ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_SUCCESS);
data = tdb1_fetch(tdb, key);
ok1(data.dsize == strlen("world"));
diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c
index eb52e55f62..4a0d383548 100644
--- a/lib/tdb2/test/tdb1-external-agent.c
+++ b/lib/tdb2/test/tdb1-external-agent.c
@@ -66,7 +66,10 @@ static enum agent_return do_operation(enum operation op, const char *name)
free(data.dptr);
break;
case STORE:
- ret = tdb1_store(tdb, k, k, 0) == 0 ? SUCCESS : OTHER_FAILURE;
+ if (tdb_store(tdb, k, k, 0) == TDB_SUCCESS)
+ ret = SUCCESS;
+ else
+ ret = OTHER_FAILURE;
break;
case TRANSACTION_COMMIT:
ret = tdb1_transaction_commit(tdb)==0 ? SUCCESS : OTHER_FAILURE;