1 #include <ccan/failtest/failtest_override.h>
2 #include "ntdb-source.h"
3 #include "tap-interface.h"
4 #include <ccan/failtest/failtest.h>
6 #include "failtest_helper.h"
8 int main(int argc, char *argv[])
11 struct ntdb_context *ntdb;
12 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
13 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
14 NTDB_NOMMAP|NTDB_CONVERT };
15 NTDB_DATA key = ntdb_mkdata("key", 3);
16 NTDB_DATA data = ntdb_mkdata("data", 4);
18 failtest_init(argc, argv);
19 failtest_hook = block_repeat_failures;
20 failtest_exit_check = exit_check_log;
22 failtest_suppress = true;
23 plan_tests(sizeof(flags) / sizeof(flags[0]) * 7 + 1);
24 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
25 ntdb = ntdb_open("run-10-simple-store.ntdb", flags[i],
26 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
29 /* Modify should fail. */
30 failtest_suppress = false;
31 if (!ok1(ntdb_store(ntdb, key, data, NTDB_MODIFY)
34 failtest_suppress = true;
35 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
36 /* Insert should succeed. */
37 failtest_suppress = false;
38 if (!ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0))
40 failtest_suppress = true;
41 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
42 /* Second insert should fail. */
43 failtest_suppress = false;
44 if (!ok1(ntdb_store(ntdb, key, data, NTDB_INSERT)
47 failtest_suppress = true;
48 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
51 ok1(tap_log_messages == 0);
52 failtest_exit(exit_status());
55 failtest_suppress = true;
57 failtest_exit(exit_status());