dovecot-2.2: lib-index: test suite memory leak cleanup
dovecot at dovecot.org
dovecot at dovecot.org
Wed Sep 10 11:11:51 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/f0701f84ca01
changeset: 17781:f0701f84ca01
user: Phil Carmody <phil at dovecot.fi>
date: Wed Sep 10 14:08:58 2014 +0300
description:
lib-index: test suite memory leak cleanup
So that memory leak checkers can be active while running the test
suites, ensure that the suite itself doesn't leak.
Signed-off-by: Phil Carmody <phil at dovecot.fi>
diffstat:
src/lib-index/test-mail-index-transaction-finish.c | 1 +
src/lib-index/test-mail-index-transaction-update.c | 32 ++++++++++++++++++++++
src/lib-index/test-mail-transaction-log-append.c | 4 ++
src/lib-index/test-mail-transaction-log-view.c | 18 +++++++++++-
4 files changed, 54 insertions(+), 1 deletions(-)
diffs (195 lines):
diff -r c749a40eda0a -r f0701f84ca01 src/lib-index/test-mail-index-transaction-finish.c
--- a/src/lib-index/test-mail-index-transaction-finish.c Wed Sep 10 14:08:58 2014 +0300
+++ b/src/lib-index/test-mail-index-transaction-finish.c Wed Sep 10 14:08:58 2014 +0300
@@ -152,6 +152,7 @@
test_assert(conflicts[1].seq1 == 8 && conflicts[1].seq2 == 8);
test_end();
+ array_free(t->conflict_seqs);
}
static void test_mail_index_transaction_finish_modseq_updates(void)
diff -r c749a40eda0a -r f0701f84ca01 src/lib-index/test-mail-index-transaction-update.c
--- a/src/lib-index/test-mail-index-transaction-update.c Wed Sep 10 14:08:58 2014 +0300
+++ b/src/lib-index/test-mail-index-transaction-update.c Wed Sep 10 14:08:58 2014 +0300
@@ -70,6 +70,17 @@
t->first_new_seq = hdr.messages_count + 1;
return t;
}
+static void mail_index_transaction_cleanup(struct mail_index_transaction *t)
+{
+ if (array_is_created(&t->appends))
+ array_free(&t->appends);
+ if (array_is_created(&t->updates))
+ array_free(&t->updates);
+ if (array_is_created(&t->modseq_updates))
+ array_free(&t->modseq_updates);
+ if (array_is_created(&t->expunges))
+ array_free(&t->expunges);
+}
static void test_mail_index_append(void)
{
@@ -103,6 +114,7 @@
test_assert(appends[1].uid == 124);
test_assert(appends[1].flags == 0);
test_end();
+ mail_index_transaction_cleanup(t);
/* test with some uids */
t = mail_index_transaction_new();
@@ -138,6 +150,8 @@
test_assert(appends[3].uid == 131);
test_assert(appends[4].uid == 128);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_flag_update_fastpath(void)
@@ -178,6 +192,8 @@
test_assert(updates[1].remove_flags == 0);
test_assert(!t->log_updates);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_flag_update_simple_merges(void)
@@ -221,6 +237,8 @@
test_assert(updates[0].uid1 == 4);
test_assert(updates[0].uid2 == 12);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_flag_update_complex_merges(void)
@@ -279,6 +297,8 @@
test_assert(updates[6].remove_flags == 0);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void
@@ -353,6 +373,8 @@
flags_array_check(t, flags, hdr.messages_count);
}
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_cancel_flag_updates(void)
@@ -385,6 +407,8 @@
test_assert(updates[1].uid1 == 7 && updates[1].uid2 == 7);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_flag_update_appends(void)
@@ -430,6 +454,8 @@
test_assert(updates[0].uid2 == 4);
test_assert(updates[0].add_flags == MAIL_ANSWERED);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static bool test_flag_update_pos(struct mail_index_transaction *t,
@@ -475,6 +501,8 @@
test_assert(test_flag_update_pos(t, 11, 4));
test_assert(test_flag_update_pos(t, 12, 4));
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_modseq_update(void)
@@ -511,6 +539,8 @@
ups[3].modseq_high32 == 0 &&
ups[3].modseq_low32 == 2);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
static void test_mail_index_expunge(void)
@@ -553,6 +583,8 @@
test_assert(memcmp(expunges[4].guid_128, empty_guid, sizeof(empty_guid)) == 0);
test_end();
+
+ mail_index_transaction_cleanup(t);
}
int main(void)
diff -r c749a40eda0a -r f0701f84ca01 src/lib-index/test-mail-transaction-log-append.c
--- a/src/lib-index/test-mail-transaction-log-append.c Wed Sep 10 14:08:58 2014 +0300
+++ b/src/lib-index/test-mail-transaction-log-append.c Wed Sep 10 14:08:58 2014 +0300
@@ -157,6 +157,10 @@
file->fd = -1;
test_end();
+ buffer_free(&log->head->buffer);
+ i_free(log->head);
+ i_free(log->index);
+ i_free(log);
unlink(tmp_path);
}
diff -r c749a40eda0a -r f0701f84ca01 src/lib-index/test-mail-transaction-log-view.c
--- a/src/lib-index/test-mail-transaction-log-view.c Wed Sep 10 14:08:58 2014 +0300
+++ b/src/lib-index/test-mail-transaction-log-view.c Wed Sep 10 14:08:58 2014 +0300
@@ -71,8 +71,10 @@
/* files must be sorted by file_seq */
for (p = &log->files; *p != NULL; p = &(*p)->next) {
- if ((*p)->hdr.file_seq > file->hdr.file_seq)
+ if ((*p)->hdr.file_seq > file->hdr.file_seq) {
+ file->next = *p;
break;
+ }
}
*p = file;
log->head = file;
@@ -119,6 +121,7 @@
const struct mail_index_record *rec;
struct mail_index_record append_rec;
const void *data;
+ void *oldfile;
uint32_t seq;
uoff_t offset, last_log_size;
bool reset;
@@ -186,7 +189,10 @@
mail_transaction_log_view_clear(view, 2);
test_assert(!view_is_file_refed(1) && view_is_file_refed(2) &&
view_is_file_refed(3));
+ oldfile = log->files;
+ buffer_free(&log->files->buffer);
log->files = log->files->next;
+ i_free(oldfile);
test_assert(log->files->hdr.file_seq == 2);
test_end();
@@ -205,6 +211,16 @@
test_assert(mail_transaction_log_view_set(view, 0, 0, (uint32_t)-1, (uoff_t)-1, &reset) == -1);
view->log = log;
test_end();
+
+ mail_transaction_log_view_close(&view);
+ i_free(log->index);
+ while (log->files != NULL) {
+ oldfile = log->files;
+ buffer_free(&log->files->buffer);
+ log->files = log->files->next;
+ i_free(oldfile);
+ }
+ i_free(log);
}
int main(void)
More information about the dovecot-cvs
mailing list