summaryrefslogtreecommitdiff
path: root/lib/tdb2/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c6
-rw-r--r--lib/tdb2/test/run-tdb1-endian.c8
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c10
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c8
-rw-r--r--lib/tdb2/test/run-tdb1-zero-append.c4
-rw-r--r--lib/tdb2/test/run-tdb1.c7
-rw-r--r--lib/tdb2/test/tdb1-external-agent.c3
7 files changed, 22 insertions, 24 deletions
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 0f299a32fe..5e0e64e815 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(24);
+ plan_tests(26);
tdb = tdb_open("run-36-file.tdb1", TDB_VERSION1,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_start(tdb) == 0);
ok1(tdb_store(tdb, key, orig_data, TDB_INSERT) == TDB_SUCCESS);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
diff --git a/lib/tdb2/test/run-tdb1-endian.c b/lib/tdb2/test/run-tdb1-endian.c
index bb5acf627b..3b91d45bdf 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(11);
+ plan_tests(14);
tdb = tdb_open("run-endian.tdb1",
TDB_VERSION1|TDB_CONVERT,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -30,13 +30,13 @@ int main(int argc, char *argv[])
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(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
key.dsize++;
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST);
ok1(data.dptr == NULL);
tdb_close(tdb);
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
key.dsize = strlen("hi");
key.dptr = (void *)"hi";
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index 13ec5d826f..d2e07107aa 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
dumbhash_attr.base.next = &log_attr;
dumbhash_attr.hash.fn = tdb1_dumb_hash;
- plan_tests(38 * 2);
+ plan_tests(42 * 2);
for (flags = 0; flags <= TDB_CONVERT; flags += TDB_CONVERT) {
unsigned int rwmagic = TDB1_HASH_RWLOCK_MAGIC;
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
O_RDWR, 0600, &incompat_hash_attr);
ok1(tdb);
ok1(log_count == 0);
- d = tdb1_fetch(tdb, d);
+ ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
O_RDWR, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
- d = tdb1_fetch(tdb, d);
+ ok1(tdb1_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
ok1(log_count == 0);
d.dptr = (void *)"Hello";
d.dsize = 5;
- d = tdb1_fetch(tdb, d);
+ ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
&dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
- d = tdb1_fetch(tdb, d);
+ ok1(tdb1_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index 6a10b46b1b..89e47d3fbf 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(27);
+ plan_tests(30);
key.dsize = strlen("hi");
key.dptr = (void *)"hi";
@@ -28,19 +28,19 @@ int main(int argc, char *argv[])
data.dptr = (void *)"world";
data.dsize = strlen("world");
ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
ok1(tdb1_transaction_start(tdb) != 0);
ok1(tdb_error(tdb) == TDB_ERR_EINVAL);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
ok1(tdb1_transaction_commit(tdb) == 0);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
diff --git a/lib/tdb2/test/run-tdb1-zero-append.c b/lib/tdb2/test/run-tdb1-zero-append.c
index 64169087e3..560b5bc8dd 100644
--- a/lib/tdb2/test/run-tdb1-zero-append.c
+++ b/lib/tdb2/test/run-tdb1-zero-append.c
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize.base.next = &tap_log_attr;
hsize.tdb1_hashsize.hsize = 1024;
- plan_tests(4);
+ plan_tests(5);
tdb = tdb_open(NULL, TDB_INTERNAL|TDB_VERSION1, O_CREAT|O_TRUNC|O_RDWR,
0600, &hsize);
ok1(tdb);
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
ok1(tdb1_append(tdb, key, data) == 0);
ok1(tdb1_append(tdb, key, data) == 0);
- data = tdb1_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == 0);
free(data.dptr);
tdb_close(tdb);
diff --git a/lib/tdb2/test/run-tdb1.c b/lib/tdb2/test/run-tdb1.c
index 584d7d6504..dca6473b1c 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(8);
+ plan_tests(9);
tdb = tdb_open("run.tdb1", TDB_VERSION1,
O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize);
@@ -29,14 +29,13 @@ int main(int argc, char *argv[])
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(tdb_fetch(tdb, key, &data) == TDB_SUCCESS);
ok1(data.dsize == strlen("world"));
ok1(memcmp(data.dptr, "world", strlen("world")) == 0);
free(data.dptr);
key.dsize++;
- data = tdb1_fetch(tdb, key);
- ok1(data.dptr == NULL);
+ ok1(tdb_fetch(tdb, key, &data) == TDB_ERR_NOEXIST);
tdb_close(tdb);
return exit_status();
diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c
index 4a0d383548..6f80b1933c 100644
--- a/lib/tdb2/test/tdb1-external-agent.c
+++ b/lib/tdb2/test/tdb1-external-agent.c
@@ -51,8 +51,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
ret = tdb1_transaction_start(tdb) == 0 ? SUCCESS : OTHER_FAILURE;
break;
case FETCH:
- data = tdb1_fetch(tdb, k);
- if (data.dptr == NULL) {
+ if (tdb_fetch(tdb, k, &data) != TDB_SUCCESS) {
if (tdb->last_error == TDB_ERR_NOEXIST)
ret = FAILED;
else