From a52720a9213d760bb8a9c21b354ab46de7b763dd Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 4 Sep 2002 08:13:38 +0000 Subject: clear nonfatal stuff. 2002-09-04 Not Zed * tests/folder/test4.c (main): clear nonfatal stuff. * tests/folder/test6.c (main): check inbox and 'another folder' because some servers do different things w/ inbox. * providers/imap/camel-imap-message-cache.c (camel_imap_message_cache_get): Dont try to open the directory instead of an empty "" uid. * providers/imap/camel-imap-folder.c (imap_get_message): we dont want to g_return_if_fail, we need to set an exception and always handle the case. (get_message_simple): Set an exception if we get a construct failure. (imap_refresh_info): if we're refreshing inbox, force a reselect. this is required for at least cryus. CHECK doesnt work either :( * tests/lib/folders.c (test_folder_basic): for non-local stores, the folder will have an extra ref for selection, take this into account when checking ref leaks. (test_folder_message_ops): Dont try to delete folder with messages in it, it works generally with imap. also, change params so we can test different mailbox types. (test_folder_message_ops): disconnect remote services before finishing off. doesn't need to stricly but makes ref count checking more accurate. (test_folder_message_ops): removed explicit remote sync, imap does it itself now ... * providers/imap/camel-imap-store.c: (camel_imap_store_finalize): call service_disconnect, so it isn't called later in the finalise chain, to properly cleanup on exit. svn path=/trunk/; revision=17962 --- camel/tests/folder/test2.c | 4 +- camel/tests/folder/test4.c | 4 +- camel/tests/folder/test6.c | 5 ++- camel/tests/folder/test7.c | 2 +- camel/tests/lib/folders.c | 94 ++++++++++++++++++++++++++++++++++------------ camel/tests/lib/folders.h | 2 +- 6 files changed, 78 insertions(+), 33 deletions(-) (limited to 'camel/tests') diff --git a/camel/tests/folder/test2.c b/camel/tests/folder/test2.c index 50a89f89e8..afd35b1704 100644 --- a/camel/tests/folder/test2.c +++ b/camel/tests/folder/test2.c @@ -44,12 +44,12 @@ int main(int argc, char **argv) for (i=0;i @@ -44,7 +44,8 @@ int main(int argc, char **argv) _exit(77); } /*camel_test_nonfatal("The IMAP code is just rooted");*/ - test_folder_message_ops(session, path, FALSE); + test_folder_message_ops(session, path, FALSE, "testbox"); + test_folder_message_ops(session, path, FALSE, "INBOX"); /*camel_test_fatal();*/ } diff --git a/camel/tests/folder/test7.c b/camel/tests/folder/test7.c index 2f08712e4c..3dee12916d 100644 --- a/camel/tests/folder/test7.c +++ b/camel/tests/folder/test7.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) _exit(77); } camel_test_nonfatal("Dont know how many tests apply to NNTP"); - test_folder_message_ops(session, path, FALSE); + test_folder_message_ops(session, path, FALSE, "testbox"); camel_test_fatal(); } diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c index e7de6b2397..a670576564 100644 --- a/camel/tests/lib/folders.c +++ b/camel/tests/lib/folders.c @@ -146,19 +146,24 @@ test_folder_not_message(CamelFolder *folder, const char *uid) CamelException *ex = camel_exception_new(); int found; - push("uid %s is not in folder", uid); + push("uid '%s' is not in folder", uid); /* first try getting info */ + push("no message info"); info = camel_folder_get_message_info(folder, uid); check(info == NULL); + pull(); /* then, getting message */ + push("no message"); msg = camel_folder_get_message(folder, uid, ex); check(camel_exception_is_set(ex)); check(msg == NULL); camel_exception_clear(ex); + pull(); /* see if it is not in the summary (only once) */ + push("not in summary list"); s = camel_folder_get_summary(folder); check(s != NULL); found = 0; @@ -169,8 +174,10 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_summary(folder, s); + pull(); /* check it is not in the uid list */ + push("not in uid list"); s = camel_folder_get_uids(folder); check(s != NULL); found = 0; @@ -180,6 +187,7 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_uids(folder, s); + pull(); camel_exception_free(ex); @@ -215,7 +223,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s } else { check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + check_unref(folder, 2); } pull(); @@ -231,14 +239,20 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("getting an existing folder"); folder = camel_store_get_folder(store, "testbox", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("renaming a non-existant folder"); @@ -263,7 +277,10 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox2", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); } @@ -298,7 +315,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s /* todo: cross-check everything with folder_info checks as well */ /* this should probably take a folder instead of a session ... */ void -test_folder_message_ops(CamelSession *session, const char *name, int local, int spool) +test_folder_message_ops(CamelSession *session, const char *name, int local, const char *mailbox) { CamelStore *store; CamelException *ex = camel_exception_new(); @@ -308,12 +325,6 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int int indexed, max; GPtrArray *uids; CamelMessageInfo *info; - char *mailbox; - - if (spool) - mailbox = "INBOX"; - else - mailbox = "testbox"; max=local?2:1; @@ -336,6 +347,16 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int else flags = CAMEL_STORE_FOLDER_CREATE; folder = camel_store_get_folder(store, mailbox, flags, ex); + + /* we can't create mailbox outside of namespace, since we have no api for it, try + using inbox namespace, works for courier */ + if (folder == NULL) { + char *mbox = g_strdup_printf("INBOX/%s", mailbox); + mailbox = mbox; + camel_exception_clear(ex); + folder = camel_store_get_folder(store, mailbox, flags, ex); + } + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); @@ -361,6 +382,7 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_append_message(folder, msg, NULL, NULL, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); +#if 0 /* sigh, this shouldn't be required, but the imap code is too dumb to do it itself */ if (!local) { push("forcing a refresh of folder updates"); @@ -368,44 +390,56 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } - - if (!local) - camel_test_nonfatal("unread counts dont seem right for imap"); +#endif + /*if (!local) + camel_test_nonfatal("unread counts dont seem right for imap");*/ test_folder_counts(folder, j+1, j+1); - if (!local) - camel_test_fatal(); + /*if (!local) + camel_test_fatal();*/ push("checking it is in the right uid slot & exists"); uids = camel_folder_get_uids(folder); check(uids != NULL); check(uids->len == j+1); - test_folder_message(folder, uids->pdata[j]); + if (uids->len > j) + test_folder_message(folder, uids->pdata[j]); pull(); push("checking it is the right message (subject): %s", subject); - info = camel_folder_get_message_info(folder, uids->pdata[j]); - check_msg(strcmp(camel_message_info_subject(info), subject)==0, - "info->subject %s", camel_message_info_subject(info)); + if (uids->len > j) { + info = camel_folder_get_message_info(folder, uids->pdata[j]); + check(info != NULL); + check_msg(strcmp(camel_message_info_subject(info), subject)==0, + "info->subject %s", camel_message_info_subject(info)); + camel_folder_free_message_info(folder, info); + } camel_folder_free_uids(folder, uids); - camel_folder_free_message_info(folder, info); pull(); test_free(subject); + /*if (!local) + camel_test_fatal();*/ + check_unref(msg, 1); pull(); } - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); +#if 0 push("deleting test folder, with messages in it"); camel_store_delete_folder(store, mailbox, ex); check(camel_exception_is_set(ex)); camel_exception_clear(ex); pull(); +#endif push("re-opening folder"); folder = camel_store_get_folder(store, mailbox, flags, ex); @@ -506,16 +540,26 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_free_uids(folder, uids); pull(); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); /* re-opening folder */ - if (!spool) { + if (strcasecmp(mailbox, "INBOX") != 0) { push("deleting test folder, with no messages in it"); camel_store_delete_folder(store, mailbox, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } + if (!local) { + push("disconneect service"); + camel_service_disconnect((CamelService *)store, TRUE, ex); + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); + pull(); + } + check_unref(store, 1); camel_test_end(); } diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h index d3c9686dc2..ae981611d3 100644 --- a/camel/tests/lib/folders.h +++ b/camel/tests/lib/folders.h @@ -17,4 +17,4 @@ void test_folder_not_message(CamelFolder *folder, const char *uid); /* test basic folder ops on a store */ void test_folder_basic(CamelSession *session, const char *storename, int local, int spool); /* test basic message operations on a folder */ -void test_folder_message_ops(CamelSession *session, const char *storename, int local, int spool); +void test_folder_message_ops(CamelSession *session, const char *storename, int local, const char *foldername); -- cgit