test-mail-transaction-log-append.c revision 92dab926b2f2270057b40a907a00cf8eb2309ed6
/* Copyright (c) 2009-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "test-common.h"
#include "mail-index-private.h"
#include "mail-transaction-log-private.h"
static bool log_lock_failure = FALSE;
const char *filepath ATTR_UNUSED,
const char *function ATTR_UNUSED)
{
}
const char *lock_reason ATTR_UNUSED)
{
return log_lock_failure ? -1 : 0;
}
const char *lock_reason ATTR_UNUSED) {}
const void *data ATTR_UNUSED,
unsigned int version ATTR_UNUSED)
{
*cur_modseq += 1;
}
{
return -1;
}
{
struct mail_transaction_log_append_ctx *ctx;
const struct mail_transaction_header *hdr;
const unsigned int *bufp;
const struct mail_transaction_boundary *bound;
test_assert(file->buffer->used == (size_t)((const char *)(bufp+1) - (const char *)file->buffer->data));
file->buffer_offset = 0;
test_end();
}
{
struct mail_transaction_log_append_ctx *ctx;
const struct mail_transaction_header *hdr;
const struct mail_transaction_header_update *u;
test_begin("transaction log append: append_sync_offset only");
u = (const void *)(hdr + 1);
offsetp = (const void *)(u+1);
test_end();
}
static void test_mail_transaction_log_append(void)
{
struct mail_transaction_log *log;
struct mail_transaction_log_file *file;
struct mail_transaction_log_append_ctx *ctx;
char tmp_path[] = "/tmp/dovecot.test.XXXXXX";
int fd;
if (fd == -1)
test_begin("transaction log append");
test_begin("transaction log append: lock failure");
test_end();
/* do this after head->buffer has already been initialized */
test_begin("transaction log append: garbage truncation");
test_end();
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}