test-dsync-brain.c revision aeaafe8d9a210c9ff121cdb77756940f05e6a088
/* Copyright (c) 2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "master-service.h"
#include "dsync-brain-private.h"
#include "test-common.h"
#include "test-dsync-worker.h"
#include "test-dsync-common.h"
#include <stdlib.h>
enum {
FLAG_EXISTS = 0x01,
FLAG_CREATED = 0x02,
};
struct test_dsync_mailbox {
struct dsync_mailbox box;
unsigned int dest_flags;
};
static struct dsync_message box1_src_msgs[] = {
};
static struct dsync_message box1_dest_msgs[] = {
};
static struct dsync_message box2_src_msgs[] = {
};
static struct dsync_message box3_src_msgs[] = {
};
static struct dsync_message box3_dest_msgs[] = {
};
static struct test_dsync_mailbox mailboxes[] = {
{ { "box1", { { 0x12, 0x34, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
0x21, 0x43, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe } },
1234567890, 4321, 605040302010ULL },
{ { "box2", { { 0xa3, 0xbd, 0x78, 0x24, 0xde, 0xfe, 0x08, 0xf7,
0xac, 0xc7, 0xca, 0x8c, 0xe7, 0x39, 0xdb, 0xca } },
554321023, 6767, 79 },
box2_src_msgs, NULL, 0 },
{ { "box3", { { 0x46, 0x25, 0xb3, 0x24, 0xde, 0xfe, 0x08, 0xf7,
0xac, 0xc7, 0xca, 0x1a, 0xe7, 0x39, 0xdb, 0x54 } },
};
struct master_service *master_service;
{
}
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(mailboxes); i++) {
*idx_r = i;
return TRUE;
}
}
return FALSE;
}
{
}
{
struct test_dsync_worker_msg test_msg;
struct dsync_message *msgs;
unsigned int i, j;
for (i = 0; i < N_ELEMENTS(mailboxes); i++) {
continue;
test_msg.mailbox_idx = i;
}
}
}
const struct test_dsync_msg_event *e2)
{
int ret;
if (ret != 0)
return ret;
}
const struct dsync_message *msg,
const struct test_dsync_mailbox **box2_r,
const struct dsync_message **msg2_r)
{
unsigned int i, j;
for (i = 0; i < N_ELEMENTS(mailboxes); i++) {
continue;
continue;
MAILBOX_GUID_SIZE) != 0 ||
return TRUE;
}
}
}
return FALSE;
}
static void
const struct test_dsync_msg_event *event,
const struct dsync_message *src)
{
MAILBOX_GUID_SIZE) == 0);
}
static void
const struct test_dsync_msg_event **eventsp,
unsigned int *idx_r)
{
unsigned int i, j;
/* we don't try to handle uid conflicts here */
i = j = 0;
/* need to add message to dest */
i++;
/* message expunged from src */
MAILBOX_GUID_SIZE) == 0);
j++; event++;
/* message changed */
i++; j++; event++;
} else {
/* message unchanged */
i++; j++;
}
}
/* message expunged from src */
MAILBOX_GUID_SIZE) == 0);
j++; event++;
}
*idx_r = i;
}
static void
const struct test_dsync_msg_event **eventsp)
{
const struct test_dsync_mailbox *box2;
unsigned int i = 0;
return;
/* sync existing messages */
}
/* sync new messages */
MAILBOX_GUID_SIZE) == 0);
MAILBOX_GUID_SIZE) == 0);
} else {
"hdr\n\nbody") == 0);
}
event++;
}
}
static void
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(mailboxes); i++)
}
static void test_dsync_brain_run(void)
{
struct dsync_brain *brain;
struct dsync_mailbox new_box;
struct test_dsync_box_event box_event;
struct test_dsync_msg_event msg_event;
unsigned int i;
/* have brain read the mailboxes */
for (i = 0; i < N_ELEMENTS(mailboxes); i++) {
}
}
/* check that it created missing mailboxes */
new_box.highest_modseq = 0;
}
/* brain wants mailboxes in guid order. make things easier for us
by sorting them now. */
/* start syncing messages */
for (i = 0; i < N_ELEMENTS(mailboxes); i++) {
}
/* get events and sort them so we can easily check if they're correct */
(void)array_append_space(&msg_events);
}
static void test_dsync_brain(void)
{
test_begin("dsync brain basics");
test_end();
}
int main(void)
{
static void (*test_functions[])(void) = {
};
return test_run(test_functions);
}