1 #include "ntdb-source.h"
2 #include "tap-interface.h"
5 static int log_count
= 0;
7 /* Normally we get a log when setting random seed. */
8 static void my_log_fn(struct ntdb_context
*ntdb
,
9 enum ntdb_log_level level
,
10 enum NTDB_ERROR ecode
,
11 const char *message
, void *priv
)
16 static union ntdb_attribute log_attr
= {
17 .log
= { .base
= { .attr
= NTDB_ATTRIBUTE_LOG
},
21 int main(int argc
, char *argv
[])
24 struct ntdb_context
*ntdb
;
25 union ntdb_attribute attr
;
26 int flags
[] = { NTDB_INTERNAL
, NTDB_DEFAULT
, NTDB_NOMMAP
,
27 NTDB_INTERNAL
|NTDB_CONVERT
, NTDB_CONVERT
,
28 NTDB_NOMMAP
|NTDB_CONVERT
};
30 attr
.seed
.base
.attr
= NTDB_ATTRIBUTE_SEED
;
31 attr
.seed
.base
.next
= &log_attr
;
34 plan_tests(sizeof(flags
) / sizeof(flags
[0]) * 4 + 4 * 3);
35 for (i
= 0; i
< sizeof(flags
) / sizeof(flags
[0]); i
++) {
36 struct ntdb_header hdr
;
38 ntdb
= ntdb_open("run-seed.ntdb", flags
[i
]|MAYBE_NOSYNC
,
39 O_RDWR
|O_CREAT
|O_TRUNC
, 0600, &attr
);
43 ok1(ntdb_check(ntdb
, NULL
, NULL
) == 0);
44 ok1(ntdb
->hash_seed
== 42);
48 if (flags
[i
] & NTDB_INTERNAL
)
51 fd
= open("run-seed.ntdb", O_RDONLY
);
53 ok1(read(fd
, &hdr
, sizeof(hdr
)) == sizeof(hdr
));
54 if (flags
[i
] & NTDB_CONVERT
)
55 ok1(bswap_64(hdr
.hash_seed
) == 42);
57 ok1(hdr
.hash_seed
== 42);