test-mail-index-sync-ext.c revision d7c8280f58292cc292eba9209dcc9024fe96cf06
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenvoid mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx ATTR_UNUSED,
2cd2518bab14292a67cf8a490b58ab9ef89879daTimo Sirainenmail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx) { return ctx->view->map; }
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenmail_index_map_register_ext(struct mail_index_map *map ATTR_UNUSED,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen const char *name ATTR_UNUSED, uint32_t ext_offset ATTR_UNUSED,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen const struct mail_index_ext_header *ext_hdr ATTR_UNUSED) { return 0; }
6ec925f52d04ec8700e47cb005bd7ddc65ac5614Timo Sirainenbool mail_index_ext_lookup(struct mail_index *index ATTR_UNUSED,
4d4d6d4745682790c20d759ba93dbea46b812c5dTimo Sirainen uint32_t *ext_id_r ATTR_UNUSED) { return FALSE; }
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenbool mail_index_map_lookup_ext(struct mail_index_map *map ATTR_UNUSED,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen uint32_t *idx_r ATTR_UNUSED) { return FALSE; }
cf2e6953d03a1c22f272ec19432fc03c136ac1bbTimo Sirainenint mail_index_map_ext_hdr_check(const struct mail_index_header *hdr ATTR_UNUSED,
5d4c793b4e3dbc07f08daa4465594b1857f80725Timo Sirainen const struct mail_index_ext_header *ext_hdr ATTR_UNUSED,
6c2ce1d5bf17b21e804a079eb0f973b7ab83e0d8Timo Sirainen const char **error_r ATTR_UNUSED) { return -1; }
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenvoid mail_index_modseq_hdr_update(struct mail_index_modseq_sync *ctx ATTR_UNUSED) {}
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenbool mail_index_lookup_seq(struct mail_index_view *view ATTR_UNUSED,
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainenstatic void test_mail_index_sync_ext_atomic_inc(void)
5d4c793b4e3dbc07f08daa4465594b1857f80725Timo Sirainen ctx.view->map = t_new(struct mail_index_map, 1);
5d4c793b4e3dbc07f08daa4465594b1857f80725Timo Sirainen ctx.view->map->hdr.record_size = sizeof(struct mail_index_record) + 16;
5d4c793b4e3dbc07f08daa4465594b1857f80725Timo Sirainen ctx.view->map->rec_map = t_new(struct mail_index_record_map, 1);
5d4c793b4e3dbc07f08daa4465594b1857f80725Timo Sirainen ext = array_append_space(&ctx.view->map->extensions);
78fa3c578c14ee8a612f86cf73b6181c7f16463fTimo Sirainen ext->record_offset = sizeof(struct mail_index_record);
cf0ad1a0bddb0787f3d7b408a96d721a8b2a98a3Timo Sirainen ptr = PTR_OFFSET(ctx.view->map->rec_map->records, ext->record_offset);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen memset(&u, 0, sizeof(u));
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen test_assert(mail_index_sync_ext_atomic_inc(&ctx, &u) == -1);
71056e0f5e1f68cb9ac002a7827eb98435c40d62Timo Sirainen test_assert(mail_index_sync_ext_atomic_inc(&ctx, &u) == -1);
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen#define TEST_ATOMIC(_type, _value, _diff, _ret) \
d176f84ce5ca2073f4dfbafb457b9c74f6bf0d76Timo Sirainen test_assert(mail_index_sync_ext_atomic_inc(&ctx, &u) == _ret);
e9ac518aaf49a06d976bf7f24ab14a3e2d6d86abTimo Sirainen test_assert(mail_index_sync_ext_atomic_inc(&ctx, &u) == -1);
78fa3c578c14ee8a612f86cf73b6181c7f16463fTimo Sirainen static void (*test_functions[])(void) = {