diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:59:13 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-09-14 07:59:13 +0930 |
commit | 8e14a3e06d42b0302868dc3911a2e607e42a51b3 (patch) | |
tree | ada1f4891472e6a4d3904327fb7f6bc0264f915c /lib/tdb2/test | |
parent | 5d9dd8d541a761e0af2c8d50ee55485f2cef3e01 (diff) | |
download | samba-8e14a3e06d42b0302868dc3911a2e607e42a51b3.tar.gz samba-8e14a3e06d42b0302868dc3911a2e607e42a51b3.tar.bz2 samba-8e14a3e06d42b0302868dc3911a2e607e42a51b3.zip |
tdb2: unify tdb1_check and tdb1_summary into tdb_check and tdb_summary.
Switch on the TDB_VERSION1 flag. Also, change tdb1_check's checkfn argument
to return an error code (and set tdb->last_error accordingly).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(Imported from CCAN commit ef92843f2c74ab9d4fa7f167a2182e5e8955df91)
Diffstat (limited to 'lib/tdb2/test')
-rw-r--r-- | lib/tdb2/test/run-tdb1-check.c | 12 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-corrupt.c | 4 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-incompatible.c | 12 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-oldhash.c | 8 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-readonly-check.c | 10 | ||||
-rw-r--r-- | lib/tdb2/test/run-tdb1-wronghash-fail.c | 10 | ||||
-rw-r--r-- | lib/tdb2/test/tdb1-external-agent.c | 2 |
7 files changed, 29 insertions, 29 deletions
diff --git a/lib/tdb2/test/run-tdb1-check.c b/lib/tdb2/test/run-tdb1-check.c index d2360f02fd..e939d04036 100644 --- a/lib/tdb2/test/run-tdb1-check.c +++ b/lib/tdb2/test/run-tdb1-check.c @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) O_CREAT|O_TRUNC|O_RDWR, 0600, &hsize); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); key.dsize = strlen("hi"); key.dptr = (void *)"hi"; @@ -27,18 +27,18 @@ int main(int argc, char *argv[]) data.dptr = (void *)"world"; ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("run-check.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("test/tdb1.corrupt", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == -1); + ok1(tdb_check(tdb, NULL, NULL) == TDB_ERR_CORRUPT); ok1(tdb_error(tdb) == TDB_ERR_CORRUPT); tdb_close(tdb); @@ -46,13 +46,13 @@ int main(int argc, char *argv[]) tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); return exit_status(); diff --git a/lib/tdb2/test/run-tdb1-corrupt.c b/lib/tdb2/test/run-tdb1-corrupt.c index 373f079512..35bc4c3f22 100644 --- a/lib/tdb2/test/run-tdb1-corrupt.c +++ b/lib/tdb2/test/run-tdb1-corrupt.c @@ -45,7 +45,7 @@ static void check_test(struct tdb_context *tdb) TDB_DATA key, data; unsigned int i, verifiable, corrupt, sizes[2], dsize, ksize; - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); key.dptr = (void *)"hello"; data.dsize = strlen("world"); @@ -81,7 +81,7 @@ static void check_test(struct tdb_context *tdb) for (i = 0, corrupt = 0; i < tdb->file->map_size * CHAR_BIT; i++) { tdb1_flip_bit(tdb, i); memset(sizes, 0, sizeof(sizes)); - if (tdb1_check(tdb, check, sizes) != 0) + if (tdb_check(tdb, check, sizes) == TDB_ERR_CORRUPT) corrupt++; else if (sizes[0] != ksize || sizes[1] != dsize) corrupt++; diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c index e6b2994e20..46ab566920 100644 --- a/lib/tdb2/test/run-tdb1-incompatible.c +++ b/lib/tdb2/test/run-tdb1-incompatible.c @@ -105,7 +105,7 @@ int main(int argc, char *argv[]) ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); ok1(d.dsize == 5); free(d.dptr); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); log_count = 0; @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) TDB_VERSION1, O_RDONLY, 0, &jhash_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); log_count = 0; @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) TDB_VERSION1, O_RDONLY, 0, &jhash_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); /* OK, now create with incompatible hash. */ @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); ok1(d.dsize == 5); free(d.dptr); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); /* Can open by letting it figure it out itself. */ @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); ok1(d.dsize == 5); free(d.dptr); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); /* FIXME: Not possible with TDB2 :( */ @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS); ok1(d.dsize == 5); free(d.dptr); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); } diff --git a/lib/tdb2/test/run-tdb1-oldhash.c b/lib/tdb2/test/run-tdb1-oldhash.c index 185001db74..f9cffa25a6 100644 --- a/lib/tdb2/test/run-tdb1-oldhash.c +++ b/lib/tdb2/test/run-tdb1-oldhash.c @@ -20,25 +20,25 @@ int main(int argc, char *argv[]) tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, &tap_log_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("test/old-nohash-le.tdb1", TDB_VERSION1, O_RDWR, 0, &incompat_hash_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); tdb = tdb_open("test/old-nohash-be.tdb1", TDB_VERSION1, O_RDWR, 0, &incompat_hash_attr); ok1(tdb); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); return exit_status(); diff --git a/lib/tdb2/test/run-tdb1-readonly-check.c b/lib/tdb2/test/run-tdb1-readonly-check.c index 471f813da2..f42a8f5e27 100644 --- a/lib/tdb2/test/run-tdb1-readonly-check.c +++ b/lib/tdb2/test/run-tdb1-readonly-check.c @@ -1,5 +1,5 @@ -/* We should be able to tdb1_check a O_RDONLY tdb, and we were previously allowed - * to tdb1_check() inside a transaction (though that's paranoia!). */ +/* We should be able to tdb_check a O_RDONLY tdb, and we were previously allowed + * to tdb_check() inside a transaction (though that's paranoia!). */ #include "tdb2-source.h" #include <ccan/tap/tap.h> #include <stdlib.h> @@ -28,11 +28,11 @@ int main(int argc, char *argv[]) data.dptr = (void *)"world"; ok1(tdb_store(tdb, key, data, TDB_INSERT) == TDB_SUCCESS); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); /* We are also allowed to do a check inside a transaction. */ ok1(tdb_transaction_start(tdb) == TDB_SUCCESS); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); ok1(tdb_close(tdb) == 0); tdb = tdb_open("run-readonly-check.tdb1", @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) ok1(tdb); ok1(tdb_store(tdb, key, data, TDB_MODIFY) == TDB_ERR_RDONLY); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); ok1(tdb_close(tdb) == 0); return exit_status(); diff --git a/lib/tdb2/test/run-tdb1-wronghash-fail.c b/lib/tdb2/test/run-tdb1-wronghash-fail.c index c7e789f2ca..63c1bdf1e4 100644 --- a/lib/tdb2/test/run-tdb1-wronghash-fail.c +++ b/lib/tdb2/test/run-tdb1-wronghash-fail.c @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) 0, &incompat_hash_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); log_count = 0; @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) 0, &incompat_hash_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); /* It should open with jenkins hash if we don't specify. */ @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) &log_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); log_count = 0; @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) &log_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); log_count = 0; @@ -135,7 +135,7 @@ int main(int argc, char *argv[]) 0, &log_attr); ok1(tdb); ok1(log_count == 0); - ok1(tdb1_check(tdb, NULL, NULL) == 0); + ok1(tdb_check(tdb, NULL, NULL) == TDB_SUCCESS); tdb_close(tdb); diff --git a/lib/tdb2/test/tdb1-external-agent.c b/lib/tdb2/test/tdb1-external-agent.c index 6b6f87dea5..150150754a 100644 --- a/lib/tdb2/test/tdb1-external-agent.c +++ b/lib/tdb2/test/tdb1-external-agent.c @@ -74,7 +74,7 @@ static enum agent_return do_operation(enum operation op, const char *name) ret = tdb_transaction_commit(tdb) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; break; case CHECK: - ret = tdb1_check(tdb, NULL, NULL) == 0 ? SUCCESS : OTHER_FAILURE; + ret = tdb_check(tdb, NULL, NULL) == TDB_SUCCESS ? SUCCESS : OTHER_FAILURE; break; case NEEDS_RECOVERY: ret = tdb1_needs_recovery(tdb) ? SUCCESS : FAILED; |