1 #include "ntdb-source.h"
2 #include "tap-interface.h"
4 #include "helprun-external-agent.h"
6 static int log_count = 0;
8 /* Normally we get a log when setting random seed. */
9 static void my_log_fn(struct ntdb_context *ntdb,
10 enum ntdb_log_level level,
11 enum NTDB_ERROR ecode,
12 const char *message, void *priv)
17 static union ntdb_attribute log_attr = {
18 .log = { .base = { .attr = NTDB_ATTRIBUTE_LOG },
22 int main(int argc, char *argv[])
25 struct ntdb_context *ntdb;
26 union ntdb_attribute attr;
27 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
28 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
29 NTDB_NOMMAP|NTDB_CONVERT };
31 attr.seed.base.attr = NTDB_ATTRIBUTE_SEED;
32 attr.seed.base.next = &log_attr;
35 plan_tests(sizeof(flags) / sizeof(flags[0]) * 4 + 4 * 3);
36 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
37 struct ntdb_header hdr;
39 ntdb = ntdb_open("run-seed.ntdb", flags[i]|MAYBE_NOSYNC,
40 O_RDWR|O_CREAT|O_TRUNC, 0600, &attr);
44 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
45 ok1(ntdb->hash_seed == 42);
49 if (flags[i] & NTDB_INTERNAL)
52 fd = open("run-seed.ntdb", O_RDONLY);
54 ok1(read(fd, &hdr, sizeof(hdr)) == sizeof(hdr));
55 if (flags[i] & NTDB_CONVERT)
56 ok1(bswap_64(hdr.hash_seed) == 42);
58 ok1(hdr.hash_seed == 42);