s3:registry: do not use regdb functions during db upgrade
[Samba/gebeck_regimport.git] / lib / tdb2 / test / run-12-check.c
blob06abe422ab436e1198e9625ef48f8b1eb7af39f1
1 #include <ccan/tdb2/private.h>
2 #include <ccan/failtest/failtest_override.h>
3 #include "tdb2-source.h"
4 #include <ccan/tap/tap.h>
5 #include <ccan/failtest/failtest.h>
6 #include "logging.h"
7 #include "failtest_helper.h"
9 static bool failtest_suppress = false;
11 /* Don't need to test everything here, just want expand testing. */
12 static enum failtest_result
13 suppress_failure(struct failtest_call *history, unsigned num)
15 if (failtest_suppress)
16 return FAIL_DONT_FAIL;
17 return block_repeat_failures(history, num);
20 int main(int argc, char *argv[])
22 unsigned int i;
23 struct tdb_context *tdb;
24 int flags[] = { TDB_INTERNAL,
25 TDB_INTERNAL|TDB_CONVERT,
26 TDB_CONVERT,
27 TDB_INTERNAL|TDB_VERSION1,
28 TDB_VERSION1,
29 TDB_INTERNAL|TDB_CONVERT|TDB_VERSION1,
30 TDB_CONVERT|TDB_VERSION1 };
31 struct tdb_data key = tdb_mkdata("key", 3);
32 struct tdb_data data = tdb_mkdata("data", 4);
34 failtest_init(argc, argv);
35 failtest_hook = suppress_failure;
36 failtest_exit_check = exit_check_log;
38 failtest_suppress = true;
39 plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
40 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
41 tdb = tdb_open("run-12-check.tdb", flags[i],
42 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
43 ok1(tdb);
44 ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
46 /* This is what we really want to test: tdb_check(). */
47 failtest_suppress = false;
48 if (!ok1(tdb_check(tdb, NULL, NULL) == 0))
49 goto fail;
50 failtest_suppress = true;
52 tdb_close(tdb);
54 ok1(tap_log_messages == 0);
55 failtest_exit(exit_status());
57 fail:
58 failtest_suppress = true;
59 tdb_close(tdb);
60 failtest_exit(exit_status());