4 #include "tap-interface.h"
7 static bool test_records(struct ntdb_context *ntdb)
10 NTDB_DATA key = { (unsigned char *)&i, sizeof(i) };
11 NTDB_DATA data = { (unsigned char *)&i, sizeof(i) };
13 for (i = 0; i < 1000; i++) {
14 if (ntdb_exists(ntdb, key))
16 if (ntdb_store(ntdb, key, data, NTDB_REPLACE) != 0)
18 if (!ntdb_exists(ntdb, key))
22 for (i = 0; i < 1000; i++) {
23 if (!ntdb_exists(ntdb, key))
25 if (ntdb_delete(ntdb, key) != 0)
27 if (ntdb_exists(ntdb, key))
33 int main(int argc, char *argv[])
36 struct ntdb_context *ntdb;
37 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
38 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
39 NTDB_NOMMAP|NTDB_CONVERT };
41 plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1);
42 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
43 ntdb = ntdb_open("run-14-exists.ntdb", flags[i]|MAYBE_NOSYNC,
44 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
46 ok1(test_records(ntdb));
50 ok1(tap_log_messages == 0);