diff options
Diffstat (limited to 'camel/tests/folder')
-rw-r--r-- | camel/tests/folder/.cvsignore | 21 | ||||
-rw-r--r-- | camel/tests/folder/Makefile.am | 29 | ||||
-rw-r--r-- | camel/tests/folder/README | 11 | ||||
-rw-r--r-- | camel/tests/folder/test1.c | 50 | ||||
-rw-r--r-- | camel/tests/folder/test2.c | 58 | ||||
-rw-r--r-- | camel/tests/folder/test3.c | 335 | ||||
-rw-r--r-- | camel/tests/folder/test4.c | 53 | ||||
-rw-r--r-- | camel/tests/folder/test5.c | 53 | ||||
-rw-r--r-- | camel/tests/folder/test6.c | 55 | ||||
-rw-r--r-- | camel/tests/folder/test7.c | 55 | ||||
-rw-r--r-- | camel/tests/folder/test8.c | 215 | ||||
-rw-r--r-- | camel/tests/folder/test9.c | 227 |
12 files changed, 0 insertions, 1162 deletions
diff --git a/camel/tests/folder/.cvsignore b/camel/tests/folder/.cvsignore deleted file mode 100644 index 26eaf2f7e1..0000000000 --- a/camel/tests/folder/.cvsignore +++ /dev/null @@ -1,21 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -temp-test -*.bb -*.bbg -*.da -*.gcov -test1 -test2 -test3 -test4 -test5 -test6 -test7 -test8 -test9 diff --git a/camel/tests/folder/Makefile.am b/camel/tests/folder/Makefile.am deleted file mode 100644 index 143fd7f4ad..0000000000 --- a/camel/tests/folder/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ - -INCLUDES = -I$(top_srcdir)/intl -I$(top_srcdir) -I$(top_srcdir)/camel \ - -I$(includedir) \ - -I$(top_srcdir)/camel/tests/lib \ - -DG_LOG_DOMAIN=\"evolution-tests\" - -LDADD = \ - $(top_builddir)/camel/libcamel.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libibex/libibex.la \ - $(GNOME_LIBDIR) \ - $(top_builddir)/camel/tests/lib/libcameltest.a \ - $(GNOMEUI_LIBS) $(INTLLIBS) $(EVOLUTION_MAIL_LIBS) - -check_PROGRAMS = \ - test1 test4 test5 \ - test2 test6 test7 \ - test3 \ - test8 \ - test9 - -TESTS = test1 test4 test5 \ - test2 test6 test7 \ - test3 \ - test8 \ - test9 - - - diff --git a/camel/tests/folder/README b/camel/tests/folder/README deleted file mode 100644 index 4fed421413..0000000000 --- a/camel/tests/folder/README +++ /dev/null @@ -1,11 +0,0 @@ - -test1 camel store folder operations (local only) -test2 basic folder operations, local -test3 folder searching and indexing, local -test4 camel store folder operations, IMAP -test5 camel store folder operations, NNTP -test6 basic folder operations, IMAP -test7 basic folder operations, NNTP - -test8 multithreaded folder torture test, local -test9 filtering diff --git a/camel/tests/folder/test1.c b/camel/tests/folder/test1.c deleted file mode 100644 index c1d3809852..0000000000 --- a/camel/tests/folder/test1.c +++ /dev/null @@ -1,50 +0,0 @@ -/* store testing */ - -#include "camel-test.h" -#include "folders.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *local_providers[] = { - "mbox", - "mh", - "maildir" -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - char *path; - - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* todo: cross-check everything with folder_info checks as well */ - /* todo: subscriptions? */ - /* todo: work out how to do imap/pop/nntp tests */ - for (i=0;i<ARRAY_LEN(local_providers);i++) { - path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[i], local_providers[i]); - - test_folder_basic(session, path, TRUE, FALSE); - - g_free(path); - } - - camel_object_unref((CamelObject *)session); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test2.c b/camel/tests/folder/test2.c deleted file mode 100644 index 50a89f89e8..0000000000 --- a/camel/tests/folder/test2.c +++ /dev/null @@ -1,58 +0,0 @@ -/* folder testing */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#include "camel-test.h" -#include "messages.h" -#include "folders.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#include <camel/camel-folder.h> -#include <camel/camel-folder-summary.h> -#include <camel/camel-mime-message.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *stores[] = { - "mbox:///tmp/camel-test/mbox", - "mh:///tmp/camel-test/mh", - "maildir:///tmp/camel-test/maildir" -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - - camel_test_init(argc, argv); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - ex = camel_exception_new(); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* we iterate over all stores we want to test, with indexing or indexing turned on or off */ - for (i=0;i<ARRAY_LEN(stores);i++) { - char *name = stores[i]; - - test_folder_message_ops(session, name, TRUE, FALSE); - } - - /* create a pseudo-spool file, and check that */ - creat("/tmp/camel-test/testbox", 0600); - test_folder_message_ops(session, "spool:///tmp/camel-test/testbox", FALSE, TRUE); - - check_unref(session, 1); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test3.c b/camel/tests/folder/test3.c deleted file mode 100644 index dc2946956f..0000000000 --- a/camel/tests/folder/test3.c +++ /dev/null @@ -1,335 +0,0 @@ -/* folder/index testing */ - -#include <gtk/gtk.h> - -#include "camel-test.h" -#include "messages.h" -#include "folders.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#include <camel/camel-folder.h> -#include <camel/camel-folder-summary.h> -#include <camel/camel-mime-message.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static void -test_folder_search_sub(CamelFolder *folder, const char *expr, int expected) -{ - CamelException *ex = camel_exception_new(); - GPtrArray *uids; - GHashTable *hash; - int i; - - uids = camel_folder_search_by_expression(folder, expr, ex); - check(uids != NULL); - check_msg(uids->len == expected, "search %s expected %d got %d", expr, expected, uids->len); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - - /* check the uid's are actually unique, too */ - hash = g_hash_table_new(g_str_hash, g_str_equal); - for (i=0;i<uids->len;i++) { - check(g_hash_table_lookup(hash, uids->pdata[i]) == NULL); - g_hash_table_insert(hash, uids->pdata[i], uids->pdata[i]); - } - g_hash_table_destroy(hash); - - camel_folder_search_free(folder, uids); - - camel_exception_free(ex); -} - -static void -test_folder_search(CamelFolder *folder, const char *expr, int expected) -{ - char *matchall; - -#if 0 - /* FIXME: ??? */ - camel_test_nonfatal("most searches require match-all construct"); - push("Testing search: %s", expr); - test_folder_search_sub(folder, expr, expected); - pull(); - camel_test_fatal(); -#endif - - matchall = g_strdup_printf("(match-all %s)", expr); - push("Testing search: %s", matchall); - test_folder_search_sub(folder, matchall, expected); - test_free(matchall); - pull(); -} - -static struct { - int counts[3]; - char *expr; -} searches[] = { - { { 1, 1, 0 }, "(header-matches \"subject\" \"Test1 message99 subject\")" }, - - { { 100, 50, 0 }, "(header-contains \"subject\" \"subject\")" }, - { { 0, 0, 0 }, "(header-contains \"subject\" \"Subject\")" }, - - { { 100, 50, 0 }, "(body-contains \"content\")" }, - { { 100, 50, 0 }, "(body-contains \"Content\")" }, - - { { 0, 0, 0 }, "(user-flag \"every7\")" }, - { { 100/13+1, 50/13+1, 0 }, "(user-flag \"every13\")" }, - { { 1, 1, 0 }, "(= \"7tag1\" (user-tag \"every7\"))" }, - { { 100/11+1, 50/11+1, 0 }, "(= \"11tag\" (user-tag \"every11\"))" }, - - { { 100/13 + 100/17 + 1, 50/13 + 50/17 + 2, 0 }, "(user-flag \"every13\" \"every17\")" }, - { { 100/13 + 100/17 + 1, 50/13 + 50/17 + 2, 0 }, "(or (user-flag \"every13\") (user-flag \"every17\"))" }, - { { 1, 0, 0 }, "(and (user-flag \"every13\") (user-flag \"every17\"))" }, - - { { 0, 0, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"Test2\"))" }, - /* we get 11 here as the header-contains is a substring match */ - { { 11, 6, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))" }, - { { 1, 1, 0 }, "(and (header-contains \"subject\" \"Test19\") (header-contains \"subject\" \"subject\"))" }, - { { 0, 0, 0 }, "(and (header-contains \"subject\" \"Test191\") (header-contains \"subject\" \"subject\"))" }, - { { 1, 1, 0 }, "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"message99\"))" }, - - { { 22, 11, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"Test2\"))" }, - { { 2, 1, 0 }, "(or (header-contains \"subject\" \"Test16\") (header-contains \"subject\" \"Test99\"))" }, - { { 1, 1, 0 }, "(or (header-contains \"subject\" \"Test123\") (header-contains \"subject\" \"Test99\"))" }, - { { 100, 50, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))" }, - { { 11, 6, 0 }, "(or (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"message99\"))" }, - - /* 72000 is 24*60*100 == half the 'sent date' of the messages */ - { { 100/2, 50/2, 0 }, "(> 72000 (get-sent-date))" }, - { { 100/2-1, 50/2, 0 }, "(< 72000 (get-sent-date))" }, - { { 1, 0, 0 }, "(= 72000 (get-sent-date))" }, - { { 0, 0, 0 }, "(= 72001 (get-sent-date))" }, - - { { (100/2-1)/17+1, (50/2-1)/17+1, 0 }, "(and (user-flag \"every17\") (< 72000 (get-sent-date)))" }, - { { (100/2-1)/17+1, (50/2-1)/17, 0 }, "(and (user-flag \"every17\") (> 72000 (get-sent-date)))" }, - { { (100/2-1)/13+1, (50/2-1)/13+1, 0 }, "(and (user-flag \"every13\") (< 72000 (get-sent-date)))" }, - { { (100/2-1)/13+1, (50/2-1)/13+1, 0 }, "(and (user-flag \"every13\") (> 72000 (get-sent-date)))" }, - - { { 100/2+100/2/17, 50/2+50/2/17, 0 }, "(or (user-flag \"every17\") (< 72000 (get-sent-date)))" }, - { { 100/2+100/2/17+1, 50/2+50/2/17+1, 0 }, "(or (user-flag \"every17\") (> 72000 (get-sent-date)))" }, - { { 100/2+100/2/13, 50/2+50/2/13+1, 0 }, "(or (user-flag \"every13\") (< 72000 (get-sent-date)))" }, - { { 100/2+100/2/13+1, 50/2+50/2/13+1, 0 }, "(or (user-flag \"every13\") (> 72000 (get-sent-date)))" }, -}; - -static void -run_search(CamelFolder *folder, int m) -{ - int i, j = 0; - - check(m == 50 || m == 100 || m == 0); - - /* *shrug* messy, but it'll do */ - if (m==50) - j = 1; - else if (m==0) - j = 2; - - push("performing searches, expected %d", m); - for (i=0;i<ARRAY_LEN(searches);i++) { - push("running search %d: %s", i, searches[i].expr); - test_folder_search(folder, searches[i].expr, searches[i].counts[j]); - pull(); - } - pull(); -} - - -static char *stores[] = { - "mbox:///tmp/camel-test/mbox", - "mh:///tmp/camel-test/mh", - "maildir:///tmp/camel-test/maildir" -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelStore *store; - CamelException *ex; - CamelFolder *folder; - CamelMimeMessage *msg; - int i, j; - int indexed; - GPtrArray *uids; - - gtk_init(&argc, &argv); - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* todo: cross-check everything with folder_info checks as well */ - /* todo: work out how to do imap/pop/nntp tests */ - - /* we iterate over all stores we want to test, with indexing or indexing turned on or off */ - for (i=0;i<ARRAY_LEN(stores);i++) { - char *name = stores[i]; - for (indexed = 0;indexed<2;indexed++) { - char *what = g_strdup_printf("folder search: %s (%sindexed)", name, indexed?"":"non-"); - int flags; - - camel_test_start(what); - test_free(what); - - push("getting store"); - store = camel_session_get_store(session, stores[i], ex); - check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex)); - check(store != NULL); - pull(); - - push("creating %sindexed folder", indexed?"":"non-"); - if (indexed) - flags = CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX; - else - flags = CAMEL_STORE_FOLDER_CREATE; - folder = camel_store_get_folder(store, "testbox", flags, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(folder != NULL); - - /* we need an empty folder for this to work */ - test_folder_counts(folder, 0, 0); - pull(); - - /* append a bunch of messages with specific content */ - push("appending 100 test messages"); - for (j=0;j<100;j++) { - char *content, *subject; - - push("creating test message"); - msg = test_message_create_simple(); - content = g_strdup_printf("data%d content\n", j); - test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain", - content, strlen(content)); - test_free(content); - subject = g_strdup_printf("Test%d message%d subject", j, 100-j); - camel_mime_message_set_subject(msg, subject); - - camel_mime_message_set_date(msg, j*60*24, 0); - pull(); - - push("appending simple message %d", j); - camel_folder_append_message(folder, msg, NULL, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - - test_free(subject); - - check_unref(msg, 1); - } - pull(); - - push("Setting up some flags &c"); - uids = camel_folder_get_uids(folder); - check(uids->len == 100); - for (j=0;j<100;j++) { - char *uid = uids->pdata[j]; - - if ((j/13)*13 == j) { - camel_folder_set_message_user_flag(folder, uid, "every13", TRUE); - } - if ((j/17)*17 == j) { - camel_folder_set_message_user_flag(folder, uid, "every17", TRUE); - } - if ((j/7)*7 == j) { - char *tag = g_strdup_printf("7tag%d", j/7); - camel_folder_set_message_user_tag(folder, uid, "every7", tag); - test_free(tag); - } - if ((j/11)*11 == j) { - camel_folder_set_message_user_tag(folder, uid, "every11", "11tag"); - } - } - camel_folder_free_uids(folder, uids); - pull(); - - push("Search before sync"); - run_search(folder, 100); - pull(); - - push("syncing folder, searching"); - camel_folder_sync(folder, FALSE, ex); - run_search(folder, 100); - pull(); - - push("syncing wiht expunge, search"); - camel_folder_sync(folder, TRUE, ex); - run_search(folder, 100); - pull(); - - push("deleting every 2nd message"); - uids = camel_folder_get_uids(folder); - check(uids->len == 100); - for (j=0;j<uids->len;j+=2) { - camel_folder_delete_message(folder, uids->pdata[j]); - } - camel_folder_free_uids(folder, uids); - run_search(folder, 100); - - push("syncing"); - camel_folder_sync(folder, FALSE, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - run_search(folder, 100); - pull(); - - push("expunging"); - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - run_search(folder, 50); - pull(); - - pull(); - - push("closing and re-opening folder"); - check_unref(folder, 1); - folder = camel_store_get_folder(store, "testbox", flags&~(CAMEL_STORE_FOLDER_CREATE), ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(folder != NULL); - - push("deleting remaining messages"); - uids = camel_folder_get_uids(folder); - check(uids->len == 50); - for (j=0;j<uids->len;j++) { - camel_folder_delete_message(folder, uids->pdata[j]); - } - camel_folder_free_uids(folder, uids); - run_search(folder, 50); - - push("syncing"); - camel_folder_sync(folder, FALSE, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - run_search(folder, 50); - pull(); - - push("expunging"); - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - run_search(folder, 0); - pull(); - - pull(); - - check_unref(folder, 1); - pull(); - - push("deleting test folder, with no messages in it"); - camel_store_delete_folder(store, "testbox", ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - - check_unref(store, 1); - camel_test_end(); - } - } - - check_unref(session, 1); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test4.c b/camel/tests/folder/test4.c deleted file mode 100644 index eb0bd3420b..0000000000 --- a/camel/tests/folder/test4.c +++ /dev/null @@ -1,53 +0,0 @@ -/* store testing, for remote folders */ - -#include "camel-test.h" -#include "folders.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *remote_providers[] = { - "IMAP_TEST_URL", -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - char *path; - - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* todo: cross-check everything with folder_info checks as well */ - /* todo: subscriptions? */ - for (i=0;i<ARRAY_LEN(remote_providers);i++) { - path = getenv(remote_providers[i]); - - if (path == NULL) { - printf("Aborted (ignored).\n"); - printf("Set '%s', to re-run test.\n", remote_providers[i]); - /* tells make check to ignore us in the total count */ - _exit(77); - } - camel_test_nonfatal("The IMAP code is just rooted"); - test_folder_basic(session, path, FALSE, FALSE); - camel_test_fatal(); - } - - camel_object_unref((CamelObject *)session); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test5.c b/camel/tests/folder/test5.c deleted file mode 100644 index ccdfb23b23..0000000000 --- a/camel/tests/folder/test5.c +++ /dev/null @@ -1,53 +0,0 @@ -/* store testing, for remote folders */ - -#include "camel-test.h" -#include "folders.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *remote_providers[] = { - "NNTP_TEST_URL", -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - char *path; - - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* todo: cross-check everything with folder_info checks as well */ - /* todo: subscriptions? */ - for (i=0;i<ARRAY_LEN(remote_providers);i++) { - path = getenv(remote_providers[i]); - - if (path == NULL) { - printf("Aborted (ignored).\n"); - printf("Set '%s', to re-run test.\n", remote_providers[i]); - /* tells make check to ignore us in the total count */ - _exit(77); - } - camel_test_nonfatal("Not sure how many tests apply to NNTP"); - test_folder_basic(session, path, FALSE, FALSE); - camel_test_fatal(); - } - - camel_object_unref((CamelObject *)session); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test6.c b/camel/tests/folder/test6.c deleted file mode 100644 index 215fa999bf..0000000000 --- a/camel/tests/folder/test6.c +++ /dev/null @@ -1,55 +0,0 @@ -/* folder testing */ - -#include "camel-test.h" -#include "messages.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#include <camel/camel-folder.h> -#include <camel/camel-folder-summary.h> -#include <camel/camel-mime-message.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *remote_providers[] = { - "IMAP_TEST_URL", -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - char *path; - - camel_test_init(argc, argv); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - ex = camel_exception_new(); - - session = camel_test_session_new ("/tmp/camel-test"); - - for (i=0;i<ARRAY_LEN(remote_providers);i++) { - path = getenv(remote_providers[i]); - - if (path == NULL) { - printf("Aborted (ignored).\n"); - printf("Set '%s', to re-run test.\n", remote_providers[i]); - /* tells make check to ignore us in the total count */ - _exit(77); - } - /*camel_test_nonfatal("The IMAP code is just rooted");*/ - test_folder_message_ops(session, path, FALSE); - /*camel_test_fatal();*/ - } - - check_unref(session, 1); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test7.c b/camel/tests/folder/test7.c deleted file mode 100644 index 2f08712e4c..0000000000 --- a/camel/tests/folder/test7.c +++ /dev/null @@ -1,55 +0,0 @@ -/* folder testing */ - -#include "camel-test.h" -#include "messages.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#include <camel/camel-folder.h> -#include <camel/camel-folder-summary.h> -#include <camel/camel-mime-message.h> - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *remote_providers[] = { - "NNTP_TEST_URL", -}; - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i; - char *path; - - camel_test_init(argc, argv); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - ex = camel_exception_new(); - - session = camel_test_session_new ("/tmp/camel-test"); - - for (i=0;i<ARRAY_LEN(remote_providers);i++) { - path = getenv(remote_providers[i]); - - if (path == NULL) { - printf("Aborted (ignored).\n"); - printf("Set '%s', to re-run test.\n", remote_providers[i]); - /* tells make check to ignore us in the total count */ - _exit(77); - } - camel_test_nonfatal("Dont know how many tests apply to NNTP"); - test_folder_message_ops(session, path, FALSE); - camel_test_fatal(); - } - - check_unref(session, 1); - camel_exception_free(ex); - - return 0; -} diff --git a/camel/tests/folder/test8.c b/camel/tests/folder/test8.c deleted file mode 100644 index cf8a7ecc8a..0000000000 --- a/camel/tests/folder/test8.c +++ /dev/null @@ -1,215 +0,0 @@ -/* threaded folder testing */ - -#include "camel-test.h" -#include "folders.h" -#include "messages.h" -#include "session.h" - -#include <camel/camel-exception.h> -#include <camel/camel-service.h> -#include <camel/camel-store.h> - -#define MAX_MESSAGES (100) -#define MAX_THREADS (10) - -#define d(x) - -#ifndef ENABLE_THREADS -int main(int argc, char **argv) -{ - printf("Test %s is only compiled with threads enabled\n", argv[0]); - return 77; -} -#else - -#include <pthread.h> - - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -static char *local_providers[] = { - "mbox", - "mh", - "maildir" -}; - -static void -test_add_message(CamelFolder *folder, int j) -{ - CamelMimeMessage *msg; - char *content; - char *subject; - CamelException ex; - - camel_exception_init(&ex); - - push("creating message %d\n", j); - msg = test_message_create_simple(); - content = g_strdup_printf("Test message %d contents\n\n", j); - test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain", - content, strlen(content)); - test_free(content); - subject = g_strdup_printf("Test message %d subject", j); - camel_mime_message_set_subject(msg, subject); - pull(); - - push("appending simple message %d", j); - camel_folder_append_message(folder, msg, NULL, &ex); - check_msg(!camel_exception_is_set(&ex), "%s", camel_exception_get_description(&ex)); - pull(); - - check_unref(msg, 1); -} - -struct _threadinfo { - int id; - CamelFolder *folder; -}; - -static void * -worker(void *d) -{ - struct _threadinfo *info = d; - int i, j, id = info->id; - char *sub, *content; - GPtrArray *res; - CamelException *ex = camel_exception_new(); - CamelMimeMessage *msg; - - /* we add a message, search for it, twiddle some flags, delete it */ - /* and flat out */ - for (i=0;i<MAX_MESSAGES;i++) { - d(printf("Thread %ld message %i\n", pthread_self(), i)); - test_add_message(info->folder, id+i); - - sub = g_strdup_printf("(match-all (header-contains \"subject\" \"message %d subject\"))", id+i); - - push("searching for message %d\n\tusing: %s", id+i, sub); - res = camel_folder_search_by_expression(info->folder, sub, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check_msg(res->len == 1, "res->len = %d", res->len); - pull(); - - push("getting message '%s'", res->pdata[0]); - msg = camel_folder_get_message(info->folder, (char *)res->pdata[0], ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - - push("comparing content"); - content = g_strdup_printf("Test message %d contents\n\n", id+i); - test_message_compare_content(camel_medium_get_content_object((CamelMedium *)msg), content, strlen(content)); - test_free(content); - pull(); - - push("deleting message, cleanup"); - j=(100.0*rand()/(RAND_MAX+1.0)); - if (j<=70) { - camel_folder_delete_message(info->folder, res->pdata[0]); - } - - camel_folder_search_free(info->folder, res); - res = NULL; - test_free(sub); - - check_unref(msg, 1); - pull(); - - /* about 1-in 100 calls will expunge */ - j=(200.0*rand()/(RAND_MAX+1.0)); - if (j<=2) { - d(printf("Forcing an expuge\n")); - push("expunging folder"); - camel_folder_expunge(info->folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - } - } - - camel_exception_free(ex); - - return info; -} - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelException *ex; - int i, j, index; - char *path; - CamelStore *store; - pthread_t threads[MAX_THREADS]; - struct _threadinfo *info; - CamelFolder *folder; - GPtrArray *uids; - - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_test_session_new ("/tmp/camel-test"); - - for (j=0;j<ARRAY_LEN(local_providers);j++) { - for (index=0;index<2;index++) { - path = g_strdup_printf("method %s %s", local_providers[j], index?"indexed":"nonindexed"); - camel_test_start(path); - test_free(path); - - push("trying %s index %d", local_providers[j], index); - path = g_strdup_printf("%s:///tmp/camel-test/%s", local_providers[j], local_providers[j]); - store = camel_session_get_store(session, path, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - test_free(path); - - if (index == 0) - folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex); - else - folder = camel_store_get_folder(store, "testbox", - CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_FOLDER_BODY_INDEX, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - - for (i=0;i<MAX_THREADS;i++) { - info = g_malloc(sizeof(*info)); - info->id = i*MAX_MESSAGES; - info->folder = folder; - pthread_create(&threads[i], 0, worker, info); - } - - for (i=0;i<MAX_THREADS;i++) { - pthread_join(threads[i], (void **)&info); - g_free(info); - } - pull(); - - push("deleting remaining messages"); - uids = camel_folder_get_uids(folder); - for (i=0;i<uids->len;i++) { - camel_folder_delete_message(folder, uids->pdata[i]); - } - camel_folder_free_uids(folder, uids); - - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - - check_unref(folder, 1); - - camel_store_delete_folder(store, "testbox", ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - - check_unref(store, 1); - - pull(); - - camel_test_end(); - } - } - - camel_object_unref((CamelObject *)session); - camel_exception_free(ex); - - return 0; -} - -#endif /* ENABLE_THREADS */ diff --git a/camel/tests/folder/test9.c b/camel/tests/folder/test9.c deleted file mode 100644 index 974c2c7793..0000000000 --- a/camel/tests/folder/test9.c +++ /dev/null @@ -1,227 +0,0 @@ -/* folder/index testing */ - -#include "camel-test.h" -#include "messages.h" -#include "folders.h" -#include "session.h" - -#include "camel/camel-exception.h" -#include "camel/camel-service.h" -#include "camel/camel-store.h" - -#include "camel/camel-folder.h" -#include "camel/camel-folder-summary.h" -#include "camel/camel-mime-message.h" -#include "camel/camel-filter-driver.h" -#include "camel/camel-stream-fs.h" - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -struct { - char *name; - CamelFolder *folder; -} mailboxes[] = { - { "INBOX", NULL }, - { "folder1", NULL }, - { "folder2", NULL }, - { "folder3", NULL }, - { "folder4", NULL }, -}; - -struct { - char *name, *match, *action; -} rules[] = { - { "empty1", "(match-all (header-contains \"Frobnitz\"))", "(copy-to \"folder1\")" }, - { "empty2", "(header-contains \"Frobnitz\")", "(copy-to \"folder2\")" }, - { "count11", "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))", "(move-to \"folder3\")" }, - { "empty3", "(and (header-contains \"subject\" \"Test1\") (header-contains \"subject\" \"subject\"))", "(move-to \"folder4\")" }, - { "count1", "(body-contains \"data50\")", "(copy-to \"folder1\")" }, - { "stop", "(body-contains \"data2\")", "(stop)" }, - { "notreached1", "(body-contains \"data2\")", "(move-to \"folder2\")" }, - { "count1", "(body-contains \"data3\")", "(move-to \"folder2\")" }, - { "ustrcasecmp", "(header-matches \"Subject\" \"Test0 message100 subject\")", "(copy-to \"folder2\")" }, -}; - -/* broken match rules */ -struct { - char *name, *match, *action; -} brokens[] = { - { "count1", "(body-contains data50)", "(copy-to \"folder1\")" }, /* non string argument */ - { "count1", "(body-contains-stuff \"data3\")", "(move-to-folder \"folder2\")" }, /* invalid function */ - { "count1", "(or (body-contains \"data3\") (foo))", "(move-to-folder \"folder2\")" }, /* invalid function */ - { "count1", "(or (body-contains \"data3\") (foo)", "(move-to-folder \"folder2\")" }, /* missing ) */ - { "count1", "(and body-contains \"data3\") (foo)", "(move-to-folder \"folder2\")" }, /* missing ( */ - { "count1", "body-contains \"data3\")", "(move-to-folder \"folder2\")" }, /* missing ( */ - { "count1", "body-contains \"data3\"", "(move-to-folder \"folder2\")" }, /* missing ( ) */ - { "count1", "(body-contains \"data3\" ())", "(move-to-folder \"folder2\")" }, /* extra () */ - { "count1", "()", "(move-to-folder \"folder2\")" }, /* invalid () */ - { "count1", "", "(move-to-folder \"folder2\")" }, /* empty */ -}; - -/* broken action rules */ -struct { - char *name, *match, *action; -} brokena[] = { - { "a", "(body-contains \"data2\")", "(body-contains \"help\")" }, /* rule in action */ - { "a", "(body-contains \"data2\")", "(move-to-folder-name \"folder2\")" }, /* unknown function */ - { "a", "(body-contains \"data2\")", "(or (move-to-folder \"folder2\")" }, /* missing ) */ - { "a", "(body-contains \"data2\")", "(or move-to-folder \"folder2\"))" }, /* missing ( */ - { "a", "(body-contains \"data2\")", "move-to-folder \"folder2\")" }, /* missing ( */ - { "a", "(body-contains \"data2\")", "(move-to-folder \"folder2\" ())" }, /* invalid () */ - { "a", "(body-contains \"data2\")", "()" }, /* invalid () */ - { "a", "(body-contains \"data2\")", "" }, /* empty */ -}; - -static CamelFolder *get_folder(CamelFilterDriver *d, const char *uri, void *data, CamelException *ex) -{ - int i; - - for (i=0;i<ARRAY_LEN(mailboxes);i++) - if (!strcmp(mailboxes[i].name, uri)) { - camel_object_ref((CamelObject *)mailboxes[i].folder); - return mailboxes[i].folder; - } - return NULL; -} - -int main(int argc, char **argv) -{ - CamelSession *session; - CamelStore *store; - CamelException *ex; - CamelFolder *folder; - CamelMimeMessage *msg; - int i, j; - CamelStream *mbox; - CamelFilterDriver *driver; - - /*gtk_init(&argc, &argv);*/ - - camel_test_init(argc, argv); - - ex = camel_exception_new(); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - camel_test_start("Simple filtering of mbox"); - - session = camel_test_session_new ("/tmp/camel-test"); - - /* todo: cross-check everything with folder_info checks as well */ - /* todo: work out how to do imap/pop/nntp tests */ - - push("getting store"); - store = camel_session_get_store(session, "mbox:///tmp/camel-test/mbox", ex); - check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex)); - check(store != NULL); - pull(); - - push("Creating output folders"); - for (i=0;i<ARRAY_LEN(mailboxes);i++) { - push("creating %s", mailboxes[i].name); - mailboxes[i].folder = folder = camel_store_get_folder(store, mailboxes[i].name, CAMEL_STORE_FOLDER_CREATE, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(folder != NULL); - - /* we need an empty folder for this to work */ - test_folder_counts(folder, 0, 0); - pull(); - } - pull(); - - /* append a bunch of messages with specific content */ - push("creating 100 test message mbox"); - mbox = camel_stream_fs_new_with_name("/tmp/camel-test/inbox", O_WRONLY|O_CREAT|O_EXCL, 0600); - for (j=0;j<100;j++) { - char *content, *subject; - - push("creating test message"); - msg = test_message_create_simple(); - content = g_strdup_printf("data%d content\n", j); - test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain", - content, strlen(content)); - test_free(content); - subject = g_strdup_printf("Test%d message%d subject", j, 100-j); - camel_mime_message_set_subject(msg, subject); - - camel_mime_message_set_date(msg, j*60*24, 0); - pull(); - - camel_stream_printf(mbox, "From \n"); - check(camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, mbox) != -1); -#if 0 - push("appending simple message %d", j); - camel_folder_append_message(folder, msg, NULL, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); -#endif - test_free(subject); - - check_unref(msg, 1); - } - check(camel_stream_close(mbox) != -1); - check_unref(mbox, 1); - pull(); - - push("Building filters"); - driver = camel_filter_driver_new(); - camel_filter_driver_set_folder_func(driver, get_folder, NULL); - for (i=0;i<ARRAY_LEN(rules);i++) { - camel_filter_driver_add_rule(driver, rules[i].name, rules[i].match, rules[i].action); - } - pull(); - - push("Executing filters"); - camel_filter_driver_set_default_folder(driver, mailboxes[0].folder); - camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - - /* now need to check the folder counts/etc */ - - check_unref(driver, 1); - pull(); - - /* this tests that invalid rules are caught */ - push("Testing broken match rules"); - for (i=0;i<ARRAY_LEN(brokens);i++) { - push("rule %s", brokens[i].match); - driver = camel_filter_driver_new(); - camel_filter_driver_set_folder_func(driver, get_folder, NULL); - camel_filter_driver_add_rule(driver, brokens[i].name, brokens[i].match, brokens[i].action); - camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); - check(camel_exception_is_set(ex)); - camel_exception_clear(ex); - check_unref(driver, 1); - pull(); - } - pull(); - - push("Testing broken action rules"); - for (i=0;i<ARRAY_LEN(brokena);i++) { - push("rule %s", brokena[i].action); - driver = camel_filter_driver_new(); - camel_filter_driver_set_folder_func(driver, get_folder, NULL); - camel_filter_driver_add_rule(driver, brokena[i].name, brokena[i].match, brokena[i].action); - camel_filter_driver_filter_mbox(driver, "/tmp/camel-test/inbox", NULL, ex); - check(camel_exception_is_set(ex)); - camel_exception_clear(ex); - check_unref(driver, 1); - pull(); - } - pull(); - - - for (i=0;i<ARRAY_LEN(mailboxes);i++) { - check_unref(mailboxes[i].folder, 1); - } - - check_unref(store, 1); - - check_unref(session, 1); - camel_exception_free(ex); - - camel_test_end(); - - return 0; -} |