mirror of https://github.com/djcb/mu.git
* update/add unit tests for threading
This commit is contained in:
parent
16d6a7bd45
commit
28db904fb2
|
@ -117,12 +117,43 @@ EXTRA_DIST= \
|
|||
testdir/cur/1220863060.12663_3.mindcrime!2,S \
|
||||
testdir/cur/1283599333.1840_11.cthulhu!2, \
|
||||
testdir/cur/1305664394.2171_402.cthulhu!2, \
|
||||
testdir/cur/1252168370_3.14675.cthulhu!2,S \
|
||||
testdir2/bar/cur/mail1 \
|
||||
testdir2/bar/cur/mail2 \
|
||||
testdir2/bar/cur/mail3 \
|
||||
testdir2/bar/cur/mail4 \
|
||||
testdir2/bar/cur/mail5 \
|
||||
testdir2/Foo/cur/mail5 \
|
||||
testdir2/bar/cur/181736.eml \
|
||||
testdir2/Foo/cur/arto.eml
|
||||
testdir2/bar/tmp/.noindex \
|
||||
testdir2/bar/new/.noindex \
|
||||
testdir2/Foo/cur/mail5 \
|
||||
testdir2/Foo/cur/arto.eml \
|
||||
testdir2/Foo/tmp/.noindex \
|
||||
testdir2/Foo/new/.noindex \
|
||||
testdir3/tree \
|
||||
testdir3/tree/new \
|
||||
testdir3/tree/new/.noindex \
|
||||
testdir3/tree/cur \
|
||||
testdir3/tree/cur/child0.1 \
|
||||
testdir3/tree/cur/root1 \
|
||||
testdir3/tree/cur/child3.0.0.0.0 \
|
||||
testdir3/tree/cur/child0.0 \
|
||||
testdir3/tree/cur/child4.1 \
|
||||
testdir3/tree/cur/child4.0 \
|
||||
testdir3/tree/cur/root2 \
|
||||
testdir3/tree/cur/child0.1.0 \
|
||||
testdir3/tree/cur/child2.0.0 \
|
||||
testdir3/tree/cur/root0 \
|
||||
testdir3/tree/tmp \
|
||||
testdir3/tree/tmp/.noindex \
|
||||
testdir3/cycle \
|
||||
testdir3/cycle/new \
|
||||
testdir3/cycle/new/.noindex \
|
||||
testdir3/cycle/cur \
|
||||
testdir3/cycle/cur/rogue0 \
|
||||
testdir3/cycle/cur/cycle0 \
|
||||
testdir3/cycle/cur/cycle0.0.0 \
|
||||
testdir3/cycle/cur/cycle0.0 \
|
||||
testdir3/cycle/tmp \
|
||||
testdir3/cycle/tmp/.noindex
|
||||
|
||||
|
|
|
@ -189,7 +189,7 @@ test_mu_maildir_walk_01 (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 12);
|
||||
g_assert_cmpuint (data._file_count, ==, 13);
|
||||
g_assert_cmpuint (data._dir_entered,==, 5);
|
||||
g_assert_cmpuint (data._dir_left,==, 5);
|
||||
|
||||
|
@ -220,7 +220,7 @@ test_mu_maildir_walk_02 (void)
|
|||
&data);
|
||||
|
||||
g_assert_cmpuint (MU_OK, ==, rv);
|
||||
g_assert_cmpuint (data._file_count, ==, 8);
|
||||
g_assert_cmpuint (data._file_count, ==, 9);
|
||||
g_assert_cmpuint (data._dir_entered,==, 4);
|
||||
g_assert_cmpuint (data._dir_left,==, 4);
|
||||
|
||||
|
|
|
@ -266,7 +266,38 @@ test_mu_msg_references (void)
|
|||
mu_msg_unref (msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_msg_references_dups (void)
|
||||
{
|
||||
MuMsg *msg;
|
||||
const GSList *refs;
|
||||
|
||||
msg = mu_msg_new_from_file (MU_TESTMAILDIR
|
||||
"cur/1252168370_3.14675.cthulhu!2,S",
|
||||
NULL, NULL);
|
||||
refs = mu_msg_get_references(msg);
|
||||
|
||||
/* make sure duplicate msg-ids are filtered out */
|
||||
|
||||
g_assert_cmpuint (g_slist_length ((GSList*)refs), ==, 6);
|
||||
|
||||
g_assert_cmpstr ((char*)refs->data,==, "439C1136.90504@euler.org");
|
||||
refs = g_slist_next (refs);
|
||||
g_assert_cmpstr ((char*)refs->data,==, "4399DD94.5070309@euler.org");
|
||||
refs = g_slist_next (refs);
|
||||
g_assert_cmpstr ((char*)refs->data,==, "20051209233303.GA13812@gauss.org");
|
||||
refs = g_slist_next (refs);
|
||||
g_assert_cmpstr ((char*)refs->data,==, "439B41ED.2080402@euler.org");
|
||||
refs = g_slist_next (refs);
|
||||
g_assert_cmpstr ((char*)refs->data,==, "439A1E03.3090604@euler.org");
|
||||
refs = g_slist_next (refs);
|
||||
g_assert_cmpstr ((char*)refs->data,==, "20051211184308.GB13513@gauss.org");
|
||||
refs = g_slist_next (refs);
|
||||
|
||||
mu_msg_unref (msg);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_msg_tags (void)
|
||||
|
@ -367,6 +398,8 @@ main (int argc, char *argv[])
|
|||
test_mu_msg_tags);
|
||||
g_test_add_func ("/mu-msg/mu-msg-references",
|
||||
test_mu_msg_references);
|
||||
g_test_add_func ("/mu-msg/mu-msg-references_dups",
|
||||
test_mu_msg_references_dups);
|
||||
g_test_add_func ("/mu-msg/mu-msg-umlaut",
|
||||
test_mu_msg_umlaut);
|
||||
g_test_add_func ("/mu-msg/mu-msg-comp-unix-programmer",
|
||||
|
|
|
@ -237,9 +237,9 @@ test_mu_query_04 (void)
|
|||
{ "baggins", 1},
|
||||
{ "prio:h", 1},
|
||||
{ "prio:high", 1},
|
||||
{ "prio:normal", 4},
|
||||
{ "prio:normal", 5},
|
||||
{ "prio:l", 7},
|
||||
{ "not prio:l", 5},
|
||||
{ "not prio:l", 6},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
|
@ -379,9 +379,9 @@ test_mu_query_sizes (void)
|
|||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "size:0b..2m", 12},
|
||||
{ "size:0b..2m", 13},
|
||||
{ "size:2k..4k", 2},
|
||||
{ "size:2m..0b", 12}
|
||||
{ "size:2m..0b", 13}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
|
|
|
@ -43,7 +43,7 @@ fill_database (const char *testdir)
|
|||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM, tmpdir, testdir);
|
||||
g_print ("%s\n", cmdline);
|
||||
/* g_print ("%s\n", cmdline); */
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
|
@ -65,7 +65,7 @@ run_and_get_iter (const char *xpath, const char *query)
|
|||
mquery = mu_query_new (xpath, NULL);
|
||||
g_assert (query);
|
||||
|
||||
iter = mu_query_run (mquery, query, TRUE, MU_MSG_FIELD_ID_NONE,
|
||||
iter = mu_query_run (mquery, query, TRUE, MU_MSG_FIELD_ID_DATE,
|
||||
FALSE, NULL);
|
||||
mu_query_destroy (mquery);
|
||||
g_assert (iter);
|
||||
|
@ -74,8 +74,6 @@ run_and_get_iter (const char *xpath, const char *query)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_threads_01 (void)
|
||||
{
|
||||
|
@ -124,13 +122,18 @@ test_mu_threads_01 (void)
|
|||
g_assert(ti);
|
||||
|
||||
msg = mu_msg_iter_get_msg (iter, NULL);
|
||||
/* g_print ("%s %s %s\n", ti->threadpath, */
|
||||
/* mu_msg_get_msgid(msg), */
|
||||
/* mu_msg_get_path (msg) */
|
||||
/* ); */
|
||||
|
||||
g_assert (u < G_N_ELEMENTS(items));
|
||||
|
||||
g_assert_cmpstr (ti->threadpath,==,items[u].threadpath);
|
||||
g_assert_cmpstr (mu_msg_get_msgid(msg),==,items[u].msgid);
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),==,items[u++].subject);
|
||||
|
||||
g_assert_cmpstr (ti->threadpath,==,items[u].threadpath);
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),==,items[u].subject);
|
||||
g_assert_cmpstr (mu_msg_get_msgid(msg),==,items[u].msgid);
|
||||
|
||||
++u;
|
||||
mu_msg_iter_next (iter);
|
||||
}
|
||||
g_assert (u == G_N_ELEMENTS(items));
|
||||
|
@ -140,6 +143,65 @@ test_mu_threads_01 (void)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_threads_rogue (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
MuMsgIter *iter;
|
||||
unsigned u;
|
||||
|
||||
struct {
|
||||
const char* threadpath;
|
||||
const char *msgid;
|
||||
const char* subject;
|
||||
} items [] = {
|
||||
{"0", "cycle0@msg.id", "cycle0"},
|
||||
{"0:0", "cycle0.0@msg.id", "cycle0.0"},
|
||||
{"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR3);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
iter = run_and_get_iter (xpath, "def");
|
||||
g_assert (iter);
|
||||
g_assert (!mu_msg_iter_is_done(iter));
|
||||
|
||||
u = 0;
|
||||
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items)) {
|
||||
MuMsg *msg;
|
||||
const MuMsgIterThreadInfo *ti;
|
||||
|
||||
ti = mu_msg_iter_get_thread_info (iter);
|
||||
if (!ti)
|
||||
g_print ("%s: thread info not found\n",
|
||||
mu_msg_get_msgid(mu_msg_iter_get_msg (iter, NULL)));
|
||||
|
||||
g_assert(ti);
|
||||
|
||||
msg = mu_msg_iter_get_msg (iter, NULL);
|
||||
/* g_print ("%s %s %s\n", ti->threadpath, */
|
||||
/* mu_msg_get_msgid(msg), */
|
||||
/* mu_msg_get_path (msg) */
|
||||
/* ); */
|
||||
|
||||
g_assert (u < G_N_ELEMENTS(items));
|
||||
|
||||
g_assert_cmpstr (ti->threadpath,==,items[u].threadpath);
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),==,items[u].subject);
|
||||
g_assert_cmpstr (mu_msg_get_msgid(msg),==,items[u].msgid);
|
||||
|
||||
++u;
|
||||
mu_msg_iter_next (iter);
|
||||
}
|
||||
g_assert (u == G_N_ELEMENTS(items));
|
||||
|
||||
g_free (xpath);
|
||||
mu_msg_iter_destroy (iter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -148,6 +210,8 @@ main (int argc, char *argv[])
|
|||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-threads-01", test_mu_threads_01);
|
||||
g_test_add_func ("/mu-query/test-mu-threads-rogue", test_mu_threads_rogue);
|
||||
|
||||
|
||||
/* g_log_set_handler (NULL, */
|
||||
/* G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, */
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
Return-Path: <dfgh@floppydisk.nl>
|
||||
X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on mindcrime
|
||||
X-Spam-Level:
|
||||
Delivered-To: dfgh@floppydisk.nl
|
||||
Message-ID: <43A09C49.9040902@euler.org>
|
||||
Date: Wed, 14 Dec 2005 23:27:21 +0100
|
||||
From: Fred Flintstone <fred@euler.org>
|
||||
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051010)
|
||||
X-Accept-Language: nl-NL, nl, en
|
||||
MIME-Version: 1.0
|
||||
To: dfgh@floppydisk.nl
|
||||
Subject: Re: xyz
|
||||
References: <439C1136.90504@euler.org> <4399DD94.5070309@euler.org> <20051209233303.GA13812@gauss.org> <439B41ED.2080402@euler.org> <4399DD94.5070309@euler.org> <20051209233303.GA13812@gauss.org> <439A1E03.3090604@euler.org> <20051211184308.GB13513@gauss.org>
|
||||
In-Reply-To: <20051211184308.GB13513@gauss.org>
|
||||
X-Enigmail-Version: 0.92.0.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-UIDL: T<?"!%LG"!cAK"!_j(#!
|
||||
Content-Length: 1879
|
||||
|
||||
Test 123.
|
|
@ -0,0 +1,7 @@
|
|||
From: foo@example.com
|
||||
To: bar@example.com
|
||||
Subject: cycle0
|
||||
Message-Id: <cycle0@msg.id>
|
||||
Date: Tue, 21 Jun 2011 11:00 +0000
|
||||
|
||||
def
|
|
@ -0,0 +1,8 @@
|
|||
From: foo@example.com
|
||||
To: bar@example.com
|
||||
Subject: cycle0.0
|
||||
Message-Id: <cycle0.0@msg.id>
|
||||
References: <cycle0@msg.id>
|
||||
Date: Tue, 21 Jun 2011 12:00 +0000
|
||||
|
||||
def
|
|
@ -0,0 +1,8 @@
|
|||
From: foo@example.com
|
||||
To: bar@example.com
|
||||
Subject: cycle0.0.0
|
||||
Message-Id: <cycle0.0.0@msg.id>
|
||||
References: <cycle0@msg.id> <cycle0.0@msg.id>
|
||||
Date: Tue, 21 Jun 2011 13:00 +0000
|
||||
|
||||
def
|
|
@ -0,0 +1,8 @@
|
|||
From: foo@example.com
|
||||
To: bar@example.com
|
||||
Subject: rogue0
|
||||
Message-Id: <rogue0@msg.id>
|
||||
References: <cycle0.0@msg.id> <cycle0@msg.id>
|
||||
Date: Tue, 21 Jun 2011 15:00 +0000
|
||||
|
||||
def
|
Loading…
Reference in New Issue