* tests/: fix test cases for freebsd (and other bsds)

This commit is contained in:
djcb 2012-03-14 21:33:06 +02:00
parent ba10026dc2
commit e80c4c9124
6 changed files with 31 additions and 27 deletions

View File

@ -20,9 +20,9 @@ INCLUDES=$(XAPIAN_CXXFLAGS) \
$(GMIME_CFLAGS) \ $(GMIME_CFLAGS) \
$(GLIB_CFLAGS) \ $(GLIB_CFLAGS) \
-I ${top_srcdir} -I ${top_srcdir}/src \ -I ${top_srcdir} -I ${top_srcdir}/src \
-DMU_TESTMAILDIR=\"${abs_srcdir}/testdir/\" \ -DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \
-DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2/\" \ -DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \
-DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3/\" \ -DMU_TESTMAILDIR3=\"${abs_srcdir}/testdir3\" \
-DMU_PROGRAM=\"${abs_top_builddir}/src/mu\" \ -DMU_PROGRAM=\"${abs_top_builddir}/src/mu\" \
-DABS_CURDIR=\"${abs_builddir}\" \ -DABS_CURDIR=\"${abs_builddir}\" \
-DABS_SRCDIR=\"${abs_srcdir}\" -DABS_SRCDIR=\"${abs_srcdir}\"

View File

@ -68,7 +68,7 @@ set_en_us_utf8_locale (void)
if (strcmp (nl_langinfo(CODESET), "UTF-8") != 0) { if (strcmp (nl_langinfo(CODESET), "UTF-8") != 0) {
g_print ("Note: Unit tests require the en_US.utf8 locale. " g_print ("Note: Unit tests require the en_US.utf8 locale. "
"Ignoring test cases."); "Ignoring test cases.\n");
return FALSE; return FALSE;
} }

View File

