1 #include "ntdb-source.h"
2 #include "tap-interface.h"
5 int main(int argc
, char *argv
[])
8 struct ntdb_context
*ntdb
;
9 int flags
[] = { NTDB_DEFAULT
, NTDB_NOMMAP
,
10 NTDB_CONVERT
, NTDB_NOMMAP
|NTDB_CONVERT
};
11 NTDB_DATA key
= { (unsigned char *)&j
, sizeof(j
) };
12 NTDB_DATA data
= { (unsigned char *)&j
, sizeof(j
) };
14 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 8 + 1);
15 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
17 ntdb
= ntdb_open("run-features.ntdb", flags
[i
]|MAYBE_NOSYNC
,
18 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &tap_log_attr
);
23 /* Put some stuff in there. */
24 for (j
= 0; j
< 100; j
++) {
25 if (ntdb_store(ntdb
, key
, data
, NTDB_REPLACE
) != 0)
26 fail("Storing in ntdb");
29 /* Mess with features fields in hdr. */
30 features
= (~NTDB_FEATURE_MASK
^ 1);
31 ok1(ntdb_write_convert(ntdb
, offsetof(struct ntdb_header
,
33 &features
, sizeof(features
)) == 0);
34 ok1(ntdb_write_convert(ntdb
, offsetof(struct ntdb_header
,
36 &features
, sizeof(features
)) == 0);
39 ntdb
= ntdb_open("run-features.ntdb", flags
[i
]|MAYBE_NOSYNC
,
40 O_RDWR
, 0, &tap_log_attr
);
45 /* Should not have changed features offered. */
46 ok1(ntdb_read_convert(ntdb
, offsetof(struct ntdb_header
,
48 &features
, sizeof(features
)) == 0);
49 ok1(features
== (~NTDB_FEATURE_MASK
^ 1));
51 /* Should have cleared unknown bits in features_used. */
52 ok1(ntdb_read_convert(ntdb
, offsetof(struct ntdb_header
,
54 &features
, sizeof(features
)) == 0);
55 ok1(features
== (1 & NTDB_FEATURE_MASK
));
60 ok1(tap_log_messages
== 0);