]> git.ozlabs.org Git - ccan/blob - junkcode/rusty@rustcorp.com.au-ntdb/test/run-12-check.c
ccan/ntdb: demote to junkcode.
[ccan] / junkcode / rusty@rustcorp.com.au-ntdb / test / run-12-check.c
1 #include "../private.h"
2 #include <ccan/failtest/failtest_override.h>
3 #include "ntdb-source.h"
4 #include "tap-interface.h"
5 #include <ccan/failtest/failtest.h>
6 #include "logging.h"
7 #include "failtest_helper.h"
8 #include "helprun-external-agent.h"
9
10 int main(int argc, char *argv[])
11 {
12         unsigned int i;
13         struct ntdb_context *ntdb;
14         int flags[] = { NTDB_INTERNAL,
15                         NTDB_INTERNAL|NTDB_CONVERT,
16                         NTDB_CONVERT };
17         NTDB_DATA key = ntdb_mkdata("key", 3);
18         NTDB_DATA data = ntdb_mkdata("data", 4);
19
20         failtest_init(argc, argv);
21         failtest_hook = block_repeat_failures;
22         failtest_exit_check = exit_check_log;
23
24         failtest_suppress = true;
25         plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
26         for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
27                 ntdb = ntdb_open("run-12-check.ntdb", flags[i]|MAYBE_NOSYNC,
28                                  O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
29                 ok1(ntdb);
30                 ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
31
32                 /* This is what we really want to test: ntdb_check(). */
33                 failtest_suppress = false;
34                 if (!ok1(ntdb_check(ntdb, NULL, NULL) == 0))
35                         goto fail;
36                 failtest_suppress = true;
37
38                 ntdb_close(ntdb);
39         }
40         ok1(tap_log_messages == 0);
41         failtest_exit(exit_status());
42
43 fail:
44         failtest_suppress = true;
45         ntdb_close(ntdb);
46         failtest_exit(exit_status());
47
48         /*
49          * We will never reach this but the compiler complains if we do not
50          * return in this function.
51          */
52         return EFAULT;
53 }