#undef fcntl
#undef ftruncate
+static void taplog(struct tdb_context *tdb,
+ enum tdb_debug_level level,
+ const char *fmt, ...)
+{
+ va_list ap;
+ char line[200];
+
+ va_start(ap, fmt);
+ vsprintf(line, fmt, ap);
+ va_end(ap);
+
+ diag("%s", line);
+}
+
static void save_file_contents(int fd)
{
struct stat st;
int main(int argc, char *argv[])
{
+ struct tdb_logging_context logctx = { taplog, NULL };
const int flags[] = { TDB_DEFAULT,
TDB_CLEAR_IF_FIRST,
TDB_NOMMAP,
nice(15);
for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
+ clear_if_first = (flags[i] & TDB_CLEAR_IF_FIRST);
+ diag("Test with %s and %s\n",
+ clear_if_first ? "CLEAR" : "DEFAULT",
+ (flags[i] & TDB_NOMMAP) ? "no mmap" : "mmap");
unlink(TEST_DBNAME);
- tdb = tdb_open(TEST_DBNAME, 1024, flags[i],
- O_CREAT|O_TRUNC|O_RDWR, 0600);
+ tdb = tdb_open_ex(TEST_DBNAME, 1024, flags[i],
+ O_CREAT|O_TRUNC|O_RDWR, 0600,
+ &logctx, NULL);
ok1(tdb);
- clear_if_first = (flags[i] & TDB_CLEAR_IF_FIRST);
ok1(tdb_transaction_start(tdb) == 0);
in_transaction = true;
ok1(tdb_transaction_commit(tdb) == 0);
if (agent_pending)
check_for_agent(tdb->fd, true);
- ok(errors == 0, "We had %u errors", errors);
+ ok(errors == 0, "We had %u unexpected changes", errors);
tdb_close(tdb);
}