Mercurial > dovecot > core-2.2
annotate src/dsync/test-dsync-brain.c @ 9644:16849c0931be HEAD
dsync: Handle missing mail GUIDs.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 17 Jul 2009 20:11:05 -0400 |
parents | ffda7bd92ebc |
children | 4d5cc6ce68aa |
rev | line source |
---|---|
9559 | 1 /* Copyright (c) 2009 Dovecot authors, see the included COPYING file */ |
2 | |
3 #include "lib.h" | |
4 #include "array.h" | |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
5 #include "sha1.h" |
9559 | 6 #include "master-service.h" |
7 #include "dsync-brain-private.h" | |
8 #include "test-common.h" | |
9 #include "test-dsync-worker.h" | |
10 #include "test-dsync-common.h" | |
11 | |
12 #include <stdlib.h> | |
13 | |
14 enum { | |
15 FLAG_EXISTS = 0x01, | |
16 FLAG_CREATED = 0x02, | |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
17 FLAG_UNCHANGED = 0x04 |
9559 | 18 }; |
19 | |
20 struct test_dsync_mailbox { | |
21 struct dsync_mailbox box; | |
22 struct dsync_message *src_msgs, *dest_msgs; | |
23 unsigned int dest_flags; | |
24 }; | |
25 | |
26 static const char *kw12[] = { "kw1", "kw2", NULL }; | |
27 | |
28 static struct dsync_message box1_src_msgs[] = { | |
29 { "guid1", 3, MAIL_SEEN, kw12, 123, 987 }, | |
30 { "guid2", 5, MAIL_DRAFT, NULL, 125, 989 }, | |
31 { "guid3", 8, 0, NULL, 128, 990 }, | |
32 { NULL, 0, 0, NULL, 0, 0 } | |
33 }; | |
34 static struct dsync_message box1_dest_msgs[] = { | |
35 { "guid1", 3, MAIL_FLAGGED, NULL, 123, 987 }, | |
36 { "guid2", 5, MAIL_DRAFT, kw12, 125, 989 }, | |
37 { NULL, 0, 0, NULL, 0, 0 } | |
38 }; | |
39 | |
40 static struct dsync_message box2_src_msgs[] = { | |
41 { "guid2", 6, MAIL_ANSWERED | MAIL_FLAGGED, NULL, 3434, 6552354 }, | |
42 { "guid4", 10, 0, NULL, 3426, 43643 }, | |
43 { NULL, 0, 0, NULL, 0, 0 } | |
44 }; | |
45 | |
46 static struct dsync_message box3_src_msgs[] = { | |
47 { "guid1", 1, MAIL_FLAGGED, NULL, 5454, 273850 }, | |
48 { "guid5", 5, 0, NULL, 331, 38701233 }, | |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
49 { "b75c81f2b3a4c9f84f24851c37acedee", 6, DSYNC_MAIL_FLAG_EXPUNGED, NULL, 331, 38701233 }, |
9559 | 50 { NULL, 0, 0, NULL, 0, 0 } |
51 }; | |
52 static struct dsync_message box3_dest_msgs[] = { | |
53 { "guid1", 1, MAIL_FLAGGED, NULL, 5454, 273850 }, | |
54 { "guid8", 3, 0, NULL, 330, 2424 }, | |
55 { "guid5", 5, 0, NULL, 1, 38701233 }, | |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
56 { "guid6", 6, 0, NULL, 333, 6482 }, |
9559 | 57 { "guid7", 7, 0, NULL, 333, 6482 }, |
58 { NULL, 0, 0, NULL, 0, 0 } | |
59 }; | |
60 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
61 static struct test_dsync_mailbox basic_mailboxes[] = { |
9559 | 62 { { "box1", { { 0x12, 0x34, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, |
63 0x21, 0x43, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe } }, | |
64 1234567890, 4321, 605040302010ULL }, | |
65 box1_src_msgs, box1_dest_msgs, FLAG_EXISTS }, | |
66 { { "box2", { { 0xa3, 0xbd, 0x78, 0x24, 0xde, 0xfe, 0x08, 0xf7, | |
67 0xac, 0xc7, 0xca, 0x8c, 0xe7, 0x39, 0xdb, 0xca } }, | |
68 554321023, 6767, 79 }, | |
69 box2_src_msgs, NULL, 0 }, | |
70 { { "box3", { { 0x46, 0x25, 0xb3, 0x24, 0xde, 0xfe, 0x08, 0xf7, | |
71 0xac, 0xc7, 0xca, 0x1a, 0xe7, 0x39, 0xdb, 0x54 } }, | |
72 4545454, 656, 2366 }, box3_src_msgs, | |
73 box3_dest_msgs, FLAG_EXISTS }, | |
74 { { "dir1", { { 0, } }, 0, 0, 0 }, NULL, NULL, FLAG_EXISTS }, | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
75 { { "dir2", { { 0, } }, 0, 0, 0 }, NULL, NULL, 0 }, |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
76 { { "box4", { { 0x46, 0x2d, 0xa3, 0x24, 0x2e, 0x5e, 0x28, 0x67, |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
77 0xa6, 0xc7, 0xca, 0x8a, 0xe7, 0x36, 0xd4, 0xa4 } }, |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
78 2142, 445, 53535 }, box3_src_msgs, |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
79 box3_dest_msgs, FLAG_EXISTS | FLAG_UNCHANGED }, |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
80 { { NULL, { { 0, } }, 0, 0, 0 }, NULL, NULL, 0 } |
9559 | 81 }; |
82 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
83 static struct test_dsync_mailbox *mailboxes; |
9559 | 84 struct master_service *master_service; |
85 | |
86 void master_service_stop(struct master_service *master_service ATTR_UNUSED) | |
87 { | |
88 } | |
89 | |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
90 void mail_generate_guid_128_hash(const char *guid, |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
91 uint8_t guid_128[MAIL_GUID_128_SIZE]) |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
92 { |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
93 unsigned char sha1_sum[SHA1_RESULTLEN]; |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
94 |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
95 sha1_get_digest(guid, strlen(guid), sha1_sum); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
96 memcpy(guid_128, sha1_sum, MAIL_GUID_128_SIZE); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
97 } |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
98 |
9644
16849c0931be
dsync: Handle missing mail GUIDs.
Timo Sirainen <tss@iki.fi>
parents:
9639
diff
changeset
|
99 bool mail_guid_128_is_empty(const uint8_t guid_128[MAIL_GUID_128_SIZE] ATTR_UNUSED) |
16849c0931be
dsync: Handle missing mail GUIDs.
Timo Sirainen <tss@iki.fi>
parents:
9639
diff
changeset
|
100 { |
16849c0931be
dsync: Handle missing mail GUIDs.
Timo Sirainen <tss@iki.fi>
parents:
9639
diff
changeset
|
101 return FALSE; |
16849c0931be
dsync: Handle missing mail GUIDs.
Timo Sirainen <tss@iki.fi>
parents:
9639
diff
changeset
|
102 } |
16849c0931be
dsync: Handle missing mail GUIDs.
Timo Sirainen <tss@iki.fi>
parents:
9639
diff
changeset
|
103 |
9559 | 104 static bool mailbox_find(const char *name, unsigned int *idx_r) |
105 { | |
106 unsigned int i; | |
107 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
108 for (i = 0; mailboxes[i].box.name != NULL; i++) { |
9559 | 109 if (strcmp(mailboxes[i].box.name, name) == 0) { |
110 *idx_r = i; | |
111 return TRUE; | |
112 } | |
113 } | |
114 return FALSE; | |
115 } | |
116 | |
117 static int test_dsync_mailbox_cmp(const void *p1, const void *p2) | |
118 { | |
119 const struct test_dsync_mailbox *t1 = p1, *t2 = p2; | |
120 | |
121 return dsync_mailbox_guid_cmp(&t1->box, &t2->box); | |
122 } | |
123 | |
124 static void test_dsync_sync_msgs(struct test_dsync_worker *worker, bool dest) | |
125 { | |
126 struct test_dsync_worker_msg test_msg; | |
127 struct dsync_message *msgs; | |
128 unsigned int i, j; | |
129 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
130 for (i = 0; mailboxes[i].box.name != NULL; i++) { |
9559 | 131 msgs = dest ? mailboxes[i].dest_msgs : mailboxes[i].src_msgs; |
132 if (msgs == NULL) | |
133 continue; | |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
134 if ((mailboxes[i].dest_flags & FLAG_UNCHANGED) != 0) |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
135 continue; |
9559 | 136 |
137 for (j = 0; msgs[j].guid != NULL; j++) { | |
138 test_msg.msg = msgs[j]; | |
139 test_msg.mailbox_idx = i; | |
140 array_append(&worker->msg_iter.msgs, &test_msg, 1); | |
141 worker->worker.input_callback(worker->worker.input_context); | |
142 } | |
143 } | |
144 | |
145 worker->msg_iter.last = TRUE; | |
146 worker->worker.input_callback(worker->worker.input_context); | |
147 } | |
148 | |
149 static int test_dsync_msg_event_cmp(const struct test_dsync_msg_event *e1, | |
150 const struct test_dsync_msg_event *e2) | |
151 { | |
152 int ret; | |
153 | |
154 ret = memcmp(e1->mailbox.guid, e2->mailbox.guid, | |
155 sizeof(e1->mailbox.guid)); | |
156 if (ret != 0) | |
157 return ret; | |
158 | |
159 return (int)e1->msg.uid - (int)e2->msg.uid; | |
160 } | |
161 | |
162 static bool test_dsync_msg_find_guid(const struct test_dsync_mailbox *box, | |
163 const struct dsync_message *msg, | |
164 const struct test_dsync_mailbox **box2_r, | |
165 const struct dsync_message **msg2_r) | |
166 { | |
167 unsigned int i, j; | |
168 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
169 for (i = 0; mailboxes[i].box.name != NULL; i++) { |
9559 | 170 if (mailboxes[i].src_msgs == NULL) |
171 continue; | |
172 | |
173 for (j = 0; mailboxes[i].src_msgs[j].guid != NULL; j++) { | |
174 if (strcmp(mailboxes[i].src_msgs[j].guid, msg->guid) != 0) | |
175 continue; | |
176 | |
177 if (memcmp(mailboxes[i].box.guid.guid, box->box.guid.guid, | |
178 MAILBOX_GUID_SIZE) != 0 || | |
179 mailboxes[i].src_msgs[j].uid != msg->uid) { | |
180 *box2_r = &mailboxes[i]; | |
181 *msg2_r = &mailboxes[i].src_msgs[j]; | |
182 return TRUE; | |
183 } | |
184 } | |
185 } | |
186 return FALSE; | |
187 } | |
188 | |
189 static void | |
190 test_dsync_brain_verify_existing_one(const struct test_dsync_mailbox *box, | |
191 const struct test_dsync_msg_event *event, | |
192 const struct dsync_message *src) | |
193 { | |
194 test_assert(event->msg.guid != NULL); | |
195 test_assert(event->type == LAST_MSG_TYPE_UPDATE); | |
196 test_assert(memcmp(event->mailbox.guid, box->box.guid.guid, | |
197 MAILBOX_GUID_SIZE) == 0); | |
198 test_assert(event->msg.flags == src->flags); | |
199 test_assert(dsync_keyword_list_equals(event->msg.keywords, | |
200 src->keywords)); | |
201 test_assert(event->msg.modseq == src->modseq); | |
202 } | |
203 | |
204 static void | |
205 test_dsync_brain_verify_existing(const struct test_dsync_mailbox *box, | |
206 const struct test_dsync_msg_event **eventsp, | |
207 unsigned int *idx_r) | |
208 { | |
209 const struct test_dsync_msg_event *event = *eventsp; | |
210 unsigned int i, j; | |
211 | |
212 /* we don't try to handle uid conflicts here */ | |
213 i = j = 0; | |
214 while (box->src_msgs[i].guid != NULL && box->dest_msgs[j].guid != NULL) { | |
215 if (box->src_msgs[i].uid < box->dest_msgs[j].uid) { | |
216 /* need to add message to dest */ | |
217 i++; | |
218 } else if (box->src_msgs[i].uid > box->dest_msgs[j].uid) { | |
219 /* message expunged from src */ | |
220 test_assert(event->type == LAST_MSG_TYPE_EXPUNGE); | |
221 test_assert(memcmp(event->mailbox.guid, box->box.guid.guid, | |
222 MAILBOX_GUID_SIZE) == 0); | |
223 test_assert(event->msg.uid == box->dest_msgs[j].uid); | |
224 j++; event++; | |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
225 } else if (box->src_msgs[i].flags == DSYNC_MAIL_FLAG_EXPUNGED) { |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
226 /* message expunged from end of mailbox */ |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
227 test_assert(event->type == LAST_MSG_TYPE_EXPUNGE); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
228 test_assert(event->msg.uid == box->dest_msgs[j].uid); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
229 i++; j++; event++; |
9559 | 230 } else if (box->src_msgs[i].modseq > box->dest_msgs[j].modseq || |
231 box->src_msgs[i].flags != box->dest_msgs[j].flags || | |
232 !dsync_keyword_list_equals(box->src_msgs[i].keywords, | |
233 box->dest_msgs[j].keywords)) { | |
234 /* message changed */ | |
235 i_assert(strcmp(box->src_msgs[i].guid, | |
236 box->dest_msgs[j].guid) == 0); | |
237 | |
238 test_dsync_brain_verify_existing_one(box, event, | |
239 &box->src_msgs[i]); | |
240 i++; j++; event++; | |
241 } else { | |
242 /* message unchanged */ | |
243 i_assert(strcmp(box->src_msgs[i].guid, | |
244 box->dest_msgs[j].guid) == 0); | |
245 i++; j++; | |
246 } | |
247 } | |
248 while (box->dest_msgs[j].guid != NULL) { | |
249 /* message expunged from src */ | |
250 test_assert(event->type == LAST_MSG_TYPE_EXPUNGE); | |
251 test_assert(memcmp(event->mailbox.guid, box->box.guid.guid, | |
252 MAILBOX_GUID_SIZE) == 0); | |
253 test_assert(event->msg.uid == box->dest_msgs[j].uid); | |
254 j++; event++; | |
255 } | |
256 *idx_r = i; | |
257 *eventsp = event; | |
258 } | |
259 | |
260 static void | |
261 test_dsync_brain_verify_mailbox(const struct test_dsync_mailbox *box, | |
262 const struct test_dsync_msg_event **eventsp) | |
263 { | |
264 const struct test_dsync_msg_event *event = *eventsp; | |
265 const struct test_dsync_mailbox *box2; | |
266 const struct dsync_message *msgs, *msg2; | |
267 unsigned int i = 0; | |
268 | |
269 if (box->src_msgs == NULL) | |
270 return; | |
271 | |
272 msgs = box->src_msgs; | |
273 if (box->dest_msgs != NULL) { | |
274 /* sync existing messages */ | |
275 test_dsync_brain_verify_existing(box, &event, &i); | |
276 } | |
277 | |
278 /* sync new messages */ | |
279 for (; msgs[i].guid != NULL; i++) { | |
280 test_assert(event->msg.guid != NULL); | |
281 test_assert(memcmp(event->mailbox.guid, box->box.guid.guid, | |
282 MAILBOX_GUID_SIZE) == 0); | |
283 if (test_dsync_msg_find_guid(box, &msgs[i], &box2, &msg2)) { | |
284 test_assert(event->type == LAST_MSG_TYPE_COPY); | |
285 test_assert(memcmp(event->copy_src_mailbox.guid, | |
286 box2->box.guid.guid, | |
287 MAILBOX_GUID_SIZE) == 0); | |
288 test_assert(event->copy_src_uid == msg2->uid); | |
289 } else { | |
290 test_assert(event->type == LAST_MSG_TYPE_SAVE); | |
291 test_assert(strcmp(event->save_body, | |
292 "hdr\n\nbody") == 0); | |
293 } | |
294 test_assert(strcmp(event->msg.guid, msgs[i].guid) == 0); | |
295 test_assert(event->msg.uid == msgs[i].uid); | |
296 test_assert(event->msg.flags == msgs[i].flags); | |
297 test_assert(dsync_keyword_list_equals(event->msg.keywords, | |
298 msgs[i].keywords)); | |
299 test_assert(event->msg.modseq == msgs[i].modseq); | |
300 test_assert(event->msg.save_date == msgs[i].save_date); | |
301 | |
302 event++; | |
303 } | |
304 | |
305 *eventsp = event; | |
306 } | |
307 | |
308 static void | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
309 test_dsync_brain_verify_msg_events(struct test_dsync_worker *dest_test_worker) |
9559 | 310 { |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
311 ARRAY_DEFINE(msg_events, struct test_dsync_msg_event); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
312 const struct test_dsync_msg_event *events, *events_end; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
313 struct test_dsync_msg_event msg_event; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
314 unsigned int i, event_count; |
9559 | 315 |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
316 /* get events and sort them so we can easily check if they're correct */ |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
317 t_array_init(&msg_events, 64); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
318 while (test_dsync_worker_next_msg_event(dest_test_worker, &msg_event)) |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
319 array_append(&msg_events, &msg_event, 1); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
320 array_sort(&msg_events, test_dsync_msg_event_cmp); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
321 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
322 events = array_get(&msg_events, &event_count); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
323 events_end = events + event_count; |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
324 for (i = 0; mailboxes[i].box.name != NULL; i++) { |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
325 if ((mailboxes[i].dest_flags & FLAG_UNCHANGED) == 0) |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
326 test_dsync_brain_verify_mailbox(&mailboxes[i], &events); |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
327 } |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
328 test_assert(events == events_end); |
9559 | 329 } |
330 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
331 static void |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
332 test_dsync_brain_run(const struct test_dsync_mailbox *test_mailboxes, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
333 void (*verify_func)(struct test_dsync_worker *)) |
9559 | 334 { |
335 struct dsync_brain *brain; | |
336 struct dsync_worker *src_worker, *dest_worker; | |
337 struct test_dsync_worker *src_test_worker, *dest_test_worker; | |
338 struct dsync_mailbox new_box; | |
339 struct test_dsync_box_event box_event; | |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
340 unsigned int i, j, box_count; |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
341 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
342 box_count = 0; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
343 while (test_mailboxes[box_count].box.name != NULL) |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
344 box_count++; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
345 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
346 mailboxes = t_new(struct test_dsync_mailbox, box_count + 1); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
347 memcpy(mailboxes, test_mailboxes, sizeof(*mailboxes) * box_count); |
9559 | 348 |
349 src_worker = dsync_worker_init_test(); | |
350 dest_worker = dsync_worker_init_test(); | |
351 src_test_worker = (struct test_dsync_worker *)src_worker; | |
352 dest_test_worker = (struct test_dsync_worker *)dest_worker; | |
353 | |
354 brain = dsync_brain_init(src_worker, dest_worker); | |
355 dsync_brain_sync(brain); | |
356 | |
357 /* have brain read the mailboxes */ | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
358 for (i = 0; mailboxes[i].box.name != NULL; i++) { |
9559 | 359 src_test_worker->box_iter.next_box = &mailboxes[i].box; |
360 src_worker->input_callback(src_worker->input_context); | |
361 | |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
362 if ((mailboxes[i].dest_flags & FLAG_EXISTS) != 0) { |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
363 if ((mailboxes[i].dest_flags & FLAG_UNCHANGED) == 0) |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
364 mailboxes[i].box.highest_modseq++; |
9559 | 365 dest_test_worker->box_iter.next_box = &mailboxes[i].box; |
366 dest_worker->input_callback(dest_worker->input_context); | |
367 } | |
368 } | |
369 src_test_worker->box_iter.last = TRUE; | |
370 src_worker->input_callback(src_worker->input_context); | |
371 dest_test_worker->box_iter.last = TRUE; | |
372 dest_worker->input_callback(dest_worker->input_context); | |
373 | |
374 /* check that it created missing mailboxes */ | |
375 while (test_dsync_worker_next_box_event(dest_test_worker, &box_event)) { | |
376 test_assert(box_event.type == LAST_BOX_TYPE_CREATE); | |
377 test_assert(mailbox_find(box_event.box.name, &i)); | |
378 test_assert(mailboxes[i].dest_flags == 0); | |
379 mailboxes[i].dest_flags |= FLAG_CREATED; | |
380 | |
381 new_box = mailboxes[i].box; | |
382 new_box.uid_next = 0; | |
383 new_box.highest_modseq = 0; | |
384 test_assert(dsync_mailboxes_equal(&box_event.box, &new_box)); | |
385 } | |
386 | |
387 /* brain wants mailboxes in guid order. make things easier for us | |
388 by sorting them now. */ | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
389 qsort(mailboxes, box_count, sizeof(*mailboxes), |
9559 | 390 test_dsync_mailbox_cmp); |
391 | |
392 /* start syncing messages */ | |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
393 for (i = j = 0; mailboxes[i].box.name != NULL; i++) { |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
394 if ((mailboxes[i].dest_flags & FLAG_UNCHANGED) != 0) |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
395 continue; |
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
396 test_assert(memcmp(&dest_test_worker->msg_iter_mailboxes[j], |
9559 | 397 mailboxes[i].box.guid.guid, MAILBOX_GUID_SIZE) == 0); |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
398 j++; |
9559 | 399 } |
9639
ffda7bd92ebc
dsync: Skip syncing mailboxes whose uidvalidity/uidnext/highest-modseq hasn't changed.
Timo Sirainen <tss@iki.fi>
parents:
9638
diff
changeset
|
400 test_assert(dest_test_worker->msg_iter_mailbox_count == j); |
9559 | 401 test_dsync_sync_msgs(src_test_worker, FALSE); |
402 test_dsync_sync_msgs(dest_test_worker, TRUE); | |
403 | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
404 verify_func(dest_test_worker); |
9559 | 405 |
406 dsync_worker_deinit(&src_worker); | |
407 dsync_worker_deinit(&dest_worker); | |
408 dsync_brain_deinit(&brain); | |
409 } | |
410 | |
411 static void test_dsync_brain(void) | |
412 { | |
413 test_begin("dsync brain basics"); | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
414 test_dsync_brain_run(basic_mailboxes, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
415 test_dsync_brain_verify_msg_events); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
416 test_end(); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
417 } |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
418 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
419 static struct dsync_message conflict_src_msgs[] = { |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
420 { "guid1", 1, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
421 { "guid3", 3, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
422 { "guid5", 5, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
423 { "guidy", 6, 0, NULL, 1, 1 }, |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
424 { "67ddfe2125de633c56e033b57c897018", 7, DSYNC_MAIL_FLAG_EXPUNGED, NULL, 1, 1 }, |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
425 { "guidz", 8, DSYNC_MAIL_FLAG_EXPUNGED, NULL, 1, 1 }, |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
426 { NULL, 0, 0, NULL, 0, 0 } |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
427 }; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
428 static struct dsync_message conflict_dest_msgs[] = { |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
429 { "guid1", 1, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
430 { "guid2", 2, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
431 { "guidx", 3, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
432 { "guid4", 4, 0, NULL, 1, 1 }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
433 { "guid5", 5, 0, NULL, 1, 1 }, |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
434 { "guid7", 7, 0, NULL, 1, 1 }, |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
435 { "guid8", 8, 0, NULL, 1, 1 }, |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
436 { NULL, 0, 0, NULL, 0, 0 } |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
437 }; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
438 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
439 static struct test_dsync_mailbox conflict_mailboxes[] = { |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
440 { { "box1", { { 0x12, 0x34, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
441 0x21, 0x43, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe } }, |
9593
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
442 1234567890, 4321, 888 }, |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
443 conflict_src_msgs, conflict_dest_msgs, FLAG_EXISTS }, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
444 { { NULL, { { 0, } }, 0, 0, 0 }, NULL, NULL, 0 } |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
445 }; |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
446 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
447 static void |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
448 test_dsync_brain_verify_uid_conflict(struct test_dsync_worker *dest_test_worker) |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
449 { |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
450 struct test_dsync_msg_event event; |
9593
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
451 struct test_dsync_box_event box_event; |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
452 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
453 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
454 test_assert(event.type == LAST_MSG_TYPE_EXPUNGE); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
455 test_assert(event.msg.uid == 2); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
456 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
457 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
458 test_assert(event.type == LAST_MSG_TYPE_EXPUNGE); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
459 test_assert(event.msg.uid == 7); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
460 |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
461 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
462 test_assert(event.type == LAST_MSG_TYPE_SAVE); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
463 test_assert(event.msg.uid == 4321); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
464 test_assert(strcmp(event.msg.guid, "guid3") == 0); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
465 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
466 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
467 test_assert(event.type == LAST_MSG_TYPE_SAVE); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
468 test_assert(event.msg.uid == 6); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
469 test_assert(strcmp(event.msg.guid, "guidy") == 0); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
470 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
471 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
472 test_assert(event.type == LAST_MSG_TYPE_UPDATE_UID); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
473 test_assert(event.msg.uid == 3); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
474 |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
475 test_assert(test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
476 test_assert(event.type == LAST_MSG_TYPE_UPDATE_UID); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
477 test_assert(event.msg.uid == 8); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
478 |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
479 test_assert(!test_dsync_worker_next_msg_event(dest_test_worker, &event)); |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
480 |
9593
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
481 while (test_dsync_worker_next_box_event(dest_test_worker, &box_event) && |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
482 box_event.type == LAST_BOX_TYPE_SELECT) ; |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
483 |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
484 test_assert(box_event.type == LAST_BOX_TYPE_UPDATE); |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
485 test_assert(box_event.box.uid_next == 4322); |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
486 test_assert(box_event.box.uid_validity == 1234567890); |
7de1407b4229
dsync: Improved brain unit test.
Timo Sirainen <tss@iki.fi>
parents:
9592
diff
changeset
|
487 test_assert(box_event.box.highest_modseq == 888); |
9638
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
488 |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
489 while (test_dsync_worker_next_box_event(dest_test_worker, &box_event)) |
b11a3eda2477
dsync: Use expunged messages' GUIDs to determine what to do with missing messages at end of mailbox.
Timo Sirainen <tss@iki.fi>
parents:
9593
diff
changeset
|
490 test_assert(box_event.type == LAST_BOX_TYPE_SELECT); |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
491 } |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
492 |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
493 static void test_dsync_brain_uid_conflict(void) |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
494 { |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
495 test_begin("dsync brain uid conflict"); |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
496 test_dsync_brain_run(conflict_mailboxes, |
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
497 test_dsync_brain_verify_uid_conflict); |
9559 | 498 test_end(); |
499 } | |
500 | |
501 int main(void) | |
502 { | |
503 static void (*test_functions[])(void) = { | |
504 test_dsync_brain, | |
9592
7b0bcf423fca
dsync: Fixed uid conflict handling.
Timo Sirainen <tss@iki.fi>
parents:
9559
diff
changeset
|
505 test_dsync_brain_uid_conflict, |
9559 | 506 NULL |
507 }; | |
508 return test_run(test_functions); | |
509 } |