From e80c4c9124dae9fc93f47061c8b083b21f2a4b60 Mon Sep 17 00:00:00 2001 From: djcb Date: Wed, 14 Mar 2012 21:33:06 +0200 Subject: [PATCH] * tests/: fix test cases for freebsd (and other bsds) --- src/tests/Makefile.am | 6 +++--- src/tests/test-mu-common.c | 2 +- src/tests/test-mu-maildir.c | 13 +++++++------ src/tests/test-mu-msg.c | 19 +++++++++++-------- src/tests/test-mu-store.c | 16 ++++++++-------- src/tests/test-mu-util.c | 2 +- 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index 9ace783b..473c1561 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -20,9 +20,9 @@ INCLUDES=$(XAPIAN_CXXFLAGS) \ $(GMIME_CFLAGS) \ $(GLIB_CFLAGS) \ -I ${top_srcdir} -I ${top_srcdir}/src \ - -DMU_TESTMAILDIR=\"${abs_srcdir}/testdir/\" \ - -DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2/\" \ - -DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3/\" \ + -DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \ + -DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \ + -DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3\" \ -DMU_PROGRAM=\"${abs_top_builddir}/src/mu\" \ -DABS_CURDIR=\"${abs_builddir}\" \ -DABS_SRCDIR=\"${abs_srcdir}\" diff --git a/src/tests/test-mu-common.c b/src/tests/test-mu-common.c index e71b43b4..9d8397be 100644 --- a/src/tests/test-mu-common.c +++ b/src/tests/test-mu-common.c @@ -68,7 +68,7 @@ set_en_us_utf8_locale (void) if (strcmp (nl_langinfo(CODESET), "UTF-8") != 0) { g_print ("Note: Unit tests require the en_US.utf8 locale. " - "Ignoring test cases."); + "Ignoring test cases.\n"); return FALSE; } diff --git a/src/tests/test-mu-maildir.c b/src/tests/test-mu-maildir.c index a79fbed7..4b52edd0 100644 --- a/src/tests/test-mu-maildir.c +++ b/src/tests/test-mu-maildir.c @@ -30,6 +30,7 @@ #include "test-mu-common.h" #include "src/mu-maildir.h" +#include "src/mu-util.h" static void test_mu_maildir_mkdir_01 (void) @@ -260,10 +261,8 @@ test_mu_maildir_walk_01 (void) g_assert_cmpuint (MU_OK, ==, rv); g_assert_cmpuint (data._file_count, ==, 13); - /* FIXME: comment-out; this fails for some people, apparently because - * the dir is copied one level higher */ - /* g_assert_cmpuint (data._dir_entered,==, 5); */ - /* g_assert_cmpuint (data._dir_left,==, 5); */ + g_assert_cmpuint (data._dir_entered,==, 5); + g_assert_cmpuint (data._dir_left,==, 5); g_free (tmpdir); } @@ -302,8 +301,8 @@ test_mu_maildir_walk_02 (void) /* FIXME: comment-out; this fails for some people, apparently because * the dir is copied one level higher */ - /* g_assert_cmpuint (data._dir_entered,==, 4); */ - /* g_assert_cmpuint (data._dir_left,==, 4); */ + g_assert_cmpuint (data._dir_entered,==, 4); + g_assert_cmpuint (data._dir_left,==, 4); g_free (tmpdir); } @@ -463,6 +462,8 @@ test_mu_maildir_get_maildir_from_path (void) int main (int argc, char *argv[]) { + mu_util_init_system (); + g_test_init (&argc, &argv, NULL); /* mu_util_maildir_mkmdir */ diff --git a/src/tests/test-mu-msg.c b/src/tests/test-mu-msg.c index 591fffff..f75b184c 100644 --- a/src/tests/test-mu-msg.c +++ b/src/tests/test-mu-msg.c @@ -67,7 +67,7 @@ test_mu_msg_01 (void) gint i; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1220863042.12663_1.mindcrime!2,S", + "/cur/1220863042.12663_1.mindcrime!2,S", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), @@ -133,7 +133,7 @@ test_mu_msg_02 (void) int i; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1220863087.12663_19.mindcrime!2,S", + "/cur/1220863087.12663_19.mindcrime!2,S", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), @@ -169,7 +169,7 @@ test_mu_msg_03 (void) MuMsg *msg; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1283599333.1840_11.cthulhu!2,", + "/cur/1283599333.1840_11.cthulhu!2,", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), ==, "Bilbo Baggins "); @@ -197,7 +197,7 @@ test_mu_msg_04 (void) MuMsg *msg; msg = mu_msg_new_from_file (MU_TESTMAILDIR2 - "Foo/cur/mail5", NULL, NULL); + "/Foo/cur/mail5", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), ==, "George Custer "); @@ -223,7 +223,7 @@ test_mu_msg_umlaut (void) MuMsg *msg; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1305664394.2171_402.cthulhu!2,", + "/cur/1305664394.2171_402.cthulhu!2,", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), @@ -248,7 +248,7 @@ test_mu_msg_references (void) const GSList *refs; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1305664394.2171_402.cthulhu!2,", + "/cur/1305664394.2171_402.cthulhu!2,", NULL, NULL); refs = mu_msg_get_references(msg); @@ -275,7 +275,7 @@ test_mu_msg_references_dups (void) const GSList *refs; msg = mu_msg_new_from_file (MU_TESTMAILDIR - "cur/1252168370_3.14675.cthulhu!2,S", + "/cur/1252168370_3.14675.cthulhu!2,S", NULL, NULL); refs = mu_msg_get_references(msg); @@ -336,7 +336,7 @@ test_mu_msg_comp_unix_programmer (void) char *refs; msg = mu_msg_new_from_file (MU_TESTMAILDIR2 - "bar/cur/181736.eml", NULL, NULL); + "/bar/cur/181736.eml", NULL, NULL); g_assert_cmpstr (mu_msg_get_to(msg), ==, NULL); g_assert_cmpstr (mu_msg_get_subject(msg), @@ -383,6 +383,9 @@ int main (int argc, char *argv[]) { int rv; + + mu_util_init_system (); + g_test_init (&argc, &argv, NULL); /* mu_msg_str_date */ diff --git a/src/tests/test-mu-store.c b/src/tests/test-mu-store.c index 90ff8dbc..88554d41 100644 --- a/src/tests/test-mu-store.c +++ b/src/tests/test-mu-store.c @@ -102,7 +102,7 @@ test_mu_store_store_msg_and_count (void) /* add one */ msg = mu_msg_new_from_file ( - MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", + MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL, NULL); g_assert (msg); g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), @@ -110,24 +110,24 @@ test_mu_store_store_msg_and_count (void) g_assert_cmpuint (1,==,mu_store_count (store, NULL)); g_assert_cmpuint (TRUE,==,mu_store_contains_message (store, - MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL)); + MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL)); mu_msg_unref (msg); /* add another one */ msg = mu_msg_new_from_file (MU_TESTMAILDIR2 - "bar/cur/mail3", NULL, NULL); + "/bar/cur/mail3", NULL, NULL); g_assert (msg); g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), !=, MU_STORE_INVALID_DOCID); g_assert_cmpuint (2,==,mu_store_count (store, NULL)); g_assert_cmpuint (TRUE,==, mu_store_contains_message (store, MU_TESTMAILDIR2 - "bar/cur/mail3", NULL)); + "/bar/cur/mail3", NULL)); mu_msg_unref (msg); /* try to add the first one again. count should be 2 still */ msg = mu_msg_new_from_file - (MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", + (MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL, NULL); g_assert (msg); g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), @@ -159,7 +159,7 @@ test_mu_store_store_msg_remove_and_count (void) /* add one */ err = NULL; msg = mu_msg_new_from_file ( - MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", + MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL, &err); g_assert (msg); g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), @@ -169,11 +169,11 @@ test_mu_store_store_msg_remove_and_count (void) /* remove one */ mu_store_remove_path (store, - MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,"); + MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,"); g_assert_cmpuint (0,==,mu_store_count (store, NULL)); g_assert_cmpuint (FALSE,==,mu_store_contains_message (store, - MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL)); + MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL)); g_free (tmpdir); mu_store_unref (store); } diff --git a/src/tests/test-mu-util.c b/src/tests/test-mu-util.c index 26eaaacb..aef409d6 100644 --- a/src/tests/test-mu-util.c +++ b/src/tests/test-mu-util.c @@ -207,7 +207,7 @@ test_mu_util_get_dtype_with_lstat (void) g_assert_cmpuint ( mu_util_get_dtype_with_lstat (MU_TESTMAILDIR2), ==, DT_DIR); g_assert_cmpuint ( - mu_util_get_dtype_with_lstat (MU_TESTMAILDIR2 "Foo/cur/mail5"), + mu_util_get_dtype_with_lstat (MU_TESTMAILDIR2 "/Foo/cur/mail5"), ==, DT_REG); }