@ -30,6 +30,7 @@
#include "test-mu-common.h" #include "test-mu-common.h"
#include "src/mu-maildir.h" #include "src/mu-maildir.h"
#include "src/mu-util.h"
static void static void
test_mu_maildir_mkdir_01 (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 (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 13); g_assert_cmpuint (data._file_count, ==, 13);
/* FIXME: comment-out; this fails for some people, apparently because g_assert_cmpuint (data._dir_entered,==, 5);
* the dir is copied one level higher */ g_assert_cmpuint (data._dir_left,==, 5);
/* g_assert_cmpuint (data._dir_entered,==, 5); */
/* g_assert_cmpuint (data._dir_left,==, 5); */
g_free (tmpdir); g_free (tmpdir);
} }
@ -302,8 +301,8 @@ test_mu_maildir_walk_02 (void)
/* FIXME: comment-out; this fails for some people, apparently because /* FIXME: comment-out; this fails for some people, apparently because
* the dir is copied one level higher */ * the dir is copied one level higher */
/* g_assert_cmpuint (data._dir_entered,==, 4); */ g_assert_cmpuint (data._dir_entered,==, 4);
/* g_assert_cmpuint (data._dir_left,==, 4); */ g_assert_cmpuint (data._dir_left,==, 4);
g_free (tmpdir); g_free (tmpdir);
} }
@ -463,6 +462,8 @@ test_mu_maildir_get_maildir_from_path (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
mu_util_init_system ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
/* mu_util_maildir_mkmdir */ /* mu_util_maildir_mkmdir */

View File

@ -67,7 +67,7 @@ test_mu_msg_01 (void)
gint i; gint i;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1220863042.12663_1.mindcrime!2,S", "/cur/1220863042.12663_1.mindcrime!2,S",
NULL, NULL); NULL, NULL);
g_assert_cmpstr (mu_msg_get_to(msg), g_assert_cmpstr (mu_msg_get_to(msg),
@ -133,7 +133,7 @@ test_mu_msg_02 (void)
int i; int i;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1220863087.12663_19.mindcrime!2,S", "/cur/1220863087.12663_19.mindcrime!2,S",
NULL, NULL); NULL, NULL);
g_assert_cmpstr (mu_msg_get_to(msg), g_assert_cmpstr (mu_msg_get_to(msg),
@ -169,7 +169,7 @@ test_mu_msg_03 (void)
MuMsg *msg; MuMsg *msg;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1283599333.1840_11.cthulhu!2,", "/cur/1283599333.1840_11.cthulhu!2,",
NULL, NULL); NULL, NULL);
g_assert_cmpstr (mu_msg_get_to(msg), g_assert_cmpstr (mu_msg_get_to(msg),
==, "Bilbo Baggins <bilbo@anotherexample.com>"); ==, "Bilbo Baggins <bilbo@anotherexample.com>");
@ -197,7 +197,7 @@ test_mu_msg_04 (void)
MuMsg *msg; MuMsg *msg;
msg = mu_msg_new_from_file (MU_TESTMAILDIR2 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), g_assert_cmpstr (mu_msg_get_to(msg),
==, "George Custer <gac@example.com>"); ==, "George Custer <gac@example.com>");
@ -223,7 +223,7 @@ test_mu_msg_umlaut (void)
MuMsg *msg; MuMsg *msg;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1305664394.2171_402.cthulhu!2,", "/cur/1305664394.2171_402.cthulhu!2,",
NULL, NULL); NULL, NULL);
g_assert_cmpstr (mu_msg_get_to(msg), g_assert_cmpstr (mu_msg_get_to(msg),
@ -248,7 +248,7 @@ test_mu_msg_references (void)
const GSList *refs; const GSList *refs;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1305664394.2171_402.cthulhu!2,", "/cur/1305664394.2171_402.cthulhu!2,",
NULL, NULL); NULL, NULL);
refs = mu_msg_get_references(msg); refs = mu_msg_get_references(msg);
@ -275,7 +275,7 @@ test_mu_msg_references_dups (void)
const GSList *refs; const GSList *refs;
msg = mu_msg_new_from_file (MU_TESTMAILDIR msg = mu_msg_new_from_file (MU_TESTMAILDIR
"cur/1252168370_3.14675.cthulhu!2,S", "/cur/1252168370_3.14675.cthulhu!2,S",
NULL, NULL); NULL, NULL);
refs = mu_msg_get_references(msg); refs = mu_msg_get_references(msg);
@ -336,7 +336,7 @@ test_mu_msg_comp_unix_programmer (void)
char *refs; char *refs;
msg = mu_msg_new_from_file (MU_TESTMAILDIR2 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), g_assert_cmpstr (mu_msg_get_to(msg),
==, NULL); ==, NULL);
g_assert_cmpstr (mu_msg_get_subject(msg), g_assert_cmpstr (mu_msg_get_subject(msg),
@ -383,6 +383,9 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
int rv; int rv;
mu_util_init_system ();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
/* mu_msg_str_date */ /* mu_msg_str_date */

View File

@ -102,7 +102,7 @@ test_mu_store_store_msg_and_count (void)
/* add one */ /* add one */
msg = mu_msg_new_from_file ( msg = mu_msg_new_from_file (
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,",
NULL, NULL); NULL, NULL);
g_assert (msg); g_assert (msg);
g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), 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 (1,==,mu_store_count (store, NULL));
g_assert_cmpuint (TRUE,==,mu_store_contains_message g_assert_cmpuint (TRUE,==,mu_store_contains_message
(store, (store,
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL)); MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL));
mu_msg_unref (msg); mu_msg_unref (msg);
/* add another one */ /* add another one */
msg = mu_msg_new_from_file (MU_TESTMAILDIR2 msg = mu_msg_new_from_file (MU_TESTMAILDIR2
"bar/cur/mail3", NULL, NULL); "/bar/cur/mail3", NULL, NULL);
g_assert (msg); g_assert (msg);
g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), g_assert_cmpuint (mu_store_add_msg (store, msg, NULL),
!=, MU_STORE_INVALID_DOCID); !=, MU_STORE_INVALID_DOCID);
g_assert_cmpuint (2,==,mu_store_count (store, NULL)); g_assert_cmpuint (2,==,mu_store_count (store, NULL));
g_assert_cmpuint (TRUE,==, g_assert_cmpuint (TRUE,==,
mu_store_contains_message (store, MU_TESTMAILDIR2 mu_store_contains_message (store, MU_TESTMAILDIR2
"bar/cur/mail3", NULL)); "/bar/cur/mail3", NULL));
mu_msg_unref (msg); mu_msg_unref (msg);
/* try to add the first one again. count should be 2 still */ /* try to add the first one again. count should be 2 still */
msg = mu_msg_new_from_file msg = mu_msg_new_from_file
(MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", (MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,",
NULL, NULL); NULL, NULL);
g_assert (msg); g_assert (msg);
g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), 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 */ /* add one */
err = NULL; err = NULL;
msg = mu_msg_new_from_file ( msg = mu_msg_new_from_file (
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,",
NULL, &err); NULL, &err);
g_assert (msg); g_assert (msg);
g_assert_cmpuint (mu_store_add_msg (store, msg, NULL), 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 */ /* remove one */
mu_store_remove_path (store, 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 (0,==,mu_store_count (store, NULL));
g_assert_cmpuint (FALSE,==,mu_store_contains_message g_assert_cmpuint (FALSE,==,mu_store_contains_message
(store, (store,
MU_TESTMAILDIR "cur/1283599333.1840_11.cthulhu!2,", NULL)); MU_TESTMAILDIR "/cur/1283599333.1840_11.cthulhu!2,", NULL));
g_free (tmpdir); g_free (tmpdir);
mu_store_unref (store); mu_store_unref (store);
} }

View File

@ -207,7 +207,7 @@ test_mu_util_get_dtype_with_lstat (void)
g_assert_cmpuint ( g_assert_cmpuint (
mu_util_get_dtype_with_lstat (MU_TESTMAILDIR2), ==, DT_DIR); mu_util_get_dtype_with_lstat (MU_TESTMAILDIR2), ==, DT_DIR);
g_assert_cmpuint ( 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); ==, DT_REG);
} }