bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
0f5dc4da3982053036be65190e44bf28a67b1ca2Timo Sirainenbool mail_user_hash(const char *username ATTR_UNUSED,
0f5dc4da3982053036be65190e44bf28a67b1ca2Timo Sirainen unsigned int *hash_r, const char **error_r ATTR_UNUSED)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenverify_user_directory(struct user_directory *dir, unsigned int user_count)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen while ((user = user_directory_iter_next(iter)) != NULL) {
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen test_assert(prev == NULL || user->prev->next == user);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen test_assert(prev == NULL || prev->next == NULL);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenstatic void test_user_directory_ascending(void)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen unsigned int i;
de92873c366becfaea1554642f89b9169d7955e2Timo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, NULL);
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, 1, host, ioloop_time + count+1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++)
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+2, host, ioloop_time + i);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenstatic void test_user_directory_descending(void)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen unsigned int i;
de92873c366becfaea1554642f89b9169d7955e2Timo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, NULL);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++)
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+1, host, ioloop_time - i);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
191153d1a5b0eb0c129139570e3aa5212f28d2acJosef 'Jeff' Sipek unsigned int i, count = i_rand_minmax(10000, 19999);
de92873c366becfaea1554642f89b9169d7955e2Timo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, NULL);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++) {
191153d1a5b0eb0c129139570e3aa5212f28d2acJosef 'Jeff' Sipek timestamp = ioloop_time-i_rand_limit(100);
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+1, host, timestamp);
baf3e87e186453fda13bd21f7cbcb2efc8492e8bTimo Sirainen static void (*const test_functions[])(void) = {