3 #include "../private.h"
4 #include "tap-interface.h"
6 #include "helpapi-external-agent.h"
8 static bool test_records(struct ntdb_context *ntdb)
11 NTDB_DATA key = { (unsigned char *)&i, sizeof(i) };
12 NTDB_DATA data = { (unsigned char *)&i, sizeof(i) };
14 for (i = 0; i < 1000; i++) {
15 if (ntdb_exists(ntdb, key))
17 if (ntdb_store(ntdb, key, data, NTDB_REPLACE) != 0)
19 if (!ntdb_exists(ntdb, key))
23 for (i = 0; i < 1000; i++) {
24 if (!ntdb_exists(ntdb, key))
26 if (ntdb_delete(ntdb, key) != 0)
28 if (ntdb_exists(ntdb, key))
34 int main(int argc, char *argv[])
37 struct ntdb_context *ntdb;
38 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
39 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
40 NTDB_NOMMAP|NTDB_CONVERT };
42 plan_tests(sizeof(flags) / sizeof(flags[0]) * 2 + 1);
43 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
44 ntdb = ntdb_open("run-14-exists.ntdb", flags[i]|MAYBE_NOSYNC,
45 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
47 ok1(test_records(ntdb));
51 ok1(tap_log_messages == 0);