diff options
author | nobody <nobody@localhost> | 2002-05-16 00:19:25 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2002-05-16 00:19:25 +0800 |
commit | d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e (patch) | |
tree | 9a14849dd3a40bd1667b88d689e2aa7d58d08bce /camel/tests | |
parent | 74f4231f4eb650f0243ff39ab5a085b1df4f7697 (diff) | |
download | gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar.gz gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar.bz2 gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar.lz gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar.xz gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.tar.zst gsoc2013-evolution-d27d55fe051d6f3bf5a5670f71ee2e0e9ee1c71e.zip |
This commit was manufactured by cvs2svn to create tagguikachu-1_2_3
'guikachu-1_2_3'.
svn path=/tags/guikachu-1_2_3/; revision=16902
Diffstat (limited to 'camel/tests')
73 files changed, 0 insertions, 5269 deletions
diff --git a/camel/tests/.cvsignore b/camel/tests/.cvsignore deleted file mode 100644 index fd6b811c68..0000000000 --- a/camel/tests/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la diff --git a/camel/tests/Makefile.am b/camel/tests/Makefile.am deleted file mode 100644 index e32f2e455f..0000000000 --- a/camel/tests/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ - -SUBDIRS = lib \ - message folder stream smime misc mime-filter diff --git a/camel/tests/README b/camel/tests/README deleted file mode 100644 index 6815330102..0000000000 --- a/camel/tests/README +++ /dev/null @@ -1,44 +0,0 @@ - -This directory is to contain regression tests that should be run -before committing anything to camel. - -In each subdirectory of tests there is a README containing a -one-line description of each test file. This README must be kept -uptodate. - -To write a new test: copy an existing one and replace the contents. - -See camel-test.h for a number of functions and macros which setup and -define the test environmet, and help provide meaningful messages when -something actually fails. - -All tests have the following options: - -v[vvvv] - verbose. more v's more verbose. 2 v's will give you - a simple test backtrace of any partially failed tests. - No v's give you a simple backtrace of any failed tests. - -q - quiet. Dont print anything, unless there is a SEGV. - -See the other files in lib/* for utility functions that help to -write the tests (object comparison, creation, etc functions). - -Tests may fail and be non-fatal. In this case, you will see "Partial -success" on the result of each test line. To get more information -about the test, run the test manually with a -v command line argument. -The more v's you have the more detail you get (upto about -vvvvv), -generally use -vv to find out which parts of a partially successful -test failed, and where. - -Note that if writing tests, non-fatal tests (bracketed by a -camel_test_nonfatal() and camel_test_fatal() pair) should only be -defined where: 1. The test in question should ideally pass, and 2. The -code has known limitations currently that stop it passing, but -otherwise works for nominal input. - -To debug tests, set a breakpoint on camel_test_fail, which will be -called for any failure, even a non-fatal one. Or set it to -camel_test_break, which will only be called for fatal errors which are -to print to the screen. - - Michael <notzed@helixcode.com> diff --git a/camel/tests/data/gendoc.pl b/camel/tests/data/gendoc.pl deleted file mode 100755 index 732f05a4ed..0000000000 --- a/camel/tests/data/gendoc.pl +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/perl - -# Generate 'documents' in different encodings, from po files - -if ($#ARGV < 0) { - print "Usage: gendoc.pl pofile pofile ...\n"; - exit 1; -} - -$fmt = "| fmt -u "; - -sub read_msgstr() -{ - my $str = ""; - while (<IN>) { - if (m/^msgstr \"(.*)\"/) { - $str = $1; - if ($str eq "") { - while (<IN>) { - if (m/\"(.*)\"/) { - $str .= $1; - } else { - last; - } - } - } - return $str; - } - } - return ""; -} - -$unknown = "x-unknown-1"; - -foreach $name (@ARGV) { - if ($name =~ m@([^/]*).po$@) { - $poname = $1; - - open IN,"<$name"; - - $header = read_msgstr; - if ($header =~ /Content-Type:.*charset=([-a-zA-Z0-9]*)/i) { - $charset = $1; - } else { - $charset = $unknown++; - } - - print "Building $poname.$charset.txt from $name\n"; - - open OUT,"$fmt > $poname.$charset.txt"; - while (!eof(IN)) { - $msg = read_msgstr; - # de-escape - $msg =~ s/\\n/\n/gso; - $msg =~ s/\\t/\t/gso; - $msg =~ s/\\(.)/$1/gso; - print OUT $msg." "; - } - close OUT; - close IN; - } else { - printf("ignoring $name, probably not intended\n"); - } -} - diff --git a/camel/tests/data/genline.pl b/camel/tests/data/genline.pl deleted file mode 100755 index 99ff43c882..0000000000 --- a/camel/tests/data/genline.pl +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/perl - -# Generate 'documents' in different encodings, from po files - -if ($#ARGV < 0) { - print "Usage: genline.pl pofile pofile ...\n"; - exit 1; -} - -sub read_msgstr() -{ - my $str = ""; - while (<IN>) { - if (m/^msgstr \"(.*)\"/) { - $str = $1; - if ($str eq "") { - while (<IN>) { - if (m/\"(.*)\"/) { - $str .= $1; - } else { - last; - } - } - } - return $str; - } - } - return ""; -} - -$unknown = "x-unknown-1"; -open OUT, ">test-lines.h"; - -print OUT <<END; -struct _l { - char *type; - char *line; -} test_lines[] = { -END - -foreach $name (@ARGV) { - if ($name =~ m@([^/]*).po$@) { - $poname = $1; - - open IN,"<$name"; - - $header = read_msgstr; - if ($header =~ /Content-Type:.*charset=([-a-zA-Z0-9]*)/i) { - $charset = $1; - } else { - $charset = $unknown++; - } - - while (!eof(IN)) { - $msg = read_msgstr; - if (length($msg) > 60 && length($msg) < 160) { - print OUT "\t{ \"$charset\", \"$msg\" },\n"; - last; - } -# $msg =~ s/\\n/\n/gso; -# $msg =~ s/\\t/\t/gso; -# $msg =~ s/\\(.)/$1/gso; -# print OUT $msg." "; - } - close IN; - } else { - printf("ignoring $name, probably not intended\n"); - } -} - -print OUT "};\n"; -close OUT; diff --git a/camel/tests/data/getaddr.pl b/camel/tests/data/getaddr.pl deleted file mode 100755 index 74a8a81f74..0000000000 --- a/camel/tests/data/getaddr.pl +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/perl - -# get addresses out of messages - -if ($#ARGV < 0) { - print "Usage: $0 message(s) mbox(es)\n"; - exit 1; -} - -foreach $name (@ARGV) { - open IN,"<$name"; - while (<IN>) { - if (/^From: (.*)/i - || /^To: (.*)/i - || /^Cc: (.*)/i) { - $base = $1; - while (<IN>) { - if (/^\s+(.*)/) { - $base .= " ".$1; - } else { - last; - } - } - $uniq{$base} = 1; - } - } - close IN; -} - -foreach $key (sort keys %uniq) { - print $key."\n"; -} 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; -} diff --git a/camel/tests/lib/.cvsignore b/camel/tests/lib/.cvsignore deleted file mode 100644 index ba98331a6d..0000000000 --- a/camel/tests/lib/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -temp-test -*.bb -*.bbg -*.da -*.gcov diff --git a/camel/tests/lib/Makefile.am b/camel/tests/lib/Makefile.am deleted file mode 100644 index f3a92899b2..0000000000 --- a/camel/tests/lib/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ - -INCLUDES = -I$(includedir) -I$(top_srcdir) -I$(top_srcdir)/camel - -check_LIBRARIES = libcameltest.a - -libcameltest_a_SOURCES = \ - camel-test.c camel-test.h \ - messages.c messages.h \ - addresses.c addresses.h \ - folders.c folders.h \ - session.c session.h \ - streams.c streams.h \ - address-data.h - diff --git a/camel/tests/lib/address-data.h b/camel/tests/lib/address-data.h deleted file mode 100644 index acecac596a..0000000000 --- a/camel/tests/lib/address-data.h +++ /dev/null @@ -1,93 +0,0 @@ -/* BE WARY of editing this file with emacs. - Otherwise it might be smart and try to re-encode everything, which - you really do not want -*/ - -static struct _a { - int count; - char *addr; - char *utf8; /* the utf8 in this table was generated by camel itself. As a result i'm making the assumption it - was right when it was created. It also depends on the format of ::format(),. which is likely to - change, to handle other bugs ! */ -} test_address[] = { - { 1, "\"=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=\" <david@iiia.csic.es>", "David GutiĂŠrrez Magallanes <david@iiia.csic.es>" }, - { 1, "\"=?iso-8859-1?Q?Jos=E9?= Antonio Milke G.\" <gerencia@ovoplus.com>", "JosĂŠ Antonio Milke G. <gerencia@ovoplus.com>" }, - { 1, "\"=?iso-8859-2?Q?Hi-Fi_Internert_market_=3D_1.Virtu=E1ln=ED_Internetov=E9_H?= =?iso-8859-2?Q?i-Fi_Studio?=\" <hifimarket@atlas.cz>", "Hi-Fi Internert market = 1.VirtuĂĄlnĂ InternetovĂŠ Hi-Fi Studio <hifimarket@atlas.cz>" }, - { 3, "\"James M. Cape\" <jcape@jcinteractive.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "James M. Cape <jcape@jcinteractive.com>, JoaquĂn Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" }, - { 1, "=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?= <david@iiia.csic.es>", "David GutiĂŠrrez Magallanes <david@iiia.csic.es>" }, - { 1, "=?ISO-8859-2?Q?Tomasz_K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz KĹoczko <kloczek@rudy.mif.pg.gda.pl>" }, - { 1, "=?ISO-8859-2?Q?Vladim=EDr_Solnick=FD?= <vs@utia.cas.cz>", "VladimĂr SolnickĂ˝ <vs@utia.cas.cz>" }, - { 1, "=?iso-8859-1?Q?=22S=F6rensen=2C_Daniel=22?= <dasar@wmdata.com>", "\"SĂśrensen, Daniel\" <dasar@wmdata.com>" }, - { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@iim.nctu.edu.tw>", "ĂĂÂŞQ§à <dennys@iim.nctu.edu.tw>" }, - { 1, "=?iso-8859-1?Q?=C1=C2=AAQ=A7=CA?= <dennys@news.iim.nctu.edu.tw>", "ĂĂÂŞQ§à <dennys@news.iim.nctu.edu.tw>" }, - { 1, "=?iso-8859-1?Q?=C1kos?= Valentinyi <A.Valentinyi@soton.ac.uk>", "Ăkos Valentinyi <A.Valentinyi@soton.ac.uk>" }, - { 1, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>", "JoaquĂn Cuenca Abela <cuenca@ie2.u-psud.fr>" }, - { 2, "=?iso-8859-1?Q?Joaqu=EDn?= Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx", "JoaquĂn Cuenca Abela <cuenca@ie2.u-psud.fr>, gnome-hackers@nuclecu.unam.mx" }, - { 1, "=?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>", "JoaquĂn Cuenca Abela <cuenca@celium.net>" }, - { 1, "=?iso-8859-1?Q?Juantom=E1s=20Garc=EDa?= <juantomas@lared.es>", "JuantomĂĄs GarcĂa <juantomas@lared.es>" }, - { 1, "=?iso-8859-1?Q?Kenneth_ll=E9phaane_Christiansen?= <kenneth@ripen.dk>", "Kenneth llĂŠphaane Christiansen <kenneth@ripen.dk>" }, - { 1, "=?iso-8859-1?Q?Kjell_Tage_=D8hman?= <tage@ohman.no>", "Kjell Tage Ăhman <tage@ohman.no>" }, - { 1, "=?iso-8859-1?Q?Martin_Norb=E4ck?= <d95mback@dtek.chalmers.se>", "Martin Norbäck <d95mback@dtek.chalmers.se>" }, - { 1, "=?iso-8859-1?Q?P=E5llen?= <pollen@astrakan.hig.se>", "PĂĽllen <pollen@astrakan.hig.se>" }, - { 1, "=?iso-8859-1?Q?Ville_P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" }, - { 1, "=?iso-8859-1?q?Joaqu=EDn?= Cuenca Abela <cuenca@celium.net>", "JoaquĂn Cuenca Abela <cuenca@celium.net>" }, - { 1, "=?iso-8859-2?Q?Dra=BEen_Ka=E8ar?= <dave@srce.hr>", "DraĹžen KaÄar <dave@srce.hr>" }, - /* yep this is right, this isn't valid so doesn't decode at all */ - { 1, "=?windows-1250?Q? \"Jaka Mo=E8nik\" ?= <jaka.mocnik@kiss.uni-lj.si>", "=?windows-1250?Q? Jaka Mo=E8nik ?= <jaka.mocnik@kiss.uni-lj.si>" }, - { 3, "George <jirka@5z.com>, Juantomas =?ISO-8859-1?Q?Garc=C3=83=C2=ADa?= <juantomas@lared.es>, gnome-hackers@gnome.org", "George <jirka@5z.com>, Juantomas GarcĂÂĂÂa <juantomas@lared.es>, gnome-hackers@gnome.org" }, - { 7, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@celium.net>, sam th <sam@uchicago.edu>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, JoaquĂn Cuenca Abela <cuenca@celium.net>, sam th <sam@uchicago.edu>" }, - { 6, "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, =?iso-8859-1?Q?Joaqu=EDn_Cuenca_Abela?= <cuenca@ie2.u-psud.fr>", "Jon Trowbridge <trow@emccta.com>, gnome-1.4-list@gnome.org, gnome-devel-list@gnome.org, gnome-hackers@gnome.org, Dom Lachowicz <cinamod@hotmail.com>, JoaquĂn Cuenca Abela <cuenca@ie2.u-psud.fr>" }, - { 1, "Kai =?iso-8859-1?Q?Gro=DFjohann?= <Kai.Grossjohann@CS.Uni-Dortmund.DE>", "Kai GroĂjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" }, - { 1, "Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=)", "Kai GroĂjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>" }, - { 1, "Rickard =?iso-8859-1?Q?Nordstr=F6m?= <rzi@ebox.tninet.se>", "Rickard NordstrĂśm <rzi@ebox.tninet.se>" }, - { 1, "Tomasz =?iso-8859-2?q?K=B3oczko?= <kloczek@rudy.mif.pg.gda.pl>", "Tomasz KĹoczko <kloczek@rudy.mif.pg.gda.pl>" }, - { 1, "VALCKE =?iso-8859-1?Q?C=E9dric?= <cvalcke@freesurf.fr>", "VALCKE CĂŠdric <cvalcke@freesurf.fr>" }, - { 1, "Ville =?iso-8859-1?q?P=E4tsi?= <drc@gnu.org>", "Ville Pätsi <drc@gnu.org>" }, - { 1, "david@iiia.csic.es (=?ISO-8859-1?Q?David_Guti=E9rrez_Magallanes?=)", "David GutiĂŠrrez Magallanes <david@iiia.csic.es>" }, - { 1, "kloczek@rudy.mif.pg.gda.pl (=?ISO-8859-2?Q?Tomasz_K=B3oczko?=)", "Tomasz KĹoczko <kloczek@rudy.mif.pg.gda.pl>" }, - { 1, "lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)", "Lasse Hillerøe Petersen <lassehp@imv.aau.dk>" }, - { 1, "ysato@etl.go.jp (Yutaka Sato =?ISO-2022-JP?B?GyRAOjRGI0stGyhK?=)", "Yutaka Sato ä˝č¤čą <ysato@etl.go.jp>" }, -}; - -static struct _l { - char *type; - char *line; -} test_lines[] = { - /* commented out unsupported charsets - FIXME: camel should somehow handle this, although it can't really of course */ - /*{ "windows-1251", "Ĺäčí ŕďëĺň íĺ îňăîâŕđ˙ íŕ çŕ˙âęŕ çŕ çŕďčń.\nÄŕ ăî ďđĺěŕőíŕ ëč čëč äŕ ďî÷ŕęŕě?" },*/ - { "iso-8859-1", "Omple les miniatures de la finestra amb contingut de la pantalla" }, - { "ISO-8859-2", "Správce oken hýbe s okrajem okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "ISO-8859-1", "Vindueshĺndtering flytter dekorationsvindue istedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "ISO-8859-1", "Vorschaubilder der Fenster mit dem Bildschirminhalt ausfüllen" }, - { "iso-8859-7", "ĹěöÜíéóç ĺńăáóéţí đďő äĺ öáßíďíôáé óôç ëßóôá đáńáčýńůí (ĐÁŃÁĘÁĚŘÇ-ËÉÓÔÁĐÁŃÁČŐŃŮÍ)" }, - { "iso-8859-1", "You've chosen to disable the startup hint.\nTo re-enable it, choose \"Startup Hint\"\nin the GNOME Control Centre" }, - { "iso-8859-1", "El aplique de reloj muestra en su panel la fecha y la hora de forma simple \ny ligero " }, - { "iso-8859-1", "Applet ei vasta salvestuskäsule.\nKas peaks ta niisama sulgema, vői veel ootama?" }, - { "iso-8859-1", "Lehio kudeatzaileak lehioaren dekorazaioa mugiarazten\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-15", "Näytä sovellukset, joiden ikkunoista on näkyvillä vain otsikkopalkki" }, - { "ISO-8859-1", "Afficher les tâches qui ne sont pas dans la liste des fenętres" }, - { "iso-8859-1", "Níl applet ag tabhair freagra ar iarratas sábháil.\nBain amach an applet nó lean ar fánacht?" }, - { "iso-8859-1", "Amosa-las tarefas agochadas da lista de fiestras (SKIP-WINLIST)" }, - { "iso-8859-2", "Az ablakkezelő a dekorációt mozgassa az ablak helyett\n(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, - { "iso-8859-1", "Riempi la finestra delle anteprime con il contenuto dello schermo" }, - { "euc-jp", "ĽŚĽ¤ĽóĽÉĽŚĽŢĽÍĄźĽ¸Ľă¤Ďžţ¤ęĽŚĽ¤ĽóĽÉĽŚ¤ňĆ°¤Ť¤š\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "euc-kr", "â °ü¸ŽŔÚ°Ą ˛ŮšÎ â ´ë˝Ĺ ŔĚľż\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-13", "Priedas neatsakinëja á prađymŕ iđsisaugoti.\nPađalinti priedŕ ar laukti toliau?" }, - { "iso-8859-1", "Window manager verplaatst dekoratie\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Vindushĺndtereren flytter dekorasjonsvinduet i stedet\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-2", "Przemieszczanie dekoracji zamiast okna\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Este programa é responsável por executar outras aplicaçőes, embeber pequenos applets, a paz no mundo e crashes aleatórios do X." }, - { "iso-8859-1", "Mostrar tarefas que se escondem da lista de janelas (SKIP-WINLIST)" }, - { "koi8-r", "÷ŮÓĎÔÁ ŇÁÂĎŢĹÇĎ ÓÔĎĚÁ × ĐĹŇĹËĚŔŢÁÔĹĚĹ ÓĎ×ĐÁÄÁĹÔ Ó ×ŮÓĎÔĎĘ ĐÁÎĹĚÉ" }, - { "iso-8859-2", "Správca okien presúva okraje okien\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-2", "Kaži posle, ki se skrivajo pred upravljalnik oken (SKIP-WINLIST)" }, - { "iso-8859-5", "Window ÜŐÝĐÔ×ŐŕŘ ßŢÜŐŕĐ ÔŐÚŢŕĐćŘŢÝŘ ßŕŢ×Ţŕ ăÜŐáâŢ âŢÓa\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-2", "Window menadzeri pomera dekoracioni prozor umesto toga\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, - { "iso-8859-1", "Fönsterhanteraren flyttar dekorationsfönstret istället\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - /*{ "TSCII", "Ŕ˝˘ě¸źî-şđź¸ňž˘ř ŔĄ÷ě¸ ÓĘÂĄž Ŕ˝˘ě¸źí¸¨Ç ¸ĄÁ˘ (Ŕ˝˘ě¸źî-şđź¸ő-žĹ˘÷)" },*/ - { "iso-8859-9", "Kaydetme isteđine bir uygulak cevap vermiyor .\nUygulađý sileyim mi , yoksa bekleyeyim mi ?" }, - { "koi8-u", "đĹŇĹÍŚÝĹÎÎŃ ÄĹËĎŇÁĂŚ§ ÚÁÍŚÓÔŘ ×ŚËÎÁ\n(AfterStep, Enlightenment, FVWM, IceWM, Sawfish)" }, - { "iso-8859-1", "Cwand on scriftôr est bodjî foű, li scriftôr čt totes\nles apliketes ĺ dvins sont pierdowes. Bodjî ci scriftôr chal?" }, - { "gb2312", "ǨŇĆľ˝×°Ęδ°żÚšÜŔíłĚĐň(AfterStep, Enlightenment, FVWM, IceWM, SawMill)" }, - { "big5", "ľřľĄşŢ˛zŞĚĽu˛ž°Ę¸Ëš˘ľřľĄ\n(AfterStep, Enlightenment, FVWM, IceWM, Sawmill)" }, -}; diff --git a/camel/tests/lib/addresses.c b/camel/tests/lib/addresses.c deleted file mode 100644 index a97ac5e4f9..0000000000 --- a/camel/tests/lib/addresses.c +++ /dev/null @@ -1,51 +0,0 @@ - -#include "addresses.h" -#include "camel-test.h" - -void -test_address_compare(CamelInternetAddress *addr, CamelInternetAddress *addr2) -{ - const char *r1, *r2, *a1, *a2; - char *e1, *e2, *f1, *f2; - int j; - - check(camel_address_length(CAMEL_ADDRESS(addr)) == camel_address_length(CAMEL_ADDRESS(addr2))); - for (j=0;j<camel_address_length(CAMEL_ADDRESS(addr));j++) { - - check(camel_internet_address_get(addr, j, &r1, &a1) == TRUE); - check(camel_internet_address_get(addr2, j, &r2, &a2) == TRUE); - - check(string_equal(r1, r2)); - check(strcmp(a1, a2) == 0); - } - check(camel_internet_address_get(addr, j, &r1, &a1) == FALSE); - check(camel_internet_address_get(addr2, j, &r2, &a2) == FALSE); - - e1 = camel_address_encode(CAMEL_ADDRESS(addr)); - e2 = camel_address_encode(CAMEL_ADDRESS(addr2)); - - if (camel_address_length(CAMEL_ADDRESS(addr)) == 0) - check(e1 == NULL && e2 == NULL); - else - check(e1 != NULL && e2 != NULL); - - if (e1 != NULL) { - check_msg(string_equal(e1, e2), "e1 = '%s' e2 = '%s'", e1, e2); - test_free(e1); - test_free(e2); - } - - f1 = camel_address_format(CAMEL_ADDRESS(addr)); - f2 = camel_address_format(CAMEL_ADDRESS(addr2)); - - if (camel_address_length(CAMEL_ADDRESS(addr)) == 0) - check(f1 == NULL && f2 == NULL); - else - check(f1 != NULL && f2 != NULL); - - if (f1 != NULL) { - check_msg(string_equal(f1, f2), "f1 = '%s' f2 = '%s'", f1, f2); - test_free(f1); - test_free(f2); - } -} diff --git a/camel/tests/lib/addresses.h b/camel/tests/lib/addresses.h deleted file mode 100644 index dc35a19f05..0000000000 --- a/camel/tests/lib/addresses.h +++ /dev/null @@ -1,5 +0,0 @@ - -#include <camel/camel-internet-address.h> - -/* addresses.c */ -void test_address_compare(CamelInternetAddress *addr, CamelInternetAddress *addr2); diff --git a/camel/tests/lib/camel-test.c b/camel/tests/lib/camel-test.c deleted file mode 100644 index a61f949f0a..0000000000 --- a/camel/tests/lib/camel-test.c +++ /dev/null @@ -1,350 +0,0 @@ - -#include "camel-test.h" - -#include <stdio.h> -#include <string.h> -#include <signal.h> - -#ifdef ENABLE_THREADS -#include <pthread.h> -#include <unistd.h> -#endif - -#ifdef ENABLE_THREADS -/* well i dunno, doesn't seem to be in the headers but hte manpage mentions it */ -/* a nonportable checking mutex for glibc, not really needed, just validates - the test harness really */ -# ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP -static pthread_mutex_t lock = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; -# else -static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; -# endif -#define CAMEL_TEST_LOCK pthread_mutex_lock(&lock) -#define CAMEL_TEST_UNLOCK pthread_mutex_unlock(&lock) -#define CAMEL_TEST_ID (pthread_self()) -#else -#define CAMEL_TEST_LOCK -#define CAMEL_TEST_UNLOCK -#define CAMEL_TEST_ID (0) -#endif - -static int setup; -static int ok; - -struct _stack { - struct _stack *next; - int fatal; - char *what; -}; - -/* per-thread state */ -struct _state { - char *test; - int nonfatal; - struct _stack *state; -}; - -static GHashTable *info_table; - -int camel_test_verbose; - -static void -dump_action(int id, struct _state *s, void *d) -{ - struct _stack *node; - -#ifdef ENABLE_THREADS - printf("\nThread %d:\n", id); -#endif - node = s->state; - if (node) { - printf("Current action:\n"); - while (node) { - printf("\t%s%s\n", node->fatal?"":"[nonfatal]", node->what); - node = node->next; - } - } - printf("\tTest: %s\n", s->test); -} - -static void die(int sig) -{ - static int indie = 0; - - if (!indie) { - indie = 1; - printf("\n\nReceived fatal signal %d\n", sig); - g_hash_table_foreach(info_table, (GHFunc)dump_action, 0); - -#ifdef ENABLE_THREADS - if (camel_test_verbose > 2) { - printf("Attach debugger to pid %d to debug\n", getpid()); - sleep(1000); - } -#endif - } - - _exit(1); -} - -static struct _state * -current_state(void) -{ - struct _state *info; - - if (info_table == NULL) - info_table = g_hash_table_new(0, 0); - - info = g_hash_table_lookup(info_table, (void *)CAMEL_TEST_ID); - if (info == NULL) { - info = g_malloc0(sizeof(*info)); - g_hash_table_insert(info_table, (void *)CAMEL_TEST_ID, info); - } - return info; -} - - -void camel_test_init(int argc, char **argv) -{ - void camel_init(void); - int i; - - setup = 1; - -#ifndef ENABLE_THREADS - camel_init(); -#endif - - info_table = g_hash_table_new(0, 0); - - /* yeah, we do need ot thread init, even though camel isn't compiled with enable threads */ - g_thread_init(NULL); - - signal(SIGSEGV, die); - signal(SIGABRT, die); - - /* default, just say what, how well we did, unless fail, then abort */ - camel_test_verbose = 1; - - for (i=0;i<argc;i++) { - if (argv[i][0] == '-') { - switch (argv[i][1]) { - case 'v': - camel_test_verbose = strlen(argv[i]); - break; - case 'q': - camel_test_verbose = 0; - break; - } - } - } -} - -void camel_test_start(const char *what) -{ - struct _state *s; - - CAMEL_TEST_LOCK; - - s = current_state(); - - if (!setup) - camel_test_init(0, 0); - - ok = 1; - - s->test = g_strdup(what); - - if (camel_test_verbose > 0) { - printf("Test: %s ... ", what); - fflush(stdout); - } - - CAMEL_TEST_UNLOCK; -} - -void camel_test_push(const char *what, ...) -{ - struct _stack *node; - va_list ap; - char *text; - struct _state *s; - - CAMEL_TEST_LOCK; - - s = current_state(); - - va_start(ap, what); - text = g_strdup_vprintf(what, ap); - va_end(ap); - - if (camel_test_verbose > 3) - printf("Start step: %s\n", text); - - node = g_malloc(sizeof(*node)); - node->what = text; - node->next = s->state; - node->fatal = 1; - s->state = node; - - CAMEL_TEST_UNLOCK; -} - -void camel_test_pull(void) -{ - struct _stack *node; - struct _state *s; - - CAMEL_TEST_LOCK; - - s = current_state(); - - g_assert(s->state); - - if (camel_test_verbose > 3) - printf("Finish step: %s\n", s->state->what); - - node = s->state; - s->state = node->next; - if (!node->fatal) - s->nonfatal--; - g_free(node->what); - g_free(node); - - CAMEL_TEST_UNLOCK; -} - -/* where to set breakpoints */ -void camel_test_break(void); - -void camel_test_break(void) -{ -} - -void camel_test_fail(const char *why, ...) -{ - va_list ap; - - va_start(ap, why); - camel_test_failv(why, ap); - va_end(ap); -} - - -void camel_test_failv(const char *why, va_list ap) -{ - char *text; - struct _state *s; - - CAMEL_TEST_LOCK; - - s = current_state(); - - text = g_strdup_vprintf(why, ap); - - if ((s->nonfatal == 0 && camel_test_verbose > 0) - || (s->nonfatal && camel_test_verbose > 1)) { - printf("Failed.\n%s\n", text); - camel_test_break(); - } - - g_free(text); - - if ((s->nonfatal == 0 && camel_test_verbose > 0) - || (s->nonfatal && camel_test_verbose > 2)) { - g_hash_table_foreach(info_table, (GHFunc)dump_action, 0); - } - - if (s->nonfatal == 0) { - exit(1); - } else { - ok=0; - if (camel_test_verbose > 1) { - printf("Known problem (ignored):\n"); - dump_action(CAMEL_TEST_ID, s, 0); - } - } - - CAMEL_TEST_UNLOCK; -} - -void camel_test_nonfatal(const char *what, ...) -{ - struct _stack *node; - va_list ap; - char *text; - struct _state *s; - - CAMEL_TEST_LOCK; - - s = current_state(); - - va_start(ap, what); - text = g_strdup_vprintf(what, ap); - va_end(ap); - - if (camel_test_verbose > 3) - printf("Start nonfatal: %s\n", text); - - node = g_malloc(sizeof(*node)); - node->what = text; - node->next = s->state; - node->fatal = 0; - s->nonfatal++; - s->state = node; - - CAMEL_TEST_UNLOCK; -} - -void camel_test_fatal(void) -{ - camel_test_pull(); -} - -void camel_test_end(void) -{ - if (camel_test_verbose > 0) { - if (ok) - printf("Ok\n"); - else - printf("Partial success\n"); - } - - fflush(stdout); -} - - - - -/* compare strings, ignore whitespace though */ -int string_equal(const char *a, const char *b) -{ - const char *ap, *bp; - - ap = a; - bp = b; - - while (*ap && *bp) { - while (*ap == ' ' || *ap == '\n' || *ap == '\t') - ap++; - while (*bp == ' ' || *bp == '\n' || *bp == '\t') - bp++; - - a = ap; - b = bp; - - while (*ap && *ap != ' ' && *ap != '\n' && *ap != '\t') - ap++; - while (*bp && *bp != ' ' && *bp != '\n' && *bp != '\t') - bp++; - - if (ap - a != bp - a - && ap - 1 > 0 - && memcmp(a, b, ap-a) != 0) { - return 0; - } - } - - return 1; -} - diff --git a/camel/tests/lib/camel-test.h b/camel/tests/lib/camel-test.h deleted file mode 100644 index 986a943fa3..0000000000 --- a/camel/tests/lib/camel-test.h +++ /dev/null @@ -1,68 +0,0 @@ - -/* some utilities for testing */ - -#include "config.h" - -#include <stdlib.h> -#include <glib.h> - -void camel_test_failv(const char *why, va_list ap); - -/* perform a check assertion */ -#define check(x) do {if (!(x)) { camel_test_fail("%s:%d: %s", __FILE__, __LINE__, #x); } } while (0) -/* check with message */ -#ifdef __GNUC__ -#define check_msg(x, y, z...) do {if (!(x)) { camel_test_fail("%s:%d: %s\n\t" #y, __FILE__, __LINE__, #x, ##z); } } while (0) -#else -static void check_msg(int truth, char *fmt, ...) -{ - /* no gcc, we lose the condition that failed, nm */ - if (!truth) { - va_list ap; - va_start(ap, fmt); - camel_test_failv(fmt, ap); - va_end(ap); - } -} -#endif - -#define check_count(object, expected) do { \ - if (CAMEL_OBJECT(object)->ref_count != expected) { \ - camel_test_fail("%s->ref_count != %s\n\tref_count = %d", #object, #expected, CAMEL_OBJECT(object)->ref_count); \ - } \ -} while (0) - -#define check_unref(object, expected) do { \ - check_count(object, expected); \ - camel_object_unref(CAMEL_OBJECT(object)); \ - if (expected == 1) { \ - object = NULL; \ - } \ -} while (0) - -#define test_free(mem) (g_free(mem), mem=NULL) - -#define push camel_test_push -#define pull camel_test_pull - -void camel_test_init(int argc, char **argv); - -/* start/finish a new test */ -void camel_test_start(const char *what); -void camel_test_end(void); - -/* start/finish a new test part */ -void camel_test_push(const char *what, ...); -void camel_test_pull(void); - -/* fail a test, with a reason why */ -void camel_test_fail(const char *why, ...); -void camel_test_failv(const char *why, va_list ap); - -/* Set whether a failed test quits. May be nested, but must be called in nonfatal/fatal pairs */ -void camel_test_nonfatal(const char *why, ...); -void camel_test_fatal(void); - -/* utility functions */ -/* compare strings, ignore whitespace though */ -int string_equal(const char *a, const char *b); diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c deleted file mode 100644 index 86d9a1f3ff..0000000000 --- a/camel/tests/lib/folders.c +++ /dev/null @@ -1,524 +0,0 @@ -#include <string.h> - -#include "camel-test.h" -#include "folders.h" -#include "messages.h" - -#include "camel/camel-exception.h" - -/* check the total/unread is what we think it should be */ -void -test_folder_counts(CamelFolder *folder, int total, int unread) -{ - GPtrArray *s; - int i, myunread; - CamelMessageInfo *info; - - push("test folder counts %d total %d unread", total, unread); - - /* first, use the standard functions */ - check(camel_folder_get_message_count(folder) == total); - check(camel_folder_get_unread_message_count(folder) == total); - - /* next, use the summary */ - s = camel_folder_get_summary(folder); - check(s != NULL); - check(s->len == total); - myunread = s->len; - for (i=0;i<s->len;i++) { - info = s->pdata[i]; - if (info->flags & CAMEL_MESSAGE_SEEN) - myunread--; - } - check(unread == myunread); - camel_folder_free_summary(folder, s); - - /* last, use the uid list */ - s = camel_folder_get_uids(folder); - check(s != NULL); - check(s->len == total); - myunread = s->len; - for (i=0;i<s->len;i++) { - info = camel_folder_get_message_info(folder, s->pdata[i]); - if (info->flags & CAMEL_MESSAGE_SEEN) - myunread--; - camel_folder_free_message_info(folder, info); - } - check(unread == myunread); - camel_folder_free_uids(folder, s); - - pull(); -} - -static int -safe_strcmp(const char *a, const char *b) -{ - if (a == NULL && b == NULL) - return 0; - if (a == NULL) - return 1; - if (b == NULL) - return -1; - return strcmp(a, b); -} - -void -test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info) -{ - check_msg(safe_strcmp(camel_message_info_subject(info), camel_mime_message_get_subject(msg)) == 0, - "info->subject = '%s', get_subject() = '%s'", camel_message_info_subject(info), camel_mime_message_get_subject(msg)); - - /* FIXME: testing from/cc/to, etc is more tricky */ - - check(info->date_sent == camel_mime_message_get_date(msg, NULL)); - - /* date received isn't set for messages that haven't been sent anywhere ... */ - /*check(info->date_received == camel_mime_message_get_date_received(msg, NULL));*/ - - /* so is messageid/references, etc */ -} - -/* check a message is present */ -void -test_folder_message(CamelFolder *folder, const char *uid) -{ - CamelMimeMessage *msg; - CamelMessageInfo *info; - GPtrArray *s; - int i; - CamelException *ex = camel_exception_new(); - int found; - - push("uid %s is in folder", uid); - - /* first try getting info */ - info = camel_folder_get_message_info(folder, uid); - check(info != NULL); - check(strcmp(camel_message_info_uid(info), uid) == 0); - camel_folder_free_message_info(folder, info); - - /* then, getting message */ - msg = camel_folder_get_message(folder, uid, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(msg != NULL); - - /* cross check with info */ - test_message_info(msg, info); - - camel_object_unref((CamelObject *)msg); - - /* see if it is in the summary (only once) */ - s = camel_folder_get_summary(folder); - check(s != NULL); - found = 0; - for (i=0;i<s->len;i++) { - info = s->pdata[i]; - if (strcmp(camel_message_info_uid(info), uid) == 0) - found++; - } - check(found == 1); - camel_folder_free_summary(folder, s); - - /* check it is in the uid list */ - s = camel_folder_get_uids(folder); - check(s != NULL); - found = 0; - for (i=0;i<s->len;i++) { - if (strcmp(s->pdata[i], uid) == 0) - found++; - } - check(found == 1); - camel_folder_free_uids(folder, s); - - camel_exception_free(ex); - - pull(); -} - -/* check message not present */ -void -test_folder_not_message(CamelFolder *folder, const char *uid) -{ - CamelMimeMessage *msg; - CamelMessageInfo *info; - GPtrArray *s; - int i; - CamelException *ex = camel_exception_new(); - int found; - - push("uid %s is not in folder", uid); - - /* first try getting info */ - info = camel_folder_get_message_info(folder, uid); - check(info == NULL); - - /* then, getting message */ - msg = camel_folder_get_message(folder, uid, ex); - check(camel_exception_is_set(ex)); - check(msg == NULL); - camel_exception_clear(ex); - - /* see if it is not in the summary (only once) */ - s = camel_folder_get_summary(folder); - check(s != NULL); - found = 0; - for (i=0;i<s->len;i++) { - info = s->pdata[i]; - if (strcmp(camel_message_info_uid(info), uid) == 0) - found++; - } - check(found == 0); - camel_folder_free_summary(folder, s); - - /* check it is not in the uid list */ - s = camel_folder_get_uids(folder); - check(s != NULL); - found = 0; - for (i=0;i<s->len;i++) { - if (strcmp(s->pdata[i], uid) == 0) - found++; - } - check(found == 0); - camel_folder_free_uids(folder, s); - - camel_exception_free(ex); - - pull(); -} - -/* test basic store operations on folders */ -/* TODO: Add subscription stuff */ -void -test_folder_basic(CamelSession *session, const char *storename, int local, int spool) -{ - CamelStore *store; - CamelException *ex = camel_exception_new(); - CamelFolder *folder; - char *what = g_strdup_printf("testing store: %s", storename); - - camel_test_start(what); - test_free(what); - - push("getting store"); - store = camel_session_get_store(session, storename, ex); - check_msg(!camel_exception_is_set(ex), "getting store: %s", camel_exception_get_description(ex)); - check(store != NULL); - pull(); - - /* local providers == no inbox */ - push("getting inbox folder"); - folder = camel_store_get_inbox(store, ex); - if (local) { - check(camel_exception_is_set(ex)); - check(folder == NULL); - camel_exception_clear(ex); - } else { - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(folder != NULL); - check_unref(folder, 1); - } - pull(); - - push("getting a non-existant folder, no create"); - folder = camel_store_get_folder(store, "unknown", 0, ex); - check(camel_exception_is_set(ex)); - check(folder == NULL); - camel_exception_clear(ex); - pull(); - - if (!spool) { - push("getting a non-existant folder, with create"); - 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); - 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); - pull(); - - push("renaming a non-existant folder"); - camel_store_rename_folder(store, "unknown1", "unknown2", ex); - check(camel_exception_is_set(ex)); - camel_exception_clear(ex); - pull(); - - push("renaming an existing folder"); - camel_store_rename_folder(store, "testbox", "testbox2", ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - - push("opening the old name of a renamed folder"); - folder = camel_store_get_folder(store, "testbox", 0, ex); - check(camel_exception_is_set(ex)); - check(folder == NULL); - camel_exception_clear(ex); - pull(); - - push("opening the new name of a renamed folder"); - 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); - pull(); - } - - push("deleting a non-existant folder"); - camel_store_delete_folder(store, "unknown", ex); - check(camel_exception_is_set(ex)); - camel_exception_clear(ex); - pull(); - - if (!spool) { - push("deleting an existing folder"); - camel_store_delete_folder(store, "testbox2", ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - pull(); - } - - push("opening a folder that has been deleted"); - folder = camel_store_get_folder(store, "testbox2", 0, ex); - check(camel_exception_is_set(ex)); - check(folder == NULL); - camel_exception_clear(ex); - pull(); - - check_unref(store, 1); - - camel_test_end(); - - camel_exception_free(ex); -} - - -/* 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) -{ - CamelStore *store; - CamelException *ex = camel_exception_new(); - CamelFolder *folder; - CamelMimeMessage *msg; - int j; - int indexed, max; - GPtrArray *uids; - CamelMessageInfo *info; - char *mailbox; - - if (spool) - mailbox = "INBOX"; - else - mailbox = "testbox"; - - max=local?2:1; - - for (indexed = 0;indexed<max;indexed++) { - char *what = g_strdup_printf("folder ops: %s %s", name, local?(indexed?"indexed":"non-indexed"):""); - int flags; - - camel_test_start(what); - test_free(what); - - push("getting store"); - store = camel_session_get_store(session, name, 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, mailbox, flags, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - check(folder != NULL); - - /* verify empty/can't get nonexistant stuff */ - test_folder_counts(folder, 0, 0); - test_folder_not_message(folder, "0"); - test_folder_not_message(folder, ""); - - for (j=0;j<10;j++) { - char *content, *subject; - - push("creating test message"); - 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", 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)); - - /* 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"); - camel_folder_refresh_info(folder, ex); - 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"); - - test_folder_counts(folder, j+1, j+1); - - 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]); - 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)); - camel_folder_free_uids(folder, uids); - camel_folder_free_message_info(folder, info); - pull(); - - test_free(subject); - - check_unref(msg, 1); - pull(); - } - - check_unref(folder, 1); - pull(); - - 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(); - - push("re-opening folder"); - 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); - - /* verify counts */ - test_folder_counts(folder, 10, 10); - - /* re-check uid's, after a reload */ - uids = camel_folder_get_uids(folder); - check(uids != NULL); - check(uids->len == 10); - for (j=0;j<10;j++) { - char *subject = g_strdup_printf("Test message %d", j); - - push("verify reload of %s", subject); - test_folder_message(folder, uids->pdata[j]); - - 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)); - test_free(subject); - camel_folder_free_message_info(folder, info); - pull(); - } - - push("deleting first message & expunging"); - camel_folder_delete_message(folder, uids->pdata[0]); - test_folder_counts(folder, 10, 10); - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - test_folder_not_message(folder, uids->pdata[0]); - test_folder_counts(folder, 9, 9); - - camel_folder_free_uids(folder, uids); - - uids = camel_folder_get_uids(folder); - check(uids != NULL); - check(uids->len == 9); - for (j=0;j<9;j++) { - char *subject = g_strdup_printf("Test message %d", j+1); - - push("verify after expunge of %s", subject); - test_folder_message(folder, uids->pdata[j]); - - 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)); - test_free(subject); - camel_folder_free_message_info(folder, info); - pull(); - } - pull(); - - push("deleting last message & expunging"); - camel_folder_delete_message(folder, uids->pdata[8]); - /* sync? */ - test_folder_counts(folder, 9, 9); - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - test_folder_not_message(folder, uids->pdata[8]); - test_folder_counts(folder, 8, 8); - - camel_folder_free_uids(folder, uids); - - uids = camel_folder_get_uids(folder); - check(uids != NULL); - check(uids->len == 8); - for (j=0;j<8;j++) { - char *subject = g_strdup_printf("Test message %d", j+1); - - push("verify after expunge of %s", subject); - test_folder_message(folder, uids->pdata[j]); - - 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)); - test_free(subject); - camel_folder_free_message_info(folder, info); - pull(); - } - pull(); - - push("deleting all messages & expunging"); - for (j=0;j<8;j++) { - camel_folder_delete_message(folder, uids->pdata[j]); - } - /* sync? */ - test_folder_counts(folder, 8, 8); - camel_folder_expunge(folder, ex); - check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); - for (j=0;j<8;j++) { - test_folder_not_message(folder, uids->pdata[j]); - } - test_folder_counts(folder, 0, 0); - - camel_folder_free_uids(folder, uids); - pull(); - - check_unref(folder, 1); - pull(); /* re-opening folder */ - - if (!spool) { - 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(); - } - - check_unref(store, 1); - camel_test_end(); - } - - camel_exception_free(ex); -} diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h deleted file mode 100644 index d3c9686dc2..0000000000 --- a/camel/tests/lib/folders.h +++ /dev/null @@ -1,20 +0,0 @@ - -#include "camel/camel-session.h" -#include "camel/camel-store.h" - -#include <camel/camel-folder.h> -#include <camel/camel-folder-summary.h> -#include <camel/camel-mime-message.h> - -/* check the total/unread is what we think it should be, everywhere it can be determined */ -void test_folder_counts(CamelFolder *folder, int total, int unread); -/* cross-check info/msg */ -void test_message_info(CamelMimeMessage *msg, const CamelMessageInfo *info); -/* check a message is present everywhere it should be */ -void test_folder_message(CamelFolder *folder, const char *uid); -/* check message not present everywhere it shouldn't be */ -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); diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c deleted file mode 100644 index 21d77582ad..0000000000 --- a/camel/tests/lib/messages.c +++ /dev/null @@ -1,154 +0,0 @@ -#include <string.h> - -#include "messages.h" -#include "camel-test.h" - -#include <camel/camel-mime-message.h> -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream-mem.h> - -CamelMimeMessage * -test_message_create_simple(void) -{ - CamelMimeMessage *msg; - CamelInternetAddress *addr; - - msg = camel_mime_message_new(); - - addr = camel_internet_address_new(); - camel_internet_address_add(addr, "Michael Zucchi", "zed@nowhere.com"); - camel_mime_message_set_from(msg, addr); - camel_address_remove((CamelAddress *)addr, -1); - camel_internet_address_add(addr, "POSTMASTER", "POSTMASTER@somewhere.net"); - camel_mime_message_set_recipients(msg, CAMEL_RECIPIENT_TYPE_TO, addr); - camel_address_remove((CamelAddress *)addr, -1); - camel_internet_address_add(addr, "Michael Zucchi", "zed@nowhere.com"); - camel_mime_message_set_recipients(msg, CAMEL_RECIPIENT_TYPE_CC, addr); - - check_unref(addr, 1); - - camel_mime_message_set_subject(msg, "Simple message subject"); - camel_mime_message_set_date(msg, time(0), 930); - - return msg; -} - -static void -content_finalise(CamelObject *folder, void *crap, void *ba) -{ - g_byte_array_free(ba, TRUE); -} - -void -test_message_set_content_simple(CamelMimePart *part, int how, const char *type, const char *text, int len) -{ - CamelStreamMem *content = NULL; - CamelDataWrapper *dw; - static GByteArray *ba; - - switch (how) { - case 0: - camel_mime_part_set_content(part, text, len, type); - break; - case 1: - content = (CamelStreamMem *)camel_stream_mem_new_with_buffer(text, len); - break; - case 2: - content = (CamelStreamMem *)camel_stream_mem_new(); - camel_stream_mem_set_buffer(content, text, len); - break; - case 3: - ba = g_byte_array_new(); - g_byte_array_append(ba, text, len); - - content = (CamelStreamMem *)camel_stream_mem_new_with_byte_array(ba); - ba = NULL; - break; - case 4: - ba = g_byte_array_new(); - g_byte_array_append(ba, text, len); - - content = (CamelStreamMem *)camel_stream_mem_new(); - camel_stream_mem_set_byte_array(content, ba); - - camel_object_hook_event((CamelObject *)content, "finalize", content_finalise, ba); - break; - } - - if (content != 0) { - dw = camel_data_wrapper_new(); - camel_data_wrapper_set_mime_type (dw, type); - - camel_data_wrapper_construct_from_stream(dw, (CamelStream *)content); - camel_medium_set_content_object((CamelMedium *)part, dw); - - check_unref(content, 2); - check_unref(dw, 2); - } -} - -int -test_message_write_file(CamelMimeMessage *msg, const char *name) -{ - CamelStreamFs *file; - int ret; - - file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_CREAT|O_WRONLY, 0600); - camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)file); - ret = camel_stream_close((CamelStream *)file); - - check(((CamelObject *)file)->ref_count == 1); - camel_object_unref((CamelObject *)file); - - return ret; -} - -CamelMimeMessage * -test_message_read_file(const char *name) -{ - CamelStreamFs *file; - CamelMimeMessage *msg2; - - file = (CamelStreamFs *)camel_stream_fs_new_with_name(name, O_RDONLY, 0); - msg2 = camel_mime_message_new(); - - camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg2, (CamelStream *)file); - /* file's refcount may be > 1 if the message is real big */ - check(CAMEL_OBJECT(file)->ref_count >=1); - camel_object_unref((CamelObject *)file); - - return msg2; -} - -int -test_message_compare_content(CamelDataWrapper *dw, const char *text, int len) -{ - CamelStreamMem *content; - - /* sigh, ok, so i len == 0, dw will probably be 0 too - camel_mime_part_set_content is weird like that */ - if (dw == 0 && len == 0) - return 0; - - content = (CamelStreamMem *)camel_stream_mem_new(); - camel_data_wrapper_write_to_stream(dw, (CamelStream *)content); - - check_msg(content->buffer->len == len, "buffer->len = %d, len = %d", content->buffer->len, len); - check_msg(memcmp(content->buffer->data, text, content->buffer->len) == 0, "len = %d", len); - - check_unref(content, 1); - - return 0; -} - -int -test_message_compare_header(CamelMimeMessage *m1, CamelMimeMessage *m2) -{ - return 0; -} - -int -test_message_compare_messages(CamelMimeMessage *m1, CamelMimeMessage *m2) -{ - return 0; -} diff --git a/camel/tests/lib/messages.h b/camel/tests/lib/messages.h deleted file mode 100644 index 9cb5758826..0000000000 --- a/camel/tests/lib/messages.h +++ /dev/null @@ -1,12 +0,0 @@ - -#include <camel/camel-mime-message.h> - -/* how many ways to set the content contents */ -#define SET_CONTENT_WAYS (5) - -/* messages.c */ -CamelMimeMessage *test_message_create_simple(void); -void test_message_set_content_simple(CamelMimePart *part, int how, const char *type, const char *text, int len); -int test_message_write_file(CamelMimeMessage *msg, const char *name); -CamelMimeMessage *test_message_read_file(const char *name); -int test_message_compare_content(CamelDataWrapper *dw, const char *text, int len); diff --git a/camel/tests/lib/session.c b/camel/tests/lib/session.c deleted file mode 100644 index 2ebf6e2d7f..0000000000 --- a/camel/tests/lib/session.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "session.h" - -static guint -register_timeout (CamelSession *session, guint32 interval, CamelTimeoutCallback callback, gpointer user_data) -{ - return 1; -} - -static gboolean -unregister_timeout (CamelSession *session, guint handle) -{ - return TRUE; -} - - -static void -class_init (CamelTestSessionClass *camel_test_session_class) -{ - CamelSessionClass *camel_session_class = - CAMEL_SESSION_CLASS (camel_test_session_class); - - /* virtual method override */ - camel_session_class->register_timeout = register_timeout; - camel_session_class->remove_timeout = unregister_timeout; -} - -CamelType -camel_test_session_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register ( - camel_session_get_type (), - "CamelTestSession", - sizeof (CamelTestSession), - sizeof (CamelTestSessionClass), - (CamelObjectClassInitFunc) class_init, - NULL, - NULL, - NULL); - } - - return type; -} - -CamelSession * -camel_test_session_new (const char *path) -{ - CamelSession *session; - - session = CAMEL_SESSION (camel_object_new (CAMEL_TEST_SESSION_TYPE)); - - camel_session_construct (session, path); - - return session; -} - - diff --git a/camel/tests/lib/session.h b/camel/tests/lib/session.h deleted file mode 100644 index e69ef65e2e..0000000000 --- a/camel/tests/lib/session.h +++ /dev/null @@ -1,19 +0,0 @@ -#include <camel/camel-session.h> - -#define CAMEL_TEST_SESSION_TYPE (camel_test_session_get_type ()) -#define CAMEL_TEST_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TEST_SESSION_TYPE, CamelTestSession)) -#define CAMEL_TEST_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TEST_SESSION_TYPE, CamelTestSessionClass)) -#define CAMEL_TEST_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_TEST_SESSION_TYPE)) - -typedef struct _CamelTestSession { - CamelSession parent_object; - -} CamelTestSession; - -typedef struct _CamelTestSessionClass { - CamelSessionClass parent_class; - -} CamelTestSessionClass; - -CamelType camel_test_session_get_type (void); -CamelSession *camel_test_session_new (const char *path); diff --git a/camel/tests/lib/streams.c b/camel/tests/lib/streams.c deleted file mode 100644 index e4dc006363..0000000000 --- a/camel/tests/lib/streams.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - stream tests - - todo: do we need a seek test that seeks beyond the eos, writes, - then reads and checks for 0's in the space? -*/ - -#include <string.h> - -#include "camel/camel-stream.h" -#include "camel/camel-seekable-stream.h" -#include "camel/camel-seekable-substream.h" - -#include "streams.h" - -#include "camel-test.h" - -static char teststring[] = "\xaa\x55\xc0\x0c\xff\x00"; -static char testbuf[10240]; - -/* pass in an empty read/write stream */ -void -test_stream_seekable_writepart(CamelSeekableStream *s) -{ - off_t end; - int i; - - push("seekable stream test, writing "); - - check(camel_seekable_stream_tell(s) == 0); - check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0); - check(camel_seekable_stream_tell(s) == 0); - - check(camel_stream_write(CAMEL_STREAM(s), "", 0) == 0); - check(camel_seekable_stream_tell(s) == 0); - check(camel_stream_write(CAMEL_STREAM(s), "\n", 1) == 1); - check(camel_seekable_stream_tell(s) == 1); - - for (i=0;i<10240;i++) { - check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring)); - check(camel_seekable_stream_tell(s) == 1 + (i+1)*sizeof(teststring)); - } - end = 10240*sizeof(teststring)+1; - - check_msg(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end, "seek =%d end = %d", - camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END), end); - - check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_END) == end); - check(camel_seekable_stream_tell(s) == end); - /* need to read 0 first to set eos */ - check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0); - check(camel_stream_eos(CAMEL_STREAM(s))); - - pull(); -} - -void -test_stream_seekable_readpart(CamelSeekableStream *s) -{ - off_t off, new, end; - int i, j; - - push("seekable stream test, re-reading"); - - end = 10240*sizeof(teststring)+1; - - check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_SET) == 0); - check(camel_seekable_stream_tell(s) == 0); - check(!camel_stream_eos(CAMEL_STREAM(s))); - - off = 0; - for (i=0;i<1024;i++) { - - new = i*3; - - /* exercise all seek methods */ - switch(i % 3) { - case 0: - check(camel_seekable_stream_seek(s, new, CAMEL_STREAM_SET) == new); - break; - case 1: - check(camel_seekable_stream_seek(s, new-off, CAMEL_STREAM_CUR) == new); - break; - case 2: - check(camel_seekable_stream_seek(s, new-end, CAMEL_STREAM_END) == new); - break; - } - check(camel_seekable_stream_tell(s) == new); - - check(camel_stream_read(CAMEL_STREAM(s), testbuf, i*3) == i*3); - for (j=0;j<i*3;j++) { - int k = new + j; - - if (k==0) { - check(testbuf[j] == '\n'); - } else { - check(testbuf[j] == teststring[(k-1) % sizeof(teststring)]); - } - } - off = new+i*3; - } - - /* verify end-of-file behaviour */ - check(camel_seekable_stream_seek(s, -1, CAMEL_STREAM_END) == end-1); - check(camel_seekable_stream_tell(s) == end-1); - - check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 1); - check(testbuf[0] == teststring[sizeof(teststring)-1]); - - check(camel_stream_read(CAMEL_STREAM(s), testbuf, 10240) == 0); - check(camel_seekable_stream_seek(s, 0, CAMEL_STREAM_CUR) == end); - check(camel_seekable_stream_tell(s) == end); - check(camel_stream_eos(CAMEL_STREAM(s))); - - pull(); -} - -/* - 0 = write to the substream - 1 = write to the parent stream at the right spot -*/ -void -test_seekable_substream_writepart(CamelStream *s, int type) -{ - CamelSeekableStream *ss = (CamelSeekableStream *)s; - CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s; - CamelSeekableStream *sp = sus->parent_stream; - int i, len; - off_t end; - - push("writing substream, type %d", type); - - if (type == 1) { - check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start); - s = (CamelStream *)sp; - } else { - check(camel_seekable_stream_tell(ss) == ss->bound_start); - check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start); - } - - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start); - - check(camel_stream_write(s, "", 0) == 0); - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start); - - /* fill up the bounds with writes */ - if (ss->bound_end != CAMEL_STREAM_UNBOUND) { - for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) { - check(camel_stream_write(s, teststring, sizeof(teststring)) == sizeof(teststring)); - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring)); - } - len = (ss->bound_end-ss->bound_start) % sizeof(teststring); - check(camel_stream_write(s, teststring, len) == len); - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end); - if (type == 0) { - check(camel_stream_write(s, teststring, sizeof(teststring)) == 0); - check(camel_stream_eos(s)); - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_end); - } - } else { - /* just 10K */ - for (i=0;i<10240;i++) { - check(camel_stream_write(CAMEL_STREAM(s), teststring, sizeof(teststring)) == sizeof(teststring)); - check(camel_seekable_stream_tell(CAMEL_SEEKABLE_STREAM(s)) == ss->bound_start + (i+1)*sizeof(teststring)); - } - - /* we can't really verify any end length here */ - } - - pull(); -} - -void -test_seekable_substream_readpart(CamelStream *s) -{ - CamelSeekableStream *ss = (CamelSeekableStream *)s; - CamelSeekableSubstream *sus = (CamelSeekableSubstream *)s; - CamelSeekableStream *sp = sus->parent_stream; - int i, len; - off_t end; - - push("reading substream"); - - check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_SET) == ss->bound_start); - check(camel_seekable_stream_tell(ss) == ss->bound_start); - - check(camel_seekable_stream_seek(sp, ss->bound_start, CAMEL_STREAM_SET) == ss->bound_start); - check(camel_seekable_stream_tell(sp) == ss->bound_start); - - /* check writes, cross check with parent stream */ - if (ss->bound_end != CAMEL_STREAM_UNBOUND) { - for (i=0;i<(ss->bound_end-ss->bound_start)/sizeof(teststring);i++) { - check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring)); - check(memcmp(testbuf, teststring, sizeof(teststring)) == 0); - check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring)); - - /* yeah great, the substreams affect the seek ... */ - check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring)); - check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring)); - check(memcmp(testbuf, teststring, sizeof(teststring)) == 0); - check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring)); - } - len = (ss->bound_end-ss->bound_start) % sizeof(teststring); - check(camel_stream_read(s, testbuf, len) == len); - check(memcmp(testbuf, teststring, len) == 0); - - check(camel_seekable_stream_seek(sp, ss->bound_end - len, CAMEL_STREAM_SET) == ss->bound_end - len); - check(camel_stream_read(CAMEL_STREAM(sp), testbuf, len) == len); - check(memcmp(testbuf, teststring, len) == 0); - - check(camel_stream_eos(s)); - check(camel_seekable_stream_tell(ss) == ss->bound_end); - check(camel_seekable_stream_tell(sp) == ss->bound_end); - check(camel_stream_read(s, testbuf, 1024) == 0); - check(camel_seekable_stream_tell(ss) == ss->bound_end); - check(camel_seekable_stream_tell(sp) == ss->bound_end); - check(camel_stream_eos(s)); - } else { - /* just 10K */ - for (i=0;i<10240;i++) { - check(camel_stream_read(s, testbuf, sizeof(teststring)) == sizeof(teststring)); - check(memcmp(testbuf, teststring, sizeof(teststring)) == 0); - check(camel_seekable_stream_tell(ss) == ss->bound_start + (i+1)*sizeof(teststring)); - - check(camel_seekable_stream_seek(sp, ss->bound_start + (i)*sizeof(teststring), CAMEL_STREAM_SET) == ss->bound_start + i*sizeof(teststring)); - check(camel_stream_read(CAMEL_STREAM(sp), testbuf, sizeof(teststring)) == sizeof(teststring)); - check(memcmp(testbuf, teststring, sizeof(teststring)) == 0); - check(camel_seekable_stream_tell(sp) == ss->bound_start + (i+1)*sizeof(teststring)); - } - - /* unbound - we dont know the real length */ -#if 0 - end = 10240*sizeof(teststring)+ss->bound_start; - - check(camel_seekable_stream_seek(ss, 0, CAMEL_STREAM_END) == end); - check(camel_seekable_stream_tell(ss) == end); - /* need to read 0 first to set eos */ - check(camel_stream_read(s, testbuf, 10240) == 0); - check(camel_stream_eos(s)); -#endif - } - - pull(); -} diff --git a/camel/tests/lib/streams.h b/camel/tests/lib/streams.h deleted file mode 100644 index df52e283d0..0000000000 --- a/camel/tests/lib/streams.h +++ /dev/null @@ -1,12 +0,0 @@ - -#include "camel/camel-seekable-stream.h" - -/* call one, then the other on the same stream content */ -void test_stream_seekable_writepart(CamelSeekableStream *s); -void test_stream_seekable_readpart(CamelSeekableStream *s); - -/* same, for substreams, multiple ways of writing */ -#define SEEKABLE_SUBSTREAM_WAYS (2) - -void test_seekable_substream_writepart(CamelStream *s, int type); -void test_seekable_substream_readpart(CamelStream *s); diff --git a/camel/tests/message/.cvsignore b/camel/tests/message/.cvsignore deleted file mode 100644 index 4f58c83bd0..0000000000 --- a/camel/tests/message/.cvsignore +++ /dev/null @@ -1,15 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -test1 -test2 -test3 -*.msg -*.bb -*.bbg -*.da -*.gcov diff --git a/camel/tests/message/Makefile.am b/camel/tests/message/Makefile.am deleted file mode 100644 index 5487a13f42..0000000000 --- a/camel/tests/message/Makefile.am +++ /dev/null @@ -1,23 +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 \ - test2 \ - test3 - -TESTS = test1 test2 test3 - - - diff --git a/camel/tests/message/README b/camel/tests/message/README deleted file mode 100644 index 280344ce9b..0000000000 --- a/camel/tests/message/README +++ /dev/null @@ -1,5 +0,0 @@ - -test1 creating, saving, loading simple messages -test2 camelinternetaddress tests, internationalised addresses, etc. -test3 multipart messages - diff --git a/camel/tests/message/test1.c b/camel/tests/message/test1.c deleted file mode 100644 index 3294000550..0000000000 --- a/camel/tests/message/test1.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - test1.c - - Create a message, save it. - - Retrieve message, compare content. - - - Operations: - writing/loading from different types of streams - reading/writing different content - reading/writing different encodings - reading/writing different charsets - - Just testing streams: - different stream types - different file ops - seek, eof, etc. -*/ - -#include "camel-test.h" -#include "messages.h" - -/* for stat */ -#include <sys/stat.h> -#include <unistd.h> - -#include <camel/camel-mime-message.h> -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream-mem.h> - -struct _text { - char *text; - int len; -}; - -#define MAX_TEXTS (14) -struct _text texts[MAX_TEXTS]; - -static void -setup(void) -{ - int i, j; - char *p; - - /* setup various edge and other general cases */ - texts[0].text = ""; - texts[0].len = 0; - texts[1].text = ""; - texts[1].len = 1; - texts[2].text = "\n"; - texts[2].len = 1; - texts[3].text = "A"; - texts[3].len = 1; - texts[4].text = "This is a test.\n."; - texts[4].len = strlen(texts[4].text); - texts[5].text = "This is a test.\n\n.\n"; - texts[5].len = strlen(texts[5].text); - texts[6].text = g_malloc0(1024); - texts[6].len = 1024; - texts[7].text = g_malloc0(102400); - texts[7].len = 102400; - texts[8].text = g_malloc(1024); - memset(texts[8].text, '\n', 1024); - texts[8].len = 1024; - texts[9].text = g_malloc(102400); - memset(texts[9].text, '\n', 102400); - texts[9].len = 102400; - texts[10].text = g_malloc(1024); - memset(texts[10].text, ' ', 1024); - texts[10].len = 1024; - texts[11].text = g_malloc(102400); - memset(texts[11].text, ' ', 102400); - texts[11].len = 102400; - - srand(42); - p = texts[12].text = g_malloc(1024); - for (i=0;i<1024;i++) { - j = rand(); - if (j<RAND_MAX/120) - *p++ = '\n'; - else - *p++ = (j % 95) + 32; - } - texts[12].len = 1024; - p = texts[13].text = g_malloc(102400); - for (i=0;i<102400;i++) { - j = rand(); - if (j<RAND_MAX/120) - *p++ = '\n'; - else - *p++ = (j % 95) + 32; - } - texts[13].len = 102400; -} - -static void cleanup(void) -{ - int i; - - for (i=6;i<14;i++) { - g_free(texts[i].text); - } -} - -int main(int argc, char **argv) -{ - CamelMimeMessage *msg, *msg2; - int i, j; - char *text; - int len; - - camel_test_init(argc, argv); - - setup(); - - camel_test_start("Simple memory-based content creation"); - - /* test all ways of setting simple content for a message (i.e. memory based) */ - for (j=0;j<MAX_TEXTS;j++) { - push("testing text number %d", j); - text = texts[j].text; - len = texts[j].len; - for (i=0;i<SET_CONTENT_WAYS;i++) { - push("create simple message %d", i); - msg = test_message_create_simple(); - - push("set simple content"); - test_message_set_content_simple((CamelMimePart *)msg, i, "text/plain", text, len); - pull(); - - push("compare original content"); - test_message_compare_content(camel_medium_get_content_object((CamelMedium *)msg), text, len); - pull(); - - push("save message to test1.msg"); - unlink("test1.msg"); - test_message_write_file(msg, "test1.msg"); - check_unref(msg, 1); - pull(); - - push("read from test1.msg"); - msg2 = test_message_read_file("test1.msg"); - pull(); - - push("compare read with original content"); - test_message_compare_content(camel_medium_get_content_object((CamelMedium *)msg2), text, len); - check_unref(msg2, 1); - pull(); - - unlink("test1.msg"); - pull(); - } - pull(); - } - - camel_test_end(); - - camel_test_start("Different encodings"); - for (j=0;j<MAX_TEXTS;j++) { - push("testing text number %d", j); - text = texts[j].text; - len = texts[j].len; - for (i=0;i<CAMEL_MIME_PART_NUM_ENCODINGS;i++) { - - push("test simple message, encoding %s", camel_mime_part_encoding_to_string(i)); - msg = test_message_create_simple(); - - push("set simple content"); - test_message_set_content_simple((CamelMimePart *)msg, 0, "text/plain", text, len); - pull(); - - camel_mime_part_set_encoding((CamelMimePart *)msg, i); - - push("save message to test1.msg"); - unlink("test1.msg"); - test_message_write_file(msg, "test1.msg"); - check_unref(msg, 1); - pull(); - - push("read from test1.msg"); - msg2 = test_message_read_file("test1.msg"); - pull(); - - push("compare read with original content"); - test_message_compare_content(camel_medium_get_content_object((CamelMedium *)msg2), text, len); - check_unref(msg2, 1); - pull(); - - unlink("test1.msg"); - pull(); - } - pull(); - } - camel_test_end(); - - cleanup(); - - return 0; -} diff --git a/camel/tests/message/test2.c b/camel/tests/message/test2.c deleted file mode 100644 index 95b0e324aa..0000000000 --- a/camel/tests/message/test2.c +++ /dev/null @@ -1,326 +0,0 @@ -#include "camel-test.h" -#include "messages.h" -#include "addresses.h" - -/* for stat */ -#include <sys/stat.h> -#include <unistd.h> -#include <string.h> -#include <stdio.h> -#include <iconv.h> - -#include <camel/camel-internet-address.h> -#include <camel/camel-address.h> - -#include "address-data.h" - -static char *convert(const char *in, const char *from, const char *to) -{ - iconv_t ic = iconv_open(to, from); - char *out, *outp; - const char *inp; - int inlen, outlen; - - if (ic == (iconv_t)-1) - return g_strdup(in); - - inlen = strlen(in); - outlen = inlen*5 + 16; - - outp = out = g_malloc(outlen); - inp = in; - - if (iconv(ic, &inp, &inlen, &outp, &outlen) == -1) { - test_free(out); - iconv_close(ic); - return g_strdup(in); - } - - if (iconv(ic, NULL, 0, &outp, &outlen) == -1) { - test_free(out); - iconv_close(ic); - return g_strdup(in); - } - - iconv_close(ic); - - *outp = 0; - -#if 0 - /* lets see if we can convert back again? */ - { - char *nout, *noutp; - iconv_t ic = iconv_open(from, to); - - inp = out; - inlen = strlen(out); - outlen = inlen*5 + 16; - noutp = nout = g_malloc(outlen); - if (iconv(ic, &inp, &inlen, &noutp, &outlen) == -1 - || iconv(ic, NULL, 0, &noutp, &outlen) == -1) { - g_warning("Cannot convert '%s' \n from %s to %s: %s\n", in, to, from, strerror(errno)); - } - iconv_close(ic); - } - - /* and lets see what camel thinks out optimal charset is */ - { - printf("Camel thinks the best encoding of '%s' is %s, although we converted from %s\n", - in, camel_charset_best(out, strlen(out)), from); - } -#endif - - return out; -} - -#define to_utf8(in, type) convert(in, type, "utf-8") -#define from_utf8(in, type) convert(in, "utf-8", type) - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -int main(int argc, char **argv) -{ - int i; - CamelInternetAddress *addr, *addr2; - char *name; - char *charset; - const char *real, *where; - char *enc, *enc2, *format, *format2; - - camel_test_init(argc, argv); - - camel_test_start("CamelInternetAddress, basics"); - - addr = camel_internet_address_new(); - - push("Test blank address"); - check(camel_address_length(CAMEL_ADDRESS(addr)) == 0); - check(camel_internet_address_get(addr, 0, &real, &where) == FALSE); - pull(); - - push("Test blank clone"); - addr2 = CAMEL_INTERNET_ADDRESS(camel_address_new_clone(CAMEL_ADDRESS(addr))); - test_address_compare(addr, addr2); - check_unref(addr2, 1); - pull(); - - push("Test add 1"); - camel_internet_address_add(addr, "Zed", "nowhere@here.com.au"); - check(camel_address_length(CAMEL_ADDRESS(addr)) == 1); - check(camel_internet_address_get(addr, 0, &real, &where) == TRUE); - check_msg(string_equal("Zed", real), "real = '%s'", real); - check(strcmp(where, "nowhere@here.com.au") == 0); - pull(); - - push("Test clone 1"); - addr2 = CAMEL_INTERNET_ADDRESS(camel_address_new_clone(CAMEL_ADDRESS(addr))); - test_address_compare(addr, addr2); - check_unref(addr2, 1); - pull(); - - push("Test add many"); - for (i=1;i<10;i++) { - char name[16], a[32]; - sprintf(name, "Zed %d", i); - sprintf(a, "nowhere@here-%d.com.au", i); - camel_internet_address_add(addr, name, a); - check(camel_address_length(CAMEL_ADDRESS(addr)) == i+1); - check(camel_internet_address_get(addr, i, &real, &where) == TRUE); - check_msg(string_equal(name, real), "name = '%s' real = '%s'", name, real); - check(strcmp(where, a) == 0); - } - pull(); - - /* put a few of these in to make it look like its doing something impressive ... :) */ - camel_test_end(); - camel_test_start("CamelInternetAddress, search"); - - push("Test search"); - camel_test_nonfatal("Address comparisons should ignore whitespace??"); - check(camel_internet_address_find_name(addr, "Zed 1", &where) == 1); - check(camel_internet_address_find_name(addr, "Zed 9", &where) == 9); - check(camel_internet_address_find_name(addr, "Zed", &where) == 0); - check(camel_internet_address_find_name(addr, " Zed", &where) == 0); - check(camel_internet_address_find_name(addr, "Zed ", &where) == 0); - check(camel_internet_address_find_name(addr, " Zed ", &where) == 0); - check(camel_internet_address_find_name(addr, "Zed 20", &where) == -1); - check(camel_internet_address_find_name(addr, "", &where) == -1); - /* interface dont handle nulls :) */ - /*check(camel_internet_address_find_name(addr, NULL, &where) == -1);*/ - - check(camel_internet_address_find_address(addr, "nowhere@here-1.com.au", &where) == 1); - check(camel_internet_address_find_address(addr, "nowhere@here-1 . com.au", &where) == 1); - check(camel_internet_address_find_address(addr, "nowhere@here-2 .com.au ", &where) == 2); - check(camel_internet_address_find_address(addr, " nowhere @here-3.com.au", &where) == 3); - check(camel_internet_address_find_address(addr, "nowhere@here-20.com.au ", &where) == -1); - check(camel_internet_address_find_address(addr, "", &where) == -1); - /*check(camel_internet_address_find_address(addr, NULL, &where) == -1);*/ - camel_test_fatal(); - pull(); - - camel_test_end(); - camel_test_start("CamelInternetAddress, copy/cat/clone"); - - push("Test clone many"); - addr2 = CAMEL_INTERNET_ADDRESS(camel_address_new_clone(CAMEL_ADDRESS(addr))); - test_address_compare(addr, addr2); - pull(); - - push("Test remove items"); - camel_address_remove(CAMEL_ADDRESS(addr2), 0); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 9); - camel_address_remove(CAMEL_ADDRESS(addr2), 0); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 8); - camel_address_remove(CAMEL_ADDRESS(addr2), 5); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 7); - camel_address_remove(CAMEL_ADDRESS(addr2), 10); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 7); - camel_address_remove(CAMEL_ADDRESS(addr2), -1); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 0); - check_unref(addr2, 1); - pull(); - - push("Testing copy/cat"); - push("clone + cat"); - addr2 = CAMEL_INTERNET_ADDRESS(camel_address_new_clone(CAMEL_ADDRESS(addr))); - camel_address_cat(CAMEL_ADDRESS(addr2), CAMEL_ADDRESS(addr)); - check(camel_address_length(CAMEL_ADDRESS(addr)) == 10); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 20); - check_unref(addr2, 1); - pull(); - - push("cat + cat + copy"); - addr2 = camel_internet_address_new(); - camel_address_cat(CAMEL_ADDRESS(addr2), CAMEL_ADDRESS(addr)); - test_address_compare(addr, addr2); - camel_address_cat(CAMEL_ADDRESS(addr2), CAMEL_ADDRESS(addr)); - check(camel_address_length(CAMEL_ADDRESS(addr)) == 10); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 20); - camel_address_copy(CAMEL_ADDRESS(addr2), CAMEL_ADDRESS(addr)); - test_address_compare(addr, addr2); - check_unref(addr2, 1); - pull(); - - push("copy"); - addr2 = camel_internet_address_new(); - camel_address_copy(CAMEL_ADDRESS(addr2), CAMEL_ADDRESS(addr)); - test_address_compare(addr, addr2); - check_unref(addr2, 1); - pull(); - - pull(); - - check_unref(addr, 1); - - camel_test_end(); - - camel_test_start("CamelInternetAddress, I18N"); - - for (i=0;i<ARRAY_LEN(test_lines);i++) { - push("Testing text line %d (%s) '%s'", i, test_lines[i].type, test_lines[i].line); - - addr = camel_internet_address_new(); - - /* first, convert to api format (utf-8) */ - charset = test_lines[i].type; - name = to_utf8(test_lines[i].line, charset); - - push("Address setup"); - camel_internet_address_add(addr, name, "nobody@nowhere.com"); - check(camel_internet_address_get(addr, 0, &real, &where) == TRUE); - check_msg(string_equal(name, real), "name = '%s' real = '%s'", name, real); - check(strcmp(where, "nobody@nowhere.com") == 0); - test_free(name); - - check(camel_internet_address_get(addr, 1, &real, &where) == FALSE); - check(camel_address_length(CAMEL_ADDRESS(addr)) == 1); - pull(); - - push("Address encode/decode"); - enc = camel_address_encode(CAMEL_ADDRESS(addr)); - - addr2 = camel_internet_address_new(); - check(camel_address_decode(CAMEL_ADDRESS(addr2), enc) == 1); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 1); - - enc2 = camel_address_encode(CAMEL_ADDRESS(addr2)); - check_msg(string_equal(enc, enc2), "enc = '%s' enc2 = '%s'", enc, enc2); - test_free(enc2); - - push("Compare addresses"); - test_address_compare(addr, addr2); - pull(); - check_unref(addr2, 1); - test_free(enc); - pull(); - - /* FIXME: format/unformat arne't guaranteed to be reversible, at least at the moment */ - camel_test_nonfatal("format/unformat not (yet) reversible for all cases"); - - push("Address format/unformat"); - format = camel_address_format(CAMEL_ADDRESS(addr)); - - addr2 = camel_internet_address_new(); - check(camel_address_unformat(CAMEL_ADDRESS(addr2), format) == 1); - check(camel_address_length(CAMEL_ADDRESS(addr2)) == 1); - - format2 = camel_address_format(CAMEL_ADDRESS(addr2)); - check_msg(string_equal(format, format2), "format = '%s\n\tformat2 = '%s'", format, format2); - test_free(format2); - - /* currently format/unformat doesn't handle ,'s and other special chars at all */ - if (camel_address_length(CAMEL_ADDRESS(addr2)) == 1) { - push("Compare addresses"); - test_address_compare(addr, addr2); - pull(); - } - - test_free(format); - pull(); - - camel_test_fatal(); - - check_unref(addr2, 1); - - check_unref(addr, 1); - pull(); - - } - - camel_test_end(); - - camel_test_start("CamelInternetAddress, I18N decode"); - - for (i=0;i<ARRAY_LEN(test_address);i++) { - push("Testing address line %d '%s'", i, test_address[i].addr); - - addr = camel_internet_address_new(); - push("checking decoded"); - check(camel_address_decode(CAMEL_ADDRESS(addr), test_address[i].addr) == test_address[i].count); - format = camel_address_format(CAMEL_ADDRESS(addr)); - check(strcmp(format, test_address[i].utf8) == 0); - test_free(format); - pull(); - - push("Comparing re-encoded output"); - addr2 = CAMEL_INTERNET_ADDRESS(camel_internet_address_new()); - enc = camel_address_encode(CAMEL_ADDRESS(addr)); - check_msg(camel_address_decode(CAMEL_ADDRESS(addr2), enc) == test_address[i].count, "enc = '%s'", enc); - test_free(enc); - test_address_compare(addr, addr2); - check_unref(addr2, 1); - pull(); - - check_unref(addr, 1); - - pull(); - } - - camel_test_end(); - - /* FIXME: Add test of decoding of broken addresses */ - - return 0; -} - - diff --git a/camel/tests/message/test3.c b/camel/tests/message/test3.c deleted file mode 100644 index 0a9683d146..0000000000 --- a/camel/tests/message/test3.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - Multipart. -*/ - -#include "camel-test.h" -#include "messages.h" - -/* for stat */ -#include <sys/stat.h> -#include <unistd.h> -#include <string.h> - -#include <camel/camel-mime-message.h> -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream-mem.h> -#include "camel/camel-multipart.h" - -int main(int argc, char **argv) -{ - CamelMimeMessage *msg, *msg2, *msg3; - CamelMultipart *mp, *mp2; - CamelMimePart *part, *part2, *part3; - - camel_test_init(argc, argv); - - camel_test_start("multipart message"); - - push("building message"); - msg = test_message_create_simple(); - mp = camel_multipart_new(); - - /* Hrm, this should be able to set its own boundary, no? */ - camel_multipart_set_boundary(mp, "_=,.XYZ_Kangaroo_Meat_is_!_ABADF00D"); - check(strcmp(camel_multipart_get_boundary(mp), "_=,.XYZ_Kangaroo_Meat_is_!_ABADF00D") == 0); - - camel_medium_set_content_object((CamelMedium *)msg, (CamelDataWrapper *)mp); - check(camel_multipart_get_number(mp) == 0); - check(camel_multipart_get_part(mp, 0) == NULL); - check(camel_multipart_get_part(mp, 1) == NULL); - - push("adding/removing parts"); - part = camel_mime_part_new(); - test_message_set_content_simple(part, 0, "text/plain", "content part 1", strlen("content part 1")); - camel_multipart_add_part(mp, part); - check(CAMEL_OBJECT(part)->ref_count == 2); - check(camel_multipart_get_number(mp) == 1); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == NULL); - - camel_multipart_remove_part(mp, part); - check(CAMEL_OBJECT(part)->ref_count == 1); - check(camel_multipart_get_number(mp) == 0); - check(camel_multipart_get_part(mp, 0) == NULL); - check(camel_multipart_get_part(mp, 1) == NULL); - - camel_multipart_add_part_at(mp, part, 0); - check(CAMEL_OBJECT(part)->ref_count == 2); - check(camel_multipart_get_number(mp) == 1); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == NULL); - - check(camel_multipart_remove_part_at(mp, 1) == NULL); - check(CAMEL_OBJECT(part)->ref_count == 2); - check(camel_multipart_get_number(mp) == 1); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == NULL); - - check(camel_multipart_remove_part_at(mp, 0) == part); - check(CAMEL_OBJECT(part)->ref_count == 1); - check(camel_multipart_get_number(mp) == 0); - check(camel_multipart_get_part(mp, 0) == NULL); - check(camel_multipart_get_part(mp, 1) == NULL); - - camel_multipart_add_part(mp, part); - check(CAMEL_OBJECT(part)->ref_count == 2); - check(camel_multipart_get_number(mp) == 1); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == NULL); - - part2 = camel_mime_part_new(); - test_message_set_content_simple(part2, 0, "text/plain", "content part 2", strlen("content part 2")); - camel_multipart_add_part(mp, part2); - check(CAMEL_OBJECT(part2)->ref_count == 2); - check(camel_multipart_get_number(mp) == 2); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == part2); - - part3 = camel_mime_part_new(); - test_message_set_content_simple(part3, 0, "text/plain", "content part 3", strlen("content part 3")); - camel_multipart_add_part_at(mp, part3, 1); - check(CAMEL_OBJECT(part3)->ref_count == 2); - check(camel_multipart_get_number(mp) == 3); - check(camel_multipart_get_part(mp, 0) == part); - check(camel_multipart_get_part(mp, 1) == part3); - check(camel_multipart_get_part(mp, 2) == part2); - pull(); - - push("save message to test3.msg"); - unlink("test3.msg"); - test_message_write_file(msg, "test3.msg"); - pull(); - - push("read from test3.msg"); - msg2 = test_message_read_file("test3.msg"); - pull(); - - push("compre content of multipart"); - mp2 = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)msg2); - check(mp2 != NULL); - check(CAMEL_IS_MULTIPART(mp2)); - check(camel_multipart_get_number(mp2) == 3); - - check(strcmp(camel_multipart_get_boundary(mp2), "_=,.XYZ_Kangaroo_Meat_is_!_ABADF00D") == 0); - check(mp2->preface == NULL || strlen(mp2->preface) == 0); - - /* FIXME */ - camel_test_nonfatal("postface may gain a single \\n?"); - check_msg(mp2->postface == NULL || strlen(mp2->postface) == 0, "postface: '%s'", mp2->postface); - camel_test_fatal(); - - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 0))), - "content part 1", strlen("content part 1")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 1))), - "content part 3", strlen("content part 3")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 2))), - "content part 2", strlen("content part 2")); - pull(); - - push("writing again, & re-reading"); - unlink("test3-2.msg"); - test_message_write_file(msg2, "test3-2.msg"); - msg3 = test_message_read_file("test3-2.msg"); - - push("comparing again"); - mp2 = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)msg3); - check(mp2 != NULL); - check(CAMEL_IS_MULTIPART(mp2)); - check(camel_multipart_get_number(mp2) == 3); - - check(strcmp(camel_multipart_get_boundary(mp2), "_=,.XYZ_Kangaroo_Meat_is_!_ABADF00D") == 0); - check(mp2->preface == NULL || strlen(mp2->preface) == 0); - - /* FIXME */ - camel_test_nonfatal("postface may gain a single \\n?"); - check_msg(mp2->postface == NULL || strlen(mp2->postface) == 0, "postface: '%s'", mp2->postface); - camel_test_fatal(); - - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 0))), - "content part 1", strlen("content part 1")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 1))), - "content part 3", strlen("content part 3")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 2))), - "content part 2", strlen("content part 2")); - pull(); - pull(); - - check_unref(msg2, 1); - check_unref(msg3, 1); - - push("testing pre/post text"); - camel_multipart_set_preface(mp, "pre-text\nLines."); - camel_multipart_set_postface(mp, "post-text, no lines.\nOne line.\n"); - - check(strcmp(mp->preface, "pre-text\nLines.") == 0); - check(strcmp(mp->postface, "post-text, no lines.\nOne line.\n") == 0); - - push("writing /re-reading"); - unlink("test3-3.msg"); - test_message_write_file(msg, "test3-3.msg"); - msg2 = test_message_read_file("test3-3.msg"); - - mp2 = (CamelMultipart *)camel_medium_get_content_object((CamelMedium *)msg2); - check(mp2 != NULL); - check(CAMEL_IS_MULTIPART(mp2)); - check(camel_multipart_get_number(mp2) == 3); - - check(strcmp(camel_multipart_get_boundary(mp2), "_=,.XYZ_Kangaroo_Meat_is_!_ABADF00D") == 0); - check(strcmp(mp2->preface, "pre-text\nLines.") == 0); - check(strcmp(mp2->postface, "post-text, no lines.\nOne line.\n") == 0); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 0))), - "content part 1", strlen("content part 1")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 1))), - "content part 3", strlen("content part 3")); - test_message_compare_content(camel_medium_get_content_object(CAMEL_MEDIUM(camel_multipart_get_part(mp2, 2))), - "content part 2", strlen("content part 2")); - pull(); - check_unref(msg2, 1); - pull(); - - check_unref(msg, 1); - check_unref(mp, 1); - check_unref(part, 1); - check_unref(part2, 1); - check_unref(part3, 1); - - camel_test_end(); - - return 0; -} diff --git a/camel/tests/mime-filter/.cvsignore b/camel/tests/mime-filter/.cvsignore deleted file mode 100644 index c1f16ee7d4..0000000000 --- a/camel/tests/mime-filter/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -*.lo -*.la -test-stripheader -test-crlf diff --git a/camel/tests/mime-filter/Makefile.am b/camel/tests/mime-filter/Makefile.am deleted file mode 100644 index d3c2a7d29f..0000000000 --- a/camel/tests/mime-filter/Makefile.am +++ /dev/null @@ -1,39 +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\" \ - -DSOURCEDIR=\"$(srcdir)\" - -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) - -EXTRA_DIST = \ - crlf-1.in \ - crlf-1.out \ - stripheader-1.in \ - stripheader-1.out \ - stripheader-2.in \ - stripheader-2.out \ - stripheader-3.in \ - stripheader-3.out \ - stripheader-4.in \ - stripheader-4.out \ - stripheader-5.in \ - stripheader-5.out \ - stripheader-6.in \ - stripheader-6.out - -check_PROGRAMS = \ - test-crlf \ - test-stripheader - -TESTS = test-crlf test-stripheader - - - diff --git a/camel/tests/mime-filter/crlf-1.in b/camel/tests/mime-filter/crlf-1.in deleted file mode 100644 index d98703c725..0000000000 --- a/camel/tests/mime-filter/crlf-1.in +++ /dev/null @@ -1,19 +0,0 @@ -This is some text to filter and stuff. Hopefully that . will not become '..' -when the filter is run on this text. It should, however, '..' the next line -. The previous . should become .. in the output file, or so I hope... - -. -.. -... -.... - -Once this text is decoded again, the above set of dots should look like: - - . - .. - ... - .... - -Only it shouldn't be indented, obviously. - -Jeff
\ No newline at end of file diff --git a/camel/tests/mime-filter/crlf-1.out b/camel/tests/mime-filter/crlf-1.out deleted file mode 100644 index c0b688f334..0000000000 --- a/camel/tests/mime-filter/crlf-1.out +++ /dev/null @@ -1,19 +0,0 @@ -This is some text to filter and stuff. Hopefully that . will not become '..'
-when the filter is run on this text. It should, however, '..' the next line
-.. The previous . should become .. in the output file, or so I hope...
-
-..
-...
-....
-.....
-
-Once this text is decoded again, the above set of dots should look like:
-
- .
- ..
- ...
- ....
-
-Only it shouldn't be indented, obviously.
-
-Jeff
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-1.in b/camel/tests/mime-filter/stripheader-1.in deleted file mode 100644 index 1db4bf86e3..0000000000 --- a/camel/tests/mime-filter/stripheader-1.in +++ /dev/null @@ -1,6 +0,0 @@ -Subject: this is a simple test -Stripped: of the header stripping filter -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-1.out b/camel/tests/mime-filter/stripheader-1.out deleted file mode 100644 index 3101c1e6bd..0000000000 --- a/camel/tests/mime-filter/stripheader-1.out +++ /dev/null @@ -1,5 +0,0 @@ -Subject: this is a simple test -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-2.in b/camel/tests/mime-filter/stripheader-2.in deleted file mode 100644 index 0a16133bc0..0000000000 --- a/camel/tests/mime-filter/stripheader-2.in +++ /dev/null @@ -1,8 +0,0 @@ -Subject: this is a simple test -Stripped: of the header stripping filter -CC: this header should be preserved -Stripped: this header should also be stripped -BCC: but not this one - -This is the body of the message. -There are several lines to it. Oh boy oh boy.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-2.out b/camel/tests/mime-filter/stripheader-2.out deleted file mode 100644 index 626dd9c170..0000000000 --- a/camel/tests/mime-filter/stripheader-2.out +++ /dev/null @@ -1,6 +0,0 @@ -Subject: this is a simple test -CC: this header should be preserved -BCC: but not this one - -This is the body of the message. -There are several lines to it. Oh boy oh boy.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-3.in b/camel/tests/mime-filter/stripheader-3.in deleted file mode 100644 index d7c348125b..0000000000 --- a/camel/tests/mime-filter/stripheader-3.in +++ /dev/null @@ -1,9 +0,0 @@ -Subject: this is a simple test with a different subject -Stripped: of the header stripping filter -Stripped: this header should also be stripped -CC: this header should be preserved -BCC: and so should this one - -This is the body of the message. -There are several lines to it. Oh boy oh boy. -Let's add lots of characters on this line just for fun because I love fun don't you who wouldn't love fun I sure do.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-3.out b/camel/tests/mime-filter/stripheader-3.out deleted file mode 100644 index a6da94594e..0000000000 --- a/camel/tests/mime-filter/stripheader-3.out +++ /dev/null @@ -1,7 +0,0 @@ -Subject: this is a simple test with a different subject -CC: this header should be preserved -BCC: and so should this one - -This is the body of the message. -There are several lines to it. Oh boy oh boy. -Let's add lots of characters on this line just for fun because I love fun don't you who wouldn't love fun I sure do.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-4.in b/camel/tests/mime-filter/stripheader-4.in deleted file mode 100644 index 5b0b12e080..0000000000 --- a/camel/tests/mime-filter/stripheader-4.in +++ /dev/null @@ -1,7 +0,0 @@ -Subject: this is a simple test -Stripped: of the header stripping filter - ooh look this header spans two lines. -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-4.out b/camel/tests/mime-filter/stripheader-4.out deleted file mode 100644 index 3101c1e6bd..0000000000 --- a/camel/tests/mime-filter/stripheader-4.out +++ /dev/null @@ -1,5 +0,0 @@ -Subject: this is a simple test -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-5.in b/camel/tests/mime-filter/stripheader-5.in deleted file mode 100644 index 99258daec6..0000000000 --- a/camel/tests/mime-filter/stripheader-5.in +++ /dev/null @@ -1,9 +0,0 @@ -Subject: this is a simple test -Stripped: of the header stripping filter - ooh look this header spans many - lines look at all the freaking lines - that this header spans. Wowwww. -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-5.out b/camel/tests/mime-filter/stripheader-5.out deleted file mode 100644 index 3101c1e6bd..0000000000 --- a/camel/tests/mime-filter/stripheader-5.out +++ /dev/null @@ -1,5 +0,0 @@ -Subject: this is a simple test -CC: this header should be preserved -BCC: as should this one - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-6.in b/camel/tests/mime-filter/stripheader-6.in deleted file mode 100644 index 8bf0e848d0..0000000000 --- a/camel/tests/mime-filter/stripheader-6.in +++ /dev/null @@ -1,15 +0,0 @@ -Subject: this is a simple test -Stripped: of the header stripping filter - ooh look this header spans many - lines look at all the freaking lines - that this header spans. Wowwww. -Stripped: and then another one to strip that extends fairly far across the page -Other: let's not use CC here. -Stripped: oops, I stripped it again -Stripped: then single line.... - followed by multi-line. Huzzah. -NotBCC: definitely not BCC - however this one is definitely continued -Stripped: god-damn look at that stripping. - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/stripheader-6.out b/camel/tests/mime-filter/stripheader-6.out deleted file mode 100644 index d8d4202ed0..0000000000 --- a/camel/tests/mime-filter/stripheader-6.out +++ /dev/null @@ -1,6 +0,0 @@ -Subject: this is a simple test -Other: let's not use CC here. -NotBCC: definitely not BCC - however this one is definitely continued - -This is the body of the message.
\ No newline at end of file diff --git a/camel/tests/mime-filter/test-crlf.c b/camel/tests/mime-filter/test-crlf.c deleted file mode 100644 index 2e8a4333fa..0000000000 --- a/camel/tests/mime-filter/test-crlf.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - test-crlf.c - - Test the CamelMimeFilterCrlf class -*/ - -#include <stdio.h> -#include <string.h> - -#include "camel-test.h" - -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream-mem.h> -#include <camel/camel-stream-filter.h> -#include <camel/camel-mime-filter-crlf.h> - -#define d(x) x - -#define NUM_CASES 1 -#define CHUNK_SIZE 32 - -enum { - CRLF_ENCODE, - CRLF_DECODE, - CRLF_DONE -}; - -int -main (int argc, char **argv) -{ - CamelStream *source; - CamelStream *correct; - CamelStreamFilter *filter; - CamelMimeFilter *sh; - gchar *work; - int i; - ssize_t comp_progress, comp_correct_chunk, comp_filter_chunk; - int comp_i; - char comp_correct[CHUNK_SIZE], comp_filter[CHUNK_SIZE]; - - camel_test_init(argc, argv); - - for (i = 0; i < NUM_CASES; i++) { - int j; - - work = g_strdup_printf ("CRLF/DOT filter, test case %d", i); - camel_test_start (work); - g_free (work); - - for (j = CRLF_ENCODE; j < CRLF_DONE; j++) { - CamelMimeFilterCRLFDirection direction; - char *infile, *outfile; - - switch (j) { - case CRLF_ENCODE: - camel_test_push ("Test of the encoder"); - direction = CAMEL_MIME_FILTER_CRLF_ENCODE; - infile = g_strdup_printf ("%s/crlf-%d.in", SOURCEDIR, i + 1); - outfile = g_strdup_printf ("%s/crlf-%d.out", SOURCEDIR, i + 1); - break; - case CRLF_DECODE: - camel_test_push ("Test of the decoder"); - direction = CAMEL_MIME_FILTER_CRLF_DECODE; - infile = g_strdup_printf ("%s/crlf-%d.out", SOURCEDIR, i + 1); - outfile = g_strdup_printf ("%s/crlf-%d.in", SOURCEDIR, i + 1); - break; - default: - break; - } - - camel_test_push ("Initializing objects"); - source = camel_stream_fs_new_with_name (infile, 0, O_RDONLY); - if (!source) { - camel_test_fail ("Failed to open input case in \"%s\"", infile); - g_free (infile); - continue; - } - g_free (infile); - - correct = camel_stream_fs_new_with_name (outfile, 0, O_RDONLY); - if (!correct) { - camel_test_fail ("Failed to open correct output in \"%s\"", outfile); - g_free (outfile); - continue; - } - g_free (outfile); - - filter = camel_stream_filter_new_with_stream (CAMEL_STREAM (source)); - if (!filter) { - camel_test_fail ("Couldn't create CamelStreamFilter??"); - continue; - } - - sh = camel_mime_filter_crlf_new (direction, CAMEL_MIME_FILTER_CRLF_MODE_CRLF_DOTS); - if (!sh) { - camel_test_fail ("Couldn't create CamelMimeFilterCrlf??"); - continue; - } - - camel_stream_filter_add (filter, sh); - camel_test_pull (); - - camel_test_push ("Running filter and comparing to correct result"); - - comp_progress = 0; - - while (1) { - comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE); - comp_filter_chunk = 0; - - if (comp_correct_chunk == 0) - break; - - while (comp_filter_chunk < comp_correct_chunk) { - ssize_t delta; - - delta = camel_stream_read (CAMEL_STREAM (filter), - comp_filter + comp_filter_chunk, - CHUNK_SIZE - comp_filter_chunk); - - if (delta == 0) { - camel_test_fail ("Chunks are different sizes: correct is %d, " - "filter is %d, %d bytes into stream", - comp_correct_chunk, comp_filter_chunk, comp_progress); - } - - comp_filter_chunk += delta; - } - - d(printf ("\n\nCORRECT: >>%.*s<<", comp_correct_chunk, comp_correct)); - d(printf ("\nFILTER : >>%.*s<<\n", comp_filter_chunk, comp_filter)); - - for (comp_i = 0; comp_i < comp_filter_chunk; comp_i++) { - if (comp_correct[comp_i] != comp_filter[comp_i]) { - camel_test_fail ("Difference: correct is %c, filter is %c, " - "%d bytes into stream", - comp_correct[comp_i], - comp_filter[comp_i], - comp_progress + comp_i); - } - } - - comp_progress += comp_filter_chunk; - } - - camel_test_pull (); - - /* inefficient */ - camel_test_push ("Cleaning up"); - camel_object_unref (CAMEL_OBJECT (filter)); - camel_object_unref (CAMEL_OBJECT (correct)); - camel_object_unref (CAMEL_OBJECT (source)); - camel_object_unref (CAMEL_OBJECT (sh)); - camel_test_pull (); - - camel_test_pull (); - } - - camel_test_end (); - } - - return 0; -} diff --git a/camel/tests/mime-filter/test-stripheader.c b/camel/tests/mime-filter/test-stripheader.c deleted file mode 100644 index ff5446635b..0000000000 --- a/camel/tests/mime-filter/test-stripheader.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - test-stripheader.c - - Test the CamelMimeFilterStripHeader class -*/ - -#include <stdio.h> -#include <string.h> - -#include "camel-test.h" - -#include <camel/camel-stream-fs.h> -#include <camel/camel-stream-mem.h> -#include <camel/camel-stream-filter.h> -#include <camel/camel-mime-filter-stripheader.h> - -#define d(x) x - -#define NUM_CASES 6 -#define CHUNK_SIZE 32 - -int -main(int argc, char **argv) -{ - CamelStream *source; - CamelStream *correct; - CamelStreamFilter *filter; - CamelMimeFilter *sh; - gchar *work; - int i; - ssize_t comp_progress, comp_correct_chunk, comp_filter_chunk; - int comp_i; - char comp_correct[CHUNK_SIZE], comp_filter[CHUNK_SIZE]; - - camel_test_init(argc, argv); - - for (i = 0; i < NUM_CASES; i++) { - work = g_strdup_printf ("Header stripping filter, test case %d", i); - camel_test_start (work); - g_free (work); - - camel_test_push ("Initializing objects"); - work = g_strdup_printf ("%s/stripheader-%d.in", SOURCEDIR, i + 1); - source = camel_stream_fs_new_with_name (work, 0, O_RDONLY); - if (!source) { - camel_test_fail ("Failed to open input case in \"%s\"", work); - g_free (work); - continue; - } - g_free (work); - - work = g_strdup_printf ("%s/stripheader-%d.out", SOURCEDIR, i + 1); - correct = camel_stream_fs_new_with_name (work, 0, O_RDONLY); - if (!correct) { - camel_test_fail ("Failed to open correct output in \"%s\"", work); - g_free (work); - continue; - } - g_free (work); - - filter = camel_stream_filter_new_with_stream (CAMEL_STREAM (source)); - if (!filter) { - camel_test_fail ("Couldn't create CamelStreamFilter??"); - continue; - } - - sh = camel_mime_filter_stripheader_new ("Stripped"); - if (!sh) { - camel_test_fail ("Couldn't create CamelMimeFilterStripHeader??"); - continue; - } - - camel_stream_filter_add (filter, sh); - camel_test_pull (); - - camel_test_push ("Running filter and comparing to correct result"); - - comp_progress = 0; - - while (1) { - comp_correct_chunk = camel_stream_read (correct, comp_correct, CHUNK_SIZE); - comp_filter_chunk = 0; - - if (comp_correct_chunk == 0) - break; - - while (comp_filter_chunk < comp_correct_chunk) { - ssize_t delta; - - delta = camel_stream_read (CAMEL_STREAM (filter), - comp_filter + comp_filter_chunk, - CHUNK_SIZE - comp_filter_chunk); - - if (delta == 0) { - camel_test_fail ("Chunks are different sizes: correct is %d, filter is %d, %d bytes into stream", - comp_correct_chunk, comp_filter_chunk, comp_progress); - } - - comp_filter_chunk += delta; - } - - d(printf ("\n\nCORRECT: >>%.*s<<", comp_correct_chunk, comp_correct);) - d(printf ("\nFILTER : >>%.*s<<\n", comp_filter_chunk, comp_filter);) - - for (comp_i = 0; comp_i < comp_filter_chunk; comp_i++) { - if (comp_correct[comp_i] != comp_filter[comp_i]) { - camel_test_fail ("Difference: correct is %c, filter is %c, %d bytes into stream", - comp_correct[comp_i], - comp_filter[comp_i], - comp_progress + comp_i); - } - } - - comp_progress += comp_filter_chunk; - } - - camel_test_pull (); - - /* inefficient */ - camel_test_push ("Cleaning up"); - camel_object_unref (CAMEL_OBJECT (filter)); - camel_object_unref (CAMEL_OBJECT (correct)); - camel_object_unref (CAMEL_OBJECT (source)); - camel_object_unref (CAMEL_OBJECT (sh)); - camel_test_pull (); - - camel_test_end(); - } - - return 0; -} diff --git a/camel/tests/misc/.cvsignore b/camel/tests/misc/.cvsignore deleted file mode 100644 index 7ef94ab5fa..0000000000 --- a/camel/tests/misc/.cvsignore +++ /dev/null @@ -1,12 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -*.bb -*.bbg -*.da -*.gcov -url
\ No newline at end of file diff --git a/camel/tests/misc/Makefile.am b/camel/tests/misc/Makefile.am deleted file mode 100644 index dc34d1ea16..0000000000 --- a/camel/tests/misc/Makefile.am +++ /dev/null @@ -1,21 +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 = \ - url - -TESTS = url - - - diff --git a/camel/tests/misc/README b/camel/tests/misc/README deleted file mode 100644 index d972108860..0000000000 --- a/camel/tests/misc/README +++ /dev/null @@ -1,3 +0,0 @@ - -url URL parsing - diff --git a/camel/tests/misc/url.c b/camel/tests/misc/url.c deleted file mode 100644 index adc6278bae..0000000000 --- a/camel/tests/misc/url.c +++ /dev/null @@ -1,108 +0,0 @@ -#include <config.h> - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-url.h> -#include <camel/camel-exception.h> - -#include "camel-test.h" - -char *base = "http://a/b/c/d;p?q#f"; - -struct { - char *url_string, *result; -} tests[] = { - { "g:h", "g:h" }, - { "g", "http://a/b/c/g" }, - { "./g", "http://a/b/c/g" }, - { "g/", "http://a/b/c/g/" }, - { "/g", "http://a/g" }, - { "//g", "http://g" }, - { "?y", "http://a/b/c/d;p?y" }, - { "g?y", "http://a/b/c/g?y" }, - { "g?y/./x", "http://a/b/c/g?y/./x" }, - { "#s", "http://a/b/c/d;p?q#s" }, - { "g#s", "http://a/b/c/g#s" }, - { "g#s/./x", "http://a/b/c/g#s/./x" }, - { "g?y#s", "http://a/b/c/g?y#s" }, - { ";x", "http://a/b/c/d;x" }, - { "g;x", "http://a/b/c/g;x" }, - { "g;x?y#s", "http://a/b/c/g;x?y#s" }, - { ".", "http://a/b/c/" }, - { "./", "http://a/b/c/" }, - { "..", "http://a/b/" }, - { "../", "http://a/b/" }, - { "../g", "http://a/b/g" }, - { "../..", "http://a/" }, - { "../../", "http://a/" }, - { "../../g", "http://a/g" }, - { "", "http://a/b/c/d;p?q#f" }, - { "../../../g", "http://a/../g" }, - { "../../../../g", "http://a/../../g" }, - { "/./g", "http://a/./g" }, - { "/../g", "http://a/../g" }, - { "g.", "http://a/b/c/g." }, - { ".g", "http://a/b/c/.g" }, - { "g..", "http://a/b/c/g.." }, - { "..g", "http://a/b/c/..g" }, - { "./../g", "http://a/b/g" }, - { "./g/.", "http://a/b/c/g/" }, - { "g/./h", "http://a/b/c/g/h" }, - { "g/../h", "http://a/b/c/h" }, - { "http:g", "http:g" }, - { "http:", "http:" } -}; -int num_tests = sizeof (tests) / sizeof (tests[0]); - -int -main (int argc, char **argv) -{ - CamelURL *base_url, *url; - CamelException ex; - char *url_string; - int i; - - camel_test_init (argc, argv); - - camel_test_start ("RFC1808 relative URL parsing"); - - camel_test_push ("base URL parsing"); - camel_exception_init (&ex); - base_url = camel_url_new (base, &ex); - if (!base_url) { - camel_test_fail ("Could not parse %s: %s\n", base, - camel_exception_get_description (&ex)); - } - camel_test_pull (); - - camel_test_push ("base URL unparsing"); - url_string = camel_url_to_string (base_url, 0); - if (strcmp (url_string, base) != 0) { - camel_test_fail ("URL <%s> unparses to <%s>\n", - base, url_string); - } - camel_test_pull (); - g_free (url_string); - - for (i = 0; i < num_tests; i++) { - camel_test_push ("<%s> + <%s> = <%s>?", base, tests[i].url_string, tests[i].result); - url = camel_url_new_with_base (base_url, tests[i].url_string); - if (!url) { - camel_test_fail ("could not parse"); - camel_test_pull (); - continue; - } - - url_string = camel_url_to_string (url, 0); - if (strcmp (url_string, tests[i].result) != 0) - camel_test_fail ("got <%s>!", url_string); - g_free (url_string); - camel_test_pull (); - } - - camel_test_end (); - - return 0; -} diff --git a/camel/tests/smime/.cvsignore b/camel/tests/smime/.cvsignore deleted file mode 100644 index c0feca5888..0000000000 --- a/camel/tests/smime/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile* -pgp -pgp-mime diff --git a/camel/tests/smime/Makefile.am b/camel/tests/smime/Makefile.am deleted file mode 100644 index e8b098745f..0000000000 --- a/camel/tests/smime/Makefile.am +++ /dev/null @@ -1,20 +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 = \ - pgp \ - pgp-mime -# pkcs7 - -TESTS = pgp pgp-mime #pkcs7 diff --git a/camel/tests/smime/README b/camel/tests/smime/README deleted file mode 100644 index baad91ba00..0000000000 --- a/camel/tests/smime/README +++ /dev/null @@ -1,2 +0,0 @@ -pgp PGP test suite - diff --git a/camel/tests/smime/pgp-mime.c b/camel/tests/smime/pgp-mime.c deleted file mode 100644 index d2e243e084..0000000000 --- a/camel/tests/smime/pgp-mime.c +++ /dev/null @@ -1,170 +0,0 @@ -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-pgp-mime.h> -#include <camel/camel-stream-mem.h> - -#include "camel-test.h" -#include "session.h" - -static char test_msg[] = "Since we need to make sure that\nFrom lines work okay, we should test that" -"as well as test 8bit chars and other fun stuff? 8bit chars: Dražen Kačar\n\nOkay, I guess that covers" -"the basics at least...\n"; - - -#define CAMEL_PGP_SESSION_TYPE (camel_pgp_session_get_type ()) -#define CAMEL_PGP_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_PGP_SESSION_TYPE, CamelPgpSession)) -#define CAMEL_PGP_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_PGP_SESSION_TYPE, CamelPgpSessionClass)) -#define CAMEL_PGP_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_PGP_SESSION_TYPE)) - - -typedef struct _CamelPgpSession { - CamelSession parent_object; - -} CamelPgpSession; - -typedef struct _CamelPgpSessionClass { - CamelSessionClass parent_class; - -} CamelPgpSessionClass; - - -static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, - const char *item, CamelException *ex); - -static void -init (CamelPgpSession *session) -{ - ; -} - -static void -class_init (CamelPgpSessionClass *camel_pgp_session_class) -{ - CamelSessionClass *camel_session_class = - CAMEL_SESSION_CLASS (camel_pgp_session_class); - - /* virtual method override */ - camel_session_class->get_password = get_password; -} - -static CamelType -camel_pgp_session_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register ( - camel_test_session_get_type (), - "CamelPgpSession", - sizeof (CamelPgpSession), - sizeof (CamelPgpSessionClass), - (CamelObjectClassInitFunc) class_init, - NULL, - (CamelObjectInitFunc) init, - NULL); - } - - return type; -} - -static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, - CamelService *service, const char *item, CamelException *ex) -{ - return g_strdup ("PGP/MIME is rfc2015, now go and read it."); -} - -static CamelSession * -camel_pgp_session_new (const char *path) -{ - CamelSession *session; - - session = CAMEL_SESSION (camel_object_new (CAMEL_PGP_SESSION_TYPE)); - - camel_session_construct (session, path); - - return session; -} - - -int main (int argc, char **argv) -{ - CamelSession *session; - CamelPgpContext *ctx; - CamelException *ex; - CamelCipherValidity *valid; - CamelMimePart *mime_part, *part; - GPtrArray *recipients; - - camel_test_init (argc, argv); - - ex = camel_exception_new (); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_pgp_session_new ("/tmp/camel-test"); - - ctx = camel_pgp_context_new (session, CAMEL_PGP_TYPE_GPG, "/usr/bin/gpg", FALSE); - - camel_test_start ("Test of PGP/MIME functions"); - - mime_part = camel_mime_part_new (); - camel_mime_part_set_content (mime_part, test_msg, strlen (test_msg), "text/plain"); - camel_mime_part_set_description (mime_part, "Test of PGP/MIME multipart/signed stuff"); - - camel_test_push ("PGP/MIME signing"); - camel_pgp_mime_part_sign (ctx, &mime_part, "pgp-mime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - check_msg (camel_pgp_mime_is_rfc2015_signed (mime_part), - "Huh, the MIME part does not seem to be a valid multipart/signed part"); - camel_test_pull (); - - camel_exception_clear (ex); - - camel_test_push ("PGP/MIME verify"); - valid = camel_pgp_mime_part_verify (ctx, mime_part, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid)); - camel_cipher_validity_free (valid); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (mime_part)); - - camel_exception_clear (ex); - - mime_part = camel_mime_part_new (); - camel_mime_part_set_content (mime_part, test_msg, strlen (test_msg), "text/plain"); - camel_mime_part_set_description (mime_part, "Test of PGP/MIME multipart/encrypted stuff"); - - camel_test_push ("PGP/MIME encrypt"); - recipients = g_ptr_array_new (); - g_ptr_array_add (recipients, "pgp-mime@xtorshun.org"); - camel_pgp_mime_part_encrypt (ctx, &mime_part, recipients, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - check_msg (camel_pgp_mime_is_rfc2015_encrypted (mime_part), - "Huh, the MIME part does not seem to be a valid multipart/encrypted part"); - g_ptr_array_free (recipients, TRUE); - camel_test_pull (); - - camel_exception_clear (ex); - - camel_test_push ("PGP/MIME decrypt"); - part = camel_pgp_mime_part_decrypt (ctx, mime_part, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - camel_object_unref (CAMEL_OBJECT (part)); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (mime_part)); - - camel_object_unref (CAMEL_OBJECT (ctx)); - camel_object_unref (CAMEL_OBJECT (session)); - - camel_test_end (); - - return 0; -} diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c deleted file mode 100644 index 2d5ff7228c..0000000000 --- a/camel/tests/smime/pgp.c +++ /dev/null @@ -1,178 +0,0 @@ -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-pgp-context.h> -#include <camel/camel-stream-mem.h> - -#include "camel-test.h" -#include "session.h" - -#define CAMEL_PGP_SESSION_TYPE (camel_pgp_session_get_type ()) -#define CAMEL_PGP_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_PGP_SESSION_TYPE, CamelPgpSession)) -#define CAMEL_PGP_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_PGP_SESSION_TYPE, CamelPgpSessionClass)) -#define CAMEL_PGP_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_PGP_SESSION_TYPE)) - - -typedef struct _CamelPgpSession { - CamelSession parent_object; - -} CamelPgpSession; - -typedef struct _CamelPgpSessionClass { - CamelSessionClass parent_class; - -} CamelPgpSessionClass; - - -static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, - const char *item, CamelException *ex); - -static void -init (CamelPgpSession *session) -{ - ; -} - -static void -class_init (CamelPgpSessionClass *camel_pgp_session_class) -{ - CamelSessionClass *camel_session_class = - CAMEL_SESSION_CLASS (camel_pgp_session_class); - - /* virtual method override */ - camel_session_class->get_password = get_password; -} - -static CamelType -camel_pgp_session_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register ( - camel_test_session_get_type (), - "CamelPgpSession", - sizeof (CamelPgpSession), - sizeof (CamelPgpSessionClass), - (CamelObjectClassInitFunc) class_init, - NULL, - (CamelObjectInitFunc) init, - NULL); - } - - return type; -} - -static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, - CamelService *service, const char *item, CamelException *ex) -{ - return g_strdup ("PGP/MIME is rfc2015, now go and read it."); -} - -static CamelSession * -camel_pgp_session_new (const char *path) -{ - CamelSession *session; - - session = CAMEL_SESSION (camel_object_new (CAMEL_PGP_SESSION_TYPE)); - - camel_session_construct (session, path); - - return session; -} - - -int main (int argc, char **argv) -{ - CamelSession *session; - CamelPgpContext *ctx; - CamelException *ex; - CamelCipherValidity *valid; - CamelStream *stream1, *stream2, *stream3; - GPtrArray *recipients; - GByteArray *buf; - char *before, *after; - - camel_test_init (argc, argv); - - ex = camel_exception_new (); - - /* clear out any camel-test data */ - system("/bin/rm -rf /tmp/camel-test"); - - session = camel_pgp_session_new ("/tmp/camel-test"); - - ctx = camel_pgp_context_new (session, CAMEL_PGP_TYPE_GPG, "/usr/bin/gpg", FALSE); - - camel_test_start ("Test of PGP functions"); - - stream1 = camel_stream_mem_new (); - camel_stream_write (stream1, "Hello, I am a test stream.\n", 27); - camel_stream_reset (stream1); - - stream2 = camel_stream_mem_new (); - - camel_test_push ("PGP signing"); - camel_pgp_sign (ctx, "pgp-mime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1, - stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - camel_test_pull (); - - camel_exception_clear (ex); - - camel_test_push ("PGP verify"); - camel_stream_reset (stream1); - camel_stream_reset (stream2); - valid = camel_pgp_verify (ctx, stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid)); - camel_cipher_validity_free (valid); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (stream1)); - camel_object_unref (CAMEL_OBJECT (stream2)); - - stream1 = camel_stream_mem_new (); - stream2 = camel_stream_mem_new (); - stream3 = camel_stream_mem_new (); - - camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44); - camel_stream_reset (stream1); - - camel_exception_clear (ex); - - camel_test_push ("PGP encrypt"); - recipients = g_ptr_array_new (); - g_ptr_array_add (recipients, "pgp-mime@xtorshun.org"); - camel_pgp_encrypt (ctx, FALSE, "pgp-mime@xtorshun.org", recipients, - stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - g_ptr_array_free (recipients, TRUE); - camel_test_pull (); - - camel_stream_reset (stream2); - camel_exception_clear (ex); - - camel_test_push ("PGP decrypt"); - camel_pgp_decrypt (ctx, stream2, stream3, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - buf = CAMEL_STREAM_MEM (stream1)->buffer; - before = g_strndup (buf->data, buf->len); - buf = CAMEL_STREAM_MEM (stream3)->buffer; - after = g_strndup (buf->data, buf->len); - check_msg (string_equal (before, after), "before = '%s', after = '%s'", before, after); - g_free (before); - g_free (after); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (ctx)); - camel_object_unref (CAMEL_OBJECT (session)); - - camel_test_end (); - - return 0; -} diff --git a/camel/tests/smime/pkcs7.c b/camel/tests/smime/pkcs7.c deleted file mode 100644 index 2248d8656d..0000000000 --- a/camel/tests/smime/pkcs7.c +++ /dev/null @@ -1,178 +0,0 @@ -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <camel/camel-smime-context.h> -#include <camel/camel-stream-mem.h> - -#include "camel-test.h" - - -#define CAMEL_TEST_SESSION_TYPE (camel_test_session_get_type ()) -#define CAMEL_TEST_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_TEST_SESSION_TYPE, CamelTestSession)) -#define CAMEL_TEST_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_TEST_SESSION_TYPE, CamelTestSessionClass)) -#define CAMEL_TEST_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_TEST_SESSION_TYPE)) - - -typedef struct _CamelTestSession { - CamelSession parent_object; - -} CamelTestSession; - -typedef struct _CamelTestSessionClass { - CamelSessionClass parent_class; - -} CamelTestSessionClass; - - -static char *get_password (CamelSession *session, const char *prompt, - gboolean secret, CamelService *service, - const char *item, CamelException *ex); - -static void -init (CamelTestSession *session) -{ - ; -} - -static void -class_init (CamelTestSessionClass *camel_test_session_class) -{ - CamelSessionClass *camel_session_class = - CAMEL_SESSION_CLASS (camel_test_session_class); - - /* virtual method override */ - camel_session_class->get_password = get_password; -} - -static CamelType -camel_test_session_get_type (void) -{ - static CamelType type = CAMEL_INVALID_TYPE; - - if (type == CAMEL_INVALID_TYPE) { - type = camel_type_register ( - camel_test_session_get_type (), - "CamelTestSession", - sizeof (CamelTestSession), - sizeof (CamelTestSessionClass), - (CamelObjectClassInitFunc) class_init, - NULL, - (CamelObjectInitFunc) init, - NULL); - } - - return type; -} - -static char * -get_password (CamelSession *session, const char *prompt, gboolean secret, - CamelService *service, const char *item, CamelException *ex) -{ - return g_strdup ("S/MIME v3 is rfc263x, now go and read them."); -} - -static CamelSession * -camel_test_session_new (const char *path) -{ - CamelSession *session; - - session = CAMEL_SESSION (camel_object_new (CAMEL_TEST_SESSION_TYPE)); - - camel_session_construct (session, path); - - return session; -} - - -int main (int argc, char **argv) -{ - CamelSession *session; - CamelSMimeContext *ctx; - CamelException *ex; - CamelCipherValidity *valid; - CamelStream *stream1, *stream2, *stream3; - GPtrArray *recipients; - GByteArray *buf; - char *before, *after; - - 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"); - - ctx = camel_smime_context_new (session); - - camel_test_start ("Test of S/MIME PKCS7 functions"); - - stream1 = camel_stream_mem_new (); - camel_stream_write (stream1, "Hello, I am a test stream.", 25); - camel_stream_reset (stream1); - - stream2 = camel_stream_mem_new (); - - camel_test_push ("PKCS7 signing"); - camel_smime_sign (ctx, "smime@xtorshun.org", CAMEL_CIPHER_HASH_SHA1, - stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - camel_test_pull (); - - camel_exception_clear (ex); - - camel_test_push ("PKCS7 verify"); - camel_stream_reset (stream1); - camel_stream_reset (stream2); - valid = camel_smime_verify (ctx, CAMEL_CIPHER_HASH_SHA1, stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - check_msg (camel_cipher_validity_get_valid (valid), "%s", camel_cipher_validity_get_description (valid)); - camel_cipher_validity_free (valid); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (stream1)); - camel_object_unref (CAMEL_OBJECT (stream2)); - - stream1 = camel_stream_mem_new (); - stream2 = camel_stream_mem_new (); - stream3 = camel_stream_mem_new (); - - camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44); - camel_stream_reset (stream1); - - camel_exception_clear (ex); - - camel_test_push ("PKCS7 encrypt"); - recipients = g_ptr_array_new (); - g_ptr_array_add (recipients, "smime@xtorshun.org"); - camel_smime_encrypt (ctx, FALSE, "smime@xtorshun.org", recipients, - stream1, stream2, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - g_ptr_array_free (recipients, TRUE); - camel_test_pull (); - - camel_stream_reset (stream2); - camel_exception_clear (ex); - - camel_test_push ("PKCS7 decrypt"); - camel_smime_decrypt (ctx, stream2, stream3, ex); - check_msg (!camel_exception_is_set (ex), "%s", camel_exception_get_description (ex)); - buf = CAMEL_STREAM_MEM (stream1)->buffer; - before = g_strndup (buf->data, buf->len); - buf = CAMEL_STREAM_MEM (stream3)->buffer; - after = g_strndup (buf->data, buf->len); - check_msg (string_equal (before, after), "before = '%s', after = '%s'", before, after); - g_free (before); - g_free (after); - camel_test_pull (); - - camel_object_unref (CAMEL_OBJECT (ctx)); - camel_object_unref (CAMEL_OBJECT (session)); - - camel_test_end (); - - return 0; -} diff --git a/camel/tests/stream/.cvsignore b/camel/tests/stream/.cvsignore deleted file mode 100644 index 36f9336c1d..0000000000 --- a/camel/tests/stream/.cvsignore +++ /dev/null @@ -1,14 +0,0 @@ -.deps -Makefile -Makefile.in -.libs -.deps -*.lo -*.la -*.bb -*.bbg -*.da -*.gcov -test1 -test2 -test3 diff --git a/camel/tests/stream/Makefile.am b/camel/tests/stream/Makefile.am deleted file mode 100644 index 37586766c7..0000000000 --- a/camel/tests/stream/Makefile.am +++ /dev/null @@ -1,21 +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 test2 test3 - -TESTS = test1 test2 test3 - - - diff --git a/camel/tests/stream/README b/camel/tests/stream/README deleted file mode 100644 index 8ca6a9602d..0000000000 --- a/camel/tests/stream/README +++ /dev/null @@ -1,4 +0,0 @@ - -test1 camelstreamfs, creating, read/write, eos, refcounting -test2 camelstreammem, creating, read/write, eos, refcounting -test3 camelseekablesubstream diff --git a/camel/tests/stream/test1.c b/camel/tests/stream/test1.c deleted file mode 100644 index 452d45274f..0000000000 --- a/camel/tests/stream/test1.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - test ... camelstreamfs */ - -#include "camel-test.h" -#include "streams.h" - -#include <errno.h> -#include <sys/stat.h> -#include <unistd.h> - -#include "camel/camel-stream-fs.h" - -int main(int argc, char **argv) -{ - CamelSeekableStream *ss = NULL; - int i; - int fd = -1; - struct stat st; - int size; - char buffer[1024]; - - camel_test_init(argc, argv); - - camel_test_start("CamelStream fs, open, seek, read, write, eos"); - for (i=0;i<2;i++) { - - (void)unlink("stream.txt"); - - push("trying to open a nonexistant stream, method %d", i); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0); - break; - case 1: - fd = open("stream.txt", O_RDWR, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss == NULL && errno == ENOENT); - check(stat("stream.txt", &st) == -1 && errno == ENOENT); - pull(); - - push("Creating stream using method %d", i); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_CREAT|O_RDWR|O_TRUNC, 0600); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0); - pull(); - - test_stream_seekable_writepart(ss); - test_stream_seekable_readpart(ss); - - push("getting filesize"); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode)); - size = st.st_size; - pull(); - - push("checking close closes"); - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - push("re-opening stream"); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR, 0); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_RDWR, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == size); - - test_stream_seekable_readpart(ss); - - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - push("re-opening stream with truncate"); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_TRUNC, 0); - fd = ((CamelStreamFs *)ss)->fd; - break; - case 1: - fd = open("stream.txt", O_RDWR|O_TRUNC, 0); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_fd(fd); - break; - } - check(ss != NULL); - check(stat("stream.txt", &st) == 0 && (st.st_mode&0777) == 0600 && S_ISREG(st.st_mode) && st.st_size == 0); - - /* read has to return 0 before eos is set */ - check(camel_stream_read(CAMEL_STREAM(ss), buffer, 1) == 0); - check(camel_stream_eos(CAMEL_STREAM(ss))); - - check_unref(ss, 1); - check(close(fd) == -1); - pull(); - - (void)unlink("stream.txt"); - } - - camel_test_end(); - - return 0; -} diff --git a/camel/tests/stream/test2.c b/camel/tests/stream/test2.c deleted file mode 100644 index 02ad88e95c..0000000000 --- a/camel/tests/stream/test2.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - test ... camelstreammem */ - -#include "camel-test.h" -#include "streams.h" - -#include <errno.h> -#include <sys/stat.h> -#include <unistd.h> - -#include "camel/camel-stream-mem.h" - -int main(int argc, char **argv) -{ - CamelSeekableStream *ss = NULL; - int i; - int fd = -1; - struct stat st; - int size; - char buffer[1024]; - GByteArray *ba; - - camel_test_init(argc, argv); - - camel_test_start("CamelStream mem, create, seek, read, write, eos"); - for (i=0;i<3;i++) { - - push("Creating stream using method %d", i); - switch(i) { - case 0: - ss = (CamelSeekableStream *)camel_stream_mem_new(); - break; - case 1: - ba = g_byte_array_new(); - ss = (CamelSeekableStream *)camel_stream_mem_new_with_byte_array(ba); - break; - case 2: - ss = (CamelSeekableStream *)camel_stream_mem_new_with_buffer("", 0); - break; - } - check(ss != NULL); - - test_stream_seekable_writepart(ss); - test_stream_seekable_readpart(ss); - - check_unref(ss, 1); - pull(); - } - - camel_test_end(); - - return 0; -} diff --git a/camel/tests/stream/test3.c b/camel/tests/stream/test3.c deleted file mode 100644 index b870a7773e..0000000000 --- a/camel/tests/stream/test3.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - test ... camelseekablesubstream */ - -#include "camel-test.h" -#include "streams.h" - -#include <errno.h> -#include <sys/stat.h> -#include <unistd.h> - -#include "camel/camel-stream-mem.h" -#include "camel/camel-stream-fs.h" -#include "camel/camel-seekable-substream.h" - -#define ARRAY_LEN(x) (sizeof(x)/sizeof(x[0])) - -struct { - off_t lower, upper; -} ranges[] = { - { 3, 10241 }, - { 0, 1024 }, - { 0, 0 }, - { 0, 1 }, - { 0, 2 }, - { 0, 3 }, - { 0, 7 }, - { 1, 8 }, - { 1, 9 }, - { 10245, 10300 }, - { 0, CAMEL_STREAM_UNBOUND }, -/* { 1, CAMEL_STREAM_UNBOUND }, - { 2, CAMEL_STREAM_UNBOUND }, - { 3, CAMEL_STREAM_UNBOUND }, these take too long to run - { 7, CAMEL_STREAM_UNBOUND },*/ - { 10245, CAMEL_STREAM_UNBOUND }, -}; - -int main(int argc, char **argv) -{ - CamelSeekableStream *ss = NULL; - int i, j; - CamelSeekableSubstream *sus, *sus2; - - camel_test_init(argc, argv); - - camel_test_start("CamelSeekableSubstream, mem backing"); - for (j=0;j<SEEKABLE_SUBSTREAM_WAYS;j++) { - push("testing writing method %d", j); - ss = (CamelSeekableStream *)camel_stream_mem_new(); - check(ss != NULL); - for (i=0;i<ARRAY_LEN(ranges);i++) { - push("stream subrange %d-%d", ranges[i].lower, ranges[i].upper); - sus = (CamelSeekableSubstream *)camel_seekable_substream_new_with_seekable_stream_and_bounds(ss, ranges[i].lower, ranges[i].upper); - check(sus != NULL); - - test_seekable_substream_writepart((CamelStream *)sus, j); - test_seekable_substream_readpart((CamelStream *)sus); - - sus2 = (CamelSeekableSubstream *)camel_seekable_substream_new_with_seekable_stream_and_bounds(ss, ranges[i].lower, ranges[i].upper); - check(sus2 != NULL); - test_seekable_substream_readpart((CamelStream *)sus2); - - check_unref(sus, 1); - check_unref(sus2, 1); - pull(); - } - check_unref(ss, 1); - pull(); - } - - camel_test_end(); - - (void)unlink("stream.txt"); - - camel_test_start("CamelSeekableSubstream, file backing"); - for (j=0;j<SEEKABLE_SUBSTREAM_WAYS;j++) { - push("testing writing method %d", j); - ss = (CamelSeekableStream *)camel_stream_fs_new_with_name("stream.txt", O_RDWR|O_CREAT|O_TRUNC, 0600); - check(ss != NULL); - for (i=0;i<ARRAY_LEN(ranges);i++) { - push("stream subrange %d-%d", ranges[i].lower, ranges[i].upper); - sus = (CamelSeekableSubstream *)camel_seekable_substream_new_with_seekable_stream_and_bounds(ss, ranges[i].lower, ranges[i].upper); - check(sus != NULL); - - test_seekable_substream_writepart((CamelStream *)sus, j); - test_seekable_substream_readpart((CamelStream *)sus); - - sus2 = (CamelSeekableSubstream *)camel_seekable_substream_new_with_seekable_stream_and_bounds(ss, ranges[i].lower, ranges[i].upper); - check(sus2 != NULL); - test_seekable_substream_readpart((CamelStream *)sus2); - - check_unref(sus, 1); - check_unref(sus2, 1); - pull(); - } - check_unref(ss, 1); - (void)unlink("stream.txt"); - pull(); - } - - camel_test_end(); - - return 0; -} |