X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=ccan%2Ftdb%2Ftest%2Frun-wronghash-old.c;fp=ccan%2Ftdb%2Ftest%2Frun-wronghash-old.c;h=0000000000000000000000000000000000000000;hb=44eea6ca52a2de5a817cf54d5d206969845dee3d;hp=af82ea28f3d5b45716a6308b0a48b6c8fbe7c08b;hpb=a1ace0cd114e0c588d6ce1b9e7386af11716e0bd;p=ccan diff --git a/ccan/tdb/test/run-wronghash-old.c b/ccan/tdb/test/run-wronghash-old.c deleted file mode 100644 index af82ea28..00000000 --- a/ccan/tdb/test/run-wronghash-old.c +++ /dev/null @@ -1,67 +0,0 @@ -#define _XOPEN_SOURCE 500 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static unsigned int non_jenkins_hash(TDB_DATA *key) -{ - return ~hash_stable(key->dptr, key->dsize, 0); -} - -static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) -{ - unsigned int *count = tdb_get_logging_private(tdb); - if (strstr(fmt, "wrong hash")) - (*count)++; -} - -/* The old code should barf on new-style TDBs created with a non-default hash. - */ -int main(int argc, char *argv[]) -{ - struct tdb_context *tdb; - unsigned int log_count; - struct tdb_logging_context log_ctx = { log_fn, &log_count }; - - plan_tests(8); - - /* We should fail to open new-style non-default-hash tdbs of - * either endian. */ - log_count = 0; - tdb = tdb_open_ex("test/jenkins-le-hash.tdb", 0, 0, O_RDWR, 0, - &log_ctx, NULL); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - tdb = tdb_open_ex("test/jenkins-be-hash.tdb", 0, 0, O_RDWR, 0, - &log_ctx, NULL); - ok1(!tdb); - ok1(log_count == 1); - - /* And of course, if we use the wrong hash it will still fail. */ - log_count = 0; - tdb = tdb_open_ex("test/jenkins-le-hash.tdb", 0, 0, O_RDWR, 0, - &log_ctx, non_jenkins_hash); - ok1(!tdb); - ok1(log_count == 1); - - log_count = 0; - tdb = tdb_open_ex("test/jenkins-be-hash.tdb", 0, 0, O_RDWR, 0, - &log_ctx, non_jenkins_hash); - ok1(!tdb); - ok1(log_count == 1); - - return exit_status(); -}