3 #include "tap-interface.h"
9 static bool test_records(struct ntdb_context
*ntdb
)
12 NTDB_DATA key
= { (unsigned char *)&i
, sizeof(i
) };
13 NTDB_DATA data
= { (unsigned char *)&i
, sizeof(i
) };
15 for (i
= 0; i
< 1000; i
++) {
16 if (ntdb_exists(ntdb
, key
))
18 if (ntdb_store(ntdb
, key
, data
, NTDB_REPLACE
) != 0)
20 if (!ntdb_exists(ntdb
, key
))
24 for (i
= 0; i
< 1000; i
++) {
25 if (!ntdb_exists(ntdb
, key
))
27 if (ntdb_delete(ntdb
, key
) != 0)
29 if (ntdb_exists(ntdb
, key
))
35 int main(int argc
, char *argv
[])
38 struct ntdb_context
*ntdb
;
39 int flags
[] = { NTDB_INTERNAL
, NTDB_DEFAULT
, NTDB_NOMMAP
,
40 NTDB_INTERNAL
|NTDB_CONVERT
, NTDB_CONVERT
,
41 NTDB_NOMMAP
|NTDB_CONVERT
};
43 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 2 + 1);
44 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
45 ntdb
= ntdb_open("run-14-exists.ntdb", flags
[i
]|MAYBE_NOSYNC
,
46 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
48 ok1(test_records(ntdb
));
52 ok1(tap_log_messages
== 0);