1 #include "ntdb-source.h"
2 #include "tap-interface.h"
4 #include "helprun-external-agent.h"
6 int main(int argc, char *argv[])
9 struct ntdb_context *ntdb;
10 int flags[] = { NTDB_DEFAULT, NTDB_NOMMAP,
11 NTDB_CONVERT, NTDB_NOMMAP|NTDB_CONVERT };
12 NTDB_DATA key = { (unsigned char *)&j, sizeof(j) };
13 NTDB_DATA data = { (unsigned char *)&j, sizeof(j) };
15 plan_tests(sizeof(flags) / sizeof(flags[0]) * 8 + 1);
16 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
18 ntdb = ntdb_open("run-features.ntdb", flags[i]|MAYBE_NOSYNC,
19 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
24 /* Put some stuff in there. */
25 for (j = 0; j < 100; j++) {
26 if (ntdb_store(ntdb, key, data, NTDB_REPLACE) != 0)
27 fail("Storing in ntdb");
30 /* Mess with features fields in hdr. */
31 features = (~NTDB_FEATURE_MASK ^ 1);
32 ok1(ntdb_write_convert(ntdb, offsetof(struct ntdb_header,
34 &features, sizeof(features)) == 0);
35 ok1(ntdb_write_convert(ntdb, offsetof(struct ntdb_header,
37 &features, sizeof(features)) == 0);
40 ntdb = ntdb_open("run-features.ntdb", flags[i]|MAYBE_NOSYNC,
41 O_RDWR, 0, &tap_log_attr);
46 /* Should not have changed features offered. */
47 ok1(ntdb_read_convert(ntdb, offsetof(struct ntdb_header,
49 &features, sizeof(features)) == 0);
50 ok1(features == (~NTDB_FEATURE_MASK ^ 1));
52 /* Should have cleared unknown bits in features_used. */
53 ok1(ntdb_read_convert(ntdb, offsetof(struct ntdb_header,
55 &features, sizeof(features)) == 0);
56 ok1(features == (1 & NTDB_FEATURE_MASK));
61 ok1(tap_log_messages == 0);