annotate src/lib-index/test-mail-transaction-log-file.c @ 22691:dca05b22217b

director: Fix crash when handling expired USER timestamps. The fix in 154f91726624265fce15097eb4bbbf6e55f8c477 wasn't complete.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 28 Nov 2017 13:10:35 +0200
parents 31ab1147d15d
children cb108f786fb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
1 /* Copyright (c) 2009-2017 Dovecot authors, see the included COPYING file */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
2
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
3 #include "lib.h"
22428
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
4 #include "ioloop.h"
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
5 #include "test-common.h"
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
6 #include "mail-index-private.h"
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
7 #include "mail-transaction-log-private.h"
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
8
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
9 #define TEST_LOG_VERSION MAIL_TRANSACTION_LOG_VERSION_FULL(1, 3)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
10
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
11 #define INITIAL_MODSEQ 100
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
12
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
13 struct update_modseq_test {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
14 enum mail_transaction_type type;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
15 unsigned int version;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
16 #define NOUPDATE (INITIAL_MODSEQ)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
17 #define UPDATE (INITIAL_MODSEQ+1)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
18 uint64_t expected_modseq;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
19 unsigned int count;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
20 union {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
21 const struct mail_transaction_flag_update *flag_update;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
22 const struct mail_transaction_modseq_update *modseq_update;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
23 } v;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
24 } update_modseq_tests[] = {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
25 /* expunges: increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
26 { MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT | MAIL_TRANSACTION_EXTERNAL, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
27 { MAIL_TRANSACTION_EXPUNGE_GUID | MAIL_TRANSACTION_EXPUNGE_PROT | MAIL_TRANSACTION_EXTERNAL, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
28 /* expunges: don't increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
29 { MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
30 { MAIL_TRANSACTION_EXPUNGE_GUID | MAIL_TRANSACTION_EXPUNGE_PROT, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
31 { MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXTERNAL, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
32 { MAIL_TRANSACTION_EXPUNGE_GUID | MAIL_TRANSACTION_EXTERNAL, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
33
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
34 /* flag changes: don't increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
35 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
36 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
37 { .uid1 = 1, .uid2 = 2, .add_flags = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
38 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
39 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
40 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
41 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
42 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_BACKEND }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
43 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
44 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
45 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
46 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
47 { .uid1 = 1, .uid2 = 2, .remove_flags = MAIL_INDEX_MAIL_FLAG_BACKEND }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
48 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
49 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
50 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
51 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
52 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_DIRTY }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
53 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
54 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
55 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
56 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
57 { .uid1 = 1, .uid2 = 2, .remove_flags = MAIL_INDEX_MAIL_FLAG_DIRTY }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
58 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
59 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
60 /* flag changes: increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
61 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
62 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
63 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_SEEN }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
64 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
65 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
66 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
67 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
68 { .uid1 = 1, .uid2 = 2, .remove_flags = MAIL_SEEN }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
69 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
70 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
71 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
72 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
73 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_SEEN | MAIL_INDEX_MAIL_FLAG_BACKEND }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
74 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
75 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
76 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
77 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
78 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_SEEN | MAIL_INDEX_MAIL_FLAG_DIRTY }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
79 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
80 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
81 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
82 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
83 { .uid1 = 1, .uid2 = 2, .remove_flags = MAIL_SEEN | MAIL_INDEX_MAIL_FLAG_BACKEND }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
84 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
85 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
86 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
87 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
88 { .uid1 = 1, .uid2 = 2, .remove_flags = MAIL_SEEN | MAIL_INDEX_MAIL_FLAG_DIRTY }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
89 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
90 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
91 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 2, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
92 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
93 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_DIRTY },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
94 { .uid1 = 3, .uid2 = 4, .add_flags = MAIL_SEEN }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
95 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
96 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
97 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
98 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
99 { .uid1 = 1, .uid2 = 2, .add_flags = 0, .modseq_inc_flag = 1 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
100 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
101 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
102 { MAIL_TRANSACTION_FLAG_UPDATE, TEST_LOG_VERSION, UPDATE, 2, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
103 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
104 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_DIRTY },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
105 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_DIRTY, .modseq_inc_flag = 1 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
106 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
107 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
108 /* flag changes: increase modseq with old version */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
109 { MAIL_TRANSACTION_FLAG_UPDATE, MAIL_TRANSACTION_LOG_VERSION_FULL(1, 2), UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
110 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
111 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_BACKEND }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
112 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
113 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
114 { MAIL_TRANSACTION_FLAG_UPDATE, MAIL_TRANSACTION_LOG_VERSION_FULL(1, 2), UPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
115 .flag_update = (const struct mail_transaction_flag_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
116 { .uid1 = 1, .uid2 = 2, .add_flags = MAIL_INDEX_MAIL_FLAG_DIRTY }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
117 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
118 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
119 /* modseq updates: don't increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
120 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
121 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
122 { .uid = 1, .modseq_low32 = 50, .modseq_high32 = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
123 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
124 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
125 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
126 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
127 { .uid = 1, .modseq_low32 = 100, .modseq_high32 = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
128 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
129 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
130 /* modseq updates: increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
131 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, 500, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
132 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
133 { .uid = 1, .modseq_low32 = 500, .modseq_high32 = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
134 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
135 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
136 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, 500, 2, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
137 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
138 { .uid = 1, .modseq_low32 = 50, .modseq_high32 = 0 },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
139 { .uid = 1, .modseq_low32 = 500, .modseq_high32 = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
140 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
141 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
142 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, 500, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
143 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
144 { .uid = 1, .modseq_low32 = 500, .modseq_high32 = 0 },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
145 { .uid = 1, .modseq_low32 = 200, .modseq_high32 = 0 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
146 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
147 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
148 { MAIL_TRANSACTION_MODSEQ_UPDATE, TEST_LOG_VERSION, (uint64_t)4294967346, 1, {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
149 .modseq_update = (const struct mail_transaction_modseq_update[]) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
150 { .uid = 1, .modseq_low32 = 50, .modseq_high32 = 1 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
151 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
152 } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
153
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
154 /* appends, keyword changes, attribute changes: increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
155 { MAIL_TRANSACTION_APPEND, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
156 { MAIL_TRANSACTION_KEYWORD_UPDATE, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
157 { MAIL_TRANSACTION_KEYWORD_RESET, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
158 { MAIL_TRANSACTION_ATTRIBUTE_UPDATE, TEST_LOG_VERSION, UPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
159
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
160 /* others: don't increase modseq */
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
161 { MAIL_TRANSACTION_HEADER_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
162 { MAIL_TRANSACTION_HEADER_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
163 { MAIL_TRANSACTION_EXT_INTRO, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
164 { MAIL_TRANSACTION_EXT_RESET, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
165 { MAIL_TRANSACTION_EXT_HDR_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
166 { MAIL_TRANSACTION_EXT_REC_UPDATE, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
167 { MAIL_TRANSACTION_EXT_ATOMIC_INC, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
168 { MAIL_TRANSACTION_EXT_HDR_UPDATE32, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
169 { MAIL_TRANSACTION_INDEX_DELETED, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
170 { MAIL_TRANSACTION_INDEX_UNDELETED, TEST_LOG_VERSION, NOUPDATE, 1, { } },
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
171 };
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
172
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
173 static size_t update_modseq_test_get_size(const struct update_modseq_test *test)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
174 {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
175 enum mail_transaction_type type =
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
176 test->type & MAIL_TRANSACTION_TYPE_MASK;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
177
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
178 if (type == (MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT))
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
179 type = MAIL_TRANSACTION_EXPUNGE;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
180 if (type == (MAIL_TRANSACTION_EXPUNGE_GUID | MAIL_TRANSACTION_EXPUNGE_PROT))
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
181 type = MAIL_TRANSACTION_EXPUNGE_GUID;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
182
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
183 switch (type) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
184 case MAIL_TRANSACTION_EXPUNGE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
185 return sizeof(struct mail_transaction_expunge);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
186 case MAIL_TRANSACTION_EXPUNGE_GUID:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
187 return sizeof(struct mail_transaction_expunge_guid);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
188 case MAIL_TRANSACTION_APPEND:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
189 return sizeof(struct mail_index_record);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
190 case MAIL_TRANSACTION_KEYWORD_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
191 return sizeof(struct mail_transaction_keyword_update);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
192 case MAIL_TRANSACTION_KEYWORD_RESET:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
193 return sizeof(struct mail_transaction_keyword_reset);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
194 case MAIL_TRANSACTION_ATTRIBUTE_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
195 return 4;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
196 case MAIL_TRANSACTION_FLAG_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
197 return sizeof(struct mail_transaction_flag_update);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
198 case MAIL_TRANSACTION_MODSEQ_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
199 return sizeof(struct mail_transaction_modseq_update);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
200 case MAIL_TRANSACTION_HEADER_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
201 case MAIL_TRANSACTION_EXT_INTRO:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
202 case MAIL_TRANSACTION_EXT_RESET:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
203 case MAIL_TRANSACTION_EXT_HDR_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
204 case MAIL_TRANSACTION_EXT_REC_UPDATE:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
205 case MAIL_TRANSACTION_EXT_ATOMIC_INC:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
206 case MAIL_TRANSACTION_EXT_HDR_UPDATE32:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
207 case MAIL_TRANSACTION_INDEX_DELETED:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
208 case MAIL_TRANSACTION_INDEX_UNDELETED:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
209 return 4;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
210 case MAIL_TRANSACTION_TYPE_MASK:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
211 case MAIL_TRANSACTION_BOUNDARY:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
212 case MAIL_TRANSACTION_EXPUNGE_PROT:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
213 case MAIL_TRANSACTION_EXTERNAL:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
214 case MAIL_TRANSACTION_SYNC:
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
215 break;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
216 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
217 i_unreached();
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
218 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
219
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
220 static void test_mail_transaction_update_modseq(void)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
221 {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
222 struct mail_transaction_header hdr;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
223 unsigned char tempbuf[1024] = { 0 };
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
224
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
225 test_begin("mail_transaction_update_modseq()");
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
226 for (unsigned int i = 0; i < N_ELEMENTS(update_modseq_tests); i++) {
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
227 const struct update_modseq_test *test = &update_modseq_tests[i];
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
228 const void *data = test->v.flag_update;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
229 uint64_t cur_modseq = INITIAL_MODSEQ;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
230
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
231 if (data == NULL)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
232 data = tempbuf;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
233
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
234 hdr.type = test->type;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
235 hdr.size = sizeof(hdr) + update_modseq_test_get_size(test) * test->count;
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
236 hdr.size = mail_index_uint32_to_offset(hdr.size);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
237 mail_transaction_update_modseq(&hdr, data, &cur_modseq, test->version);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
238 test_assert_idx(cur_modseq >= INITIAL_MODSEQ, i);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
239 test_assert_idx(test->expected_modseq == cur_modseq, i);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
240 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
241 test_end();
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
242 }
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
243
22428
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
244 static struct mail_index *test_mail_index_open(void)
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
245 {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
246 struct mail_index *index = mail_index_alloc(NULL, "test.dovecot.index");
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
247 test_assert(mail_index_open_or_create(index, MAIL_INDEX_OPEN_FLAG_CREATE) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
248 struct mail_index_view *view = mail_index_view_open(index);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
249
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
250 struct mail_index_transaction *trans =
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
251 mail_index_transaction_begin(view, 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
252 uint32_t uid_validity = 1234;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
253 mail_index_update_header(trans,
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
254 offsetof(struct mail_index_header, uid_validity),
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
255 &uid_validity, sizeof(uid_validity), TRUE);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
256 test_assert(mail_index_transaction_commit(&trans) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
257 mail_index_view_close(&view);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
258 return index;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
259 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
260
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
261 static void test_mail_transaction_log_file_modseq_offsets(void)
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
262 {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
263 test_begin("mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()");
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
264
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
265 struct mail_index *index = test_mail_index_open();
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
266 struct mail_transaction_log_file *file = index->log->head;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
267
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
268 const unsigned int max_modseq = LOG_FILE_MODSEQ_CACHE_SIZE+2;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
269 uoff_t modseq_next_offset[max_modseq+1];
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
270 uoff_t modseq_alt_next_offset[max_modseq+1];
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
271
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
272 /* start with modseq=2, because modseq=1 is the initial state */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
273 modseq_next_offset[1] = sizeof(struct mail_transaction_log_header);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
274 modseq_alt_next_offset[1] = sizeof(struct mail_transaction_log_header);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
275 for (uint64_t modseq = 2; modseq <= max_modseq; modseq++) {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
276 uint32_t seq;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
277
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
278 struct mail_index_view *view = mail_index_view_open(index);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
279 struct mail_index_transaction *trans =
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
280 mail_index_transaction_begin(view, 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
281 mail_index_append(trans, modseq, &seq);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
282 test_assert(mail_index_transaction_commit(&trans) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
283 modseq_next_offset[modseq] = file->sync_offset;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
284 mail_index_view_close(&view);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
285
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
286 /* add a non-modseq updating change */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
287 view = mail_index_view_open(index);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
288 trans = mail_index_transaction_begin(view, 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
289 mail_index_update_flags(trans, seq, MODIFY_ADD,
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
290 (enum mail_flags)MAIL_INDEX_MAIL_FLAG_DIRTY);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
291 test_assert(mail_index_transaction_commit(&trans) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
292 mail_index_view_close(&view);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
293 modseq_alt_next_offset[modseq] = file->sync_offset;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
294 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
295
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
296 /* mail_transaction_log_file_get_highest_modseq_at() is simultaneously
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
297 tested and it can also add offsets to cache. The difference is that
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
298 it adds the highest possible offset, while
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
299 mail_transaction_log_file_get_modseq_next_offset() adds the lowest
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
300 possible offset. So we'll need to allow both. */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
301 #define MODSEQ_MATCH(modseq, next_offset) \
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
302 ((next_offset) == modseq_next_offset[modseq] || \
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
303 (next_offset) == modseq_alt_next_offset[modseq])
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
304
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
305 /* 1) mail_transaction_log_file_get_modseq_next_offset() tests */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
306 uint64_t modseq;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
307 uoff_t next_offset;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
308 /* initial_modseq fast path */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
309 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 1, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
310 test_assert(next_offset == modseq_next_offset[1]);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
311 /* sync_highest_modseq fast path - it skips to sync_offset instead of
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
312 using exactly the same max_modseq */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
313 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, max_modseq, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
314 test_assert(next_offset == file->sync_offset);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
315 test_assert(next_offset != modseq_next_offset[max_modseq]);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
316 /* update the offset for the random tests */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
317 modseq_next_offset[max_modseq] = file->sync_offset;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
318 /* add to cache */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
319 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 2, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
320 test_assert(MODSEQ_MATCH(2, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
321 /* get it from cache */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
322 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 2, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
323 test_assert(MODSEQ_MATCH(2, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
324 /* get next value from cache */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
325 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 3, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
326 test_assert(MODSEQ_MATCH(3, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
327 /* get previous value from cache again */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
328 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 2, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
329 test_assert(MODSEQ_MATCH(2, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
330 /* do some random testing with cache */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
331 for (unsigned int i = 0; i < LOG_FILE_MODSEQ_CACHE_SIZE*10; i++) {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
332 modseq = (rand() % max_modseq) + 1;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
333 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, modseq, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
334 test_assert(MODSEQ_MATCH(modseq, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
335 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
336 /* go through all modseqs - do this after randomness testing or
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
337 modseq_alt_next_offset[] matching isn't triggered */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
338 for (modseq = 1; modseq <= max_modseq; modseq++) {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
339 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, modseq, &next_offset) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
340 test_assert(MODSEQ_MATCH(modseq, next_offset));
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
341 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
342
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
343 /* 2) mail_transaction_log_file_get_highest_modseq_at() tests */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
344 uint64_t modseq_at;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
345 const char *error;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
346 /* initial_offset */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
347 test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_next_offset[1], &modseq, &error) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
348 test_assert(modseq == 1);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
349 /* sync_offset fast path */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
350 test_assert(mail_transaction_log_file_get_highest_modseq_at(file, file->sync_offset, &modseq, &error) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
351 test_assert(modseq == max_modseq);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
352 /* do some random testing with cache */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
353 for (unsigned int i = 0; i < LOG_FILE_MODSEQ_CACHE_SIZE*10; i++) {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
354 modseq = (rand() % max_modseq) + 1;
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
355 test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_next_offset[modseq], &modseq_at, &error) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
356 test_assert(modseq_at == modseq);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
357 test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_alt_next_offset[modseq], &modseq_at, &error) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
358 test_assert(modseq_at == modseq);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
359 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
360 /* go through all modseqs - do this after randomness testing or
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
361 modseq_alt_next_offset[] matching isn't triggered */
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
362 for (modseq = 1; modseq <= max_modseq; modseq++) {
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
363 test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_next_offset[modseq], &modseq_at, &error) == 0);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
364 test_assert(modseq_at == modseq);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
365 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
366
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
367 mail_index_close(index);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
368 mail_index_free(&index);
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
369 test_end();
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
370 }
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
371
22430
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
372 static void
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
373 test_mail_transaction_log_file_get_modseq_next_offset_inconsistency(void)
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
374 {
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
375 test_begin("mail_transaction_log_file_get_modseq_next_offset() inconsistency");
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
376
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
377 struct mail_index *index = test_mail_index_open();
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
378 struct mail_transaction_log_file *file = index->log->head;
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
379 uint32_t seq;
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
380
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
381 /* add modseq=2 */
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
382 struct mail_index_view *view = mail_index_view_open(index);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
383 struct mail_index_transaction *trans =
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
384 mail_index_transaction_begin(view, 0);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
385 mail_index_append(trans, 1, &seq);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
386 test_assert(mail_index_transaction_commit(&trans) == 0);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
387 mail_index_view_close(&view);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
388
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
389 /* emulate a broken mail_index_modseq_header header */
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
390 file->sync_highest_modseq = 3;
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
391
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
392 uoff_t next_offset;
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
393 test_expect_error_string("Transaction log modseq tracking is corrupted");
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
394 test_assert(mail_transaction_log_file_get_modseq_next_offset(file, 2, &next_offset) == 0);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
395 test_expect_no_more_errors();
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
396 test_assert(next_offset == file->sync_offset);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
397
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
398 mail_index_close(index);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
399 mail_index_free(&index);
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
400 test_end();
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
401 }
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
402
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
403 int main(void)
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
404 {
22441
31ab1147d15d lib-index: Fix compiler warning in test-mail-transaction-log-file
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22430
diff changeset
405 static void (*test_functions[])(void) = {
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
406 test_mail_transaction_update_modseq,
22428
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
407 test_mail_transaction_log_file_modseq_offsets,
22430
2d9175af5c99 lib-index: Fix wrong mail_index_modseq_header automatically
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22428
diff changeset
408 test_mail_transaction_log_file_get_modseq_next_offset_inconsistency,
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
409 NULL
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
410 };
22428
7d95eafa16f7 lib-index: Add unit tests to mail_transaction_log_file_get_modseq_next_offset() and _get_highest_modseq_at()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 22427
diff changeset
411 ioloop_time = 1;
22427
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
412 return test_run(test_functions);
6a1d53479c46 lib-index: Add unit test to mail_transaction_update_modseq()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
413 }