* refactoring: split src/ into mu/ and lib/
This commit is contained in:
387
mu/tests/test-mu-cmd-cfind.c
Normal file
387
mu/tests/test-mu-cmd-cfind.c
Normal file
@ -0,0 +1,387 @@
|
||||
/* -*- mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
**
|
||||
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "../mu-query.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "mu-store.h"
|
||||
|
||||
static gchar*
|
||||
fill_contacts_cache (void)
|
||||
{
|
||||
gchar *cmdline, *tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM, tmpdir, MU_TESTMAILDIR);
|
||||
if (g_test_verbose())
|
||||
g_print ("%s\n", cmdline);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
g_free (cmdline);
|
||||
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_cfind_plain (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=plain "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
if (g_test_verbose())
|
||||
g_print ("%s\n", cmdline);
|
||||
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
/* note, output order is unspecified */
|
||||
g_assert (output);
|
||||
if (output[0] == 'H')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Helmut Kröger hk@testmu.xxx\n"
|
||||
"Mü testmu@testmu.xx\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Mü testmu@testmu.xx\n"
|
||||
"Helmut Kröger hk@testmu.xxx\n");
|
||||
|
||||
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_cfind_bbdb (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput, *expected;
|
||||
gchar today[12];
|
||||
const char* frm1;
|
||||
const char *frm2;
|
||||
struct tm *tmtoday;
|
||||
time_t now;
|
||||
const char *old_tz;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
old_tz = set_tz ("Europe/Helsinki");
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=bbdb "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
frm1 = ";; -*-coding: utf-8-emacs;-*-\n"
|
||||
";;; file-version: 6\n"
|
||||
"[\"Helmut\" \"Kröger\" nil nil nil nil (\"hk@testmu.xxx\") "
|
||||
"((creation-date . \"%s\") "
|
||||
"(time-stamp . \"1970-01-01\")) nil]\n"
|
||||
"[\"Mü\" \"\" nil nil nil nil (\"testmu@testmu.xx\") "
|
||||
"((creation-date . \"%s\") "
|
||||
"(time-stamp . \"1970-01-01\")) nil]\n";
|
||||
|
||||
|
||||
frm2 = ";; -*-coding: utf-8-emacs;-*-\n"
|
||||
";;; file-version: 6\n"
|
||||
"[\"Mü\" \"\" nil nil nil nil (\"testmu@testmu.xx\") "
|
||||
"((creation-date . \"%s\") "
|
||||
"(time-stamp . \"1970-01-01\")) nil]\n"
|
||||
"[\"Helmut\" \"Kröger\" nil nil nil nil (\"hk@testmu.xxx\") "
|
||||
"((creation-date . \"%s\") "
|
||||
"(time-stamp . \"1970-01-01\")) nil]\n";
|
||||
|
||||
g_assert (output);
|
||||
|
||||
now = time(NULL);
|
||||
tmtoday = localtime(&now);
|
||||
strftime(today,sizeof(today),"%Y-%m-%d", tmtoday);
|
||||
|
||||
expected = g_strdup_printf (output[52] == 'H' ? frm1 : frm2,
|
||||
today, today);
|
||||
|
||||
/* g_print ("\n%s\n", output); */
|
||||
|
||||
g_assert_cmpstr (output, ==, expected);
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
g_free (expected);
|
||||
|
||||
set_tz (old_tz);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_cfind_wl (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=wl "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
g_assert (output);
|
||||
if (output[0] == 'h')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"hk@testmu.xxx \"HelmutK\" \"Helmut Kröger\"\n"
|
||||
"testmu@testmu.xx \"Mü\" \"Mü\"\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"testmu@testmu.xx \"Mü\" \"Mü\"\n"
|
||||
"hk@testmu.xxx \"HelmutK\" \"Helmut Kröger\"\n");
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_cfind_mutt_alias (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=mutt-alias "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
/* both orders are possible... */
|
||||
g_assert (output);
|
||||
|
||||
if (output[6] == 'H')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"alias HelmutK Helmut Kröger <hk@testmu.xxx>\n"
|
||||
"alias Mü Mü <testmu@testmu.xx>\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"alias Mü Mü <testmu@testmu.xx>\n"
|
||||
"alias HelmutK Helmut Kröger <hk@testmu.xxx>\n");
|
||||
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_cfind_mutt_ab (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=mutt-ab "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
g_assert (output);
|
||||
if (output[39] == 'h')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Matching addresses in the mu database:\n"
|
||||
"hk@testmu.xxx\tHelmut Kröger\t\n"
|
||||
"testmu@testmu.xx\tMü\t\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Matching addresses in the mu database:\n"
|
||||
"testmu@testmu.xx\tMü\t\n"
|
||||
"hk@testmu.xxx\tHelmut Kröger\t\n");
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_cfind_org_contact (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=org-contact "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
g_assert (output);
|
||||
|
||||
if (output[2] == 'H')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"* Helmut Kröger\n"
|
||||
":PROPERTIES:\n"
|
||||
":EMAIL: hk@testmu.xxx\n"
|
||||
":END:\n\n"
|
||||
"* Mü\n"
|
||||
":PROPERTIES:\n"
|
||||
":EMAIL: testmu@testmu.xx\n"
|
||||
":END:\n\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"* Mü\n"
|
||||
":PROPERTIES:\n"
|
||||
":EMAIL: testmu@testmu.xx\n"
|
||||
":END:\n\n"
|
||||
"* Helmut Kröger\n"
|
||||
":PROPERTIES:\n"
|
||||
":EMAIL: hk@testmu.xxx\n"
|
||||
":END:\n\n");
|
||||
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_cfind_csv (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_contacts_cache ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
cmdline = g_strdup_printf ("%s cfind --muhome=%s --format=csv "
|
||||
"'testmu\\.xxx?'",
|
||||
MU_PROGRAM, muhome);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert (output);
|
||||
if (output[0] == 'H')
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Helmut Kröger,hk@testmu.xxx\n"
|
||||
"Mü,testmu@testmu.xx\n");
|
||||
else
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"Mü,testmu@testmu.xx\n"
|
||||
"Helmut Kröger,hk@testmu.xxx\n");
|
||||
|
||||
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
if (!set_en_us_utf8_locale())
|
||||
return 0; /* don't error out... */
|
||||
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-plain", test_mu_cfind_plain);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-bbdb", test_mu_cfind_bbdb);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-wl", test_mu_cfind_wl);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-mutt-alias",
|
||||
test_mu_cfind_mutt_alias);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-mutt-ab",
|
||||
test_mu_cfind_mutt_ab);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-org-contact",
|
||||
test_mu_cfind_org_contact);
|
||||
g_test_add_func ("/mu-cmd-cfind/test-mu-cfind-csv",
|
||||
test_mu_cfind_csv);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_LEVEL_WARNING|
|
||||
G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
|
||||
rv = g_test_run ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
803
mu/tests/test-mu-cmd.c
Normal file
803
mu/tests/test-mu-cmd.c
Normal file
@ -0,0 +1,803 @@
|
||||
/* -*- mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
**
|
||||
** Copyright (C) 2008-2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "../mu-query.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "mu-store.h"
|
||||
|
||||
|
||||
/* tests for the command line interface, uses testdir2 */
|
||||
|
||||
static gchar*
|
||||
fill_database (void)
|
||||
{
|
||||
gchar *cmdline, *tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM,
|
||||
tmpdir, MU_TESTMAILDIR2);
|
||||
if (g_test_verbose())
|
||||
g_print ("%s\n", cmdline);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
g_free (cmdline);
|
||||
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
newlines_in_output (const char* str)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
|
||||
while (str && *str) {
|
||||
if (*str == '\n')
|
||||
++count;
|
||||
++str;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
search (const char* query, unsigned expected)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput;
|
||||
|
||||
muhome = fill_database ();
|
||||
g_assert (muhome);
|
||||
|
||||
cmdline = g_strdup_printf ("%s find --muhome=%s %s",
|
||||
MU_PROGRAM, muhome, query);
|
||||
|
||||
if (g_test_verbose())
|
||||
g_printerr ("%s\n", cmdline);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline,
|
||||
&output, &erroutput,
|
||||
NULL, NULL));
|
||||
if (g_test_verbose())
|
||||
g_print ("\nOutput:\n%s", output);
|
||||
|
||||
g_assert_cmpuint (newlines_in_output(output),==,expected);
|
||||
|
||||
|
||||
/* we expect zero lines of error output if there is a match;
|
||||
* otherwise there should be one line 'No matches found' */
|
||||
/* g_assert_cmpuint (newlines_in_output(erroutput),==, */
|
||||
/* expected == 0 ? 1 : 0); */
|
||||
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
}
|
||||
|
||||
/* index testdir2, and make sure it adds two documents */
|
||||
static void
|
||||
test_mu_index (void)
|
||||
{
|
||||
MuStore *store;
|
||||
gchar *muhome, *xpath;
|
||||
|
||||
muhome = fill_database ();
|
||||
g_assert (muhome != NULL);
|
||||
|
||||
xpath = g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR, "xapian");
|
||||
|
||||
store = mu_store_new_read_only (xpath, NULL);
|
||||
g_assert (store);
|
||||
|
||||
g_assert_cmpuint (mu_store_count (store, NULL), ==, 12);
|
||||
mu_store_unref (store);
|
||||
|
||||
g_free (muhome);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_empty_query (void)
|
||||
{
|
||||
search ("\"\"", 12);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_01 (void)
|
||||
{
|
||||
search ("f:john fruit", 1);
|
||||
search ("f:soc@example.com", 1);
|
||||
search ("t:alki@example.com", 1);
|
||||
search ("t:alcibiades", 1);
|
||||
search ("f:soc@example.com OR f:john", 2);
|
||||
search ("f:soc@example.com OR f:john OR t:edmond", 3);
|
||||
search ("t:julius", 1);
|
||||
search ("s:dude", 1);
|
||||
search ("t:dantès", 1);
|
||||
}
|
||||
|
||||
|
||||
/* index testdir2, and make sure it adds two documents */
|
||||
static void
|
||||
test_mu_find_02 (void)
|
||||
{
|
||||
search ("bull", 1);
|
||||
search ("bull m:foo", 0);
|
||||
search ("bull m:/foo", 1);
|
||||
search ("bull m:/Foo", 1);
|
||||
search ("bull flag:a", 1);
|
||||
search ("g:x", 0);
|
||||
search ("flag:encrypted", 0);
|
||||
search ("flag:attach", 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_file (void)
|
||||
{
|
||||
search ("file:sittingbull.jpg", 1);
|
||||
search ("file:custer.jpg", 1);
|
||||
search ("file:custer.*", 1);
|
||||
search ("j:sit*", 1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_mime (void)
|
||||
{
|
||||
search ("mime:image/jpeg", 1);
|
||||
search ("mime:text/plain", 12);
|
||||
search ("y:text*", 12);
|
||||
search ("y:image*", 1);
|
||||
search ("mime:message/rfc822", 2);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_text_in_rfc822 (void)
|
||||
{
|
||||
search ("embed:dancing", 1);
|
||||
search ("e:curious", 1);
|
||||
search ("embed:with", 2);
|
||||
search ("e:karjala", 0);
|
||||
search ("embed:navigation", 1);
|
||||
}
|
||||
|
||||
|
||||
/* some more tests */
|
||||
static void
|
||||
test_mu_find_03 (void)
|
||||
{
|
||||
search ("bull", 1);
|
||||
search ("bull m:foo", 0);
|
||||
search ("bull m:/foo", 1);
|
||||
search ("i:3BE9E6535E0D852173@emss35m06.us.lmco.com", 1);
|
||||
}
|
||||
|
||||
|
||||
static void /* error cases */
|
||||
test_mu_find_04 (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *erroutput;
|
||||
|
||||
muhome = fill_database ();
|
||||
g_assert (muhome);
|
||||
|
||||
cmdline = g_strdup_printf ("%s --muhome=%cfoo%cbar%cnonexistent "
|
||||
"find f:socrates",
|
||||
MU_PROGRAM,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, &erroutput,
|
||||
NULL, NULL));
|
||||
|
||||
/* we expect multiple lines of error output */
|
||||
g_assert_cmpuint (newlines_in_output(erroutput),>=,1);
|
||||
|
||||
g_free (erroutput);
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_find_links (void)
|
||||
{
|
||||
gchar *muhome, *cmdline, *output, *erroutput, *tmpdir;
|
||||
|
||||
|
||||
muhome = fill_database ();
|
||||
g_assert (muhome);
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
|
||||
cmdline = g_strdup_printf (
|
||||
"%s find --muhome=%s --format=links --linksdir=%s "
|
||||
"mime:message/rfc822", MU_PROGRAM, muhome, tmpdir);
|
||||
|
||||
if (g_test_verbose())
|
||||
g_printerr ("%s\n", cmdline);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline,
|
||||
&output, &erroutput,
|
||||
NULL, NULL));
|
||||
if (g_test_verbose())
|
||||
g_print ("\nOutput:\n%s", output);
|
||||
|
||||
/* there should be no errors */
|
||||
g_assert_cmpuint (newlines_in_output(output),==,0);
|
||||
g_assert_cmpuint (newlines_in_output(erroutput),==,0);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
|
||||
|
||||
|
||||
/* now we try again, we should get 2 + 1 lines of error output,
|
||||
* because the target files already exist */
|
||||
g_assert (g_spawn_command_line_sync (cmdline,
|
||||
&output, &erroutput,
|
||||
NULL, NULL));
|
||||
if (g_test_verbose())
|
||||
g_print ("\nOutput:\n%s", output);
|
||||
|
||||
g_assert_cmpuint (newlines_in_output(output),==,0);
|
||||
g_assert_cmpuint (newlines_in_output(erroutput),==,3);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
|
||||
/* now we try again with --clearlinks, and the we should be
|
||||
* back to 0 errors */
|
||||
g_free (cmdline);
|
||||
cmdline = g_strdup_printf (
|
||||
"%s find --muhome=%s --format=links --linksdir=%s --clearlinks "
|
||||
"mime:message/rfc822", MU_PROGRAM, muhome, tmpdir);
|
||||
g_assert (g_spawn_command_line_sync (cmdline,
|
||||
&output, &erroutput,
|
||||
NULL, NULL));
|
||||
if (g_test_verbose())
|
||||
g_print ("\nOutput:\n%s", output);
|
||||
g_assert_cmpuint (newlines_in_output(output),==,0);
|
||||
g_assert_cmpuint (newlines_in_output(erroutput),==,0);
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
|
||||
g_free (cmdline);
|
||||
g_free (muhome);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* some more tests */
|
||||
static void
|
||||
test_mu_find_maildir_special (void)
|
||||
{
|
||||
/* ensure that maldirs with spaces in their names work... */
|
||||
search ("\"maildir:/wom bat\" subject:atoms", 1);
|
||||
search ("\"maildir:/wOm_bàT\"", 3);
|
||||
search ("\"maildir:/wOm*\"", 3);
|
||||
search ("\"maildir:/wOm *\"", 3);
|
||||
search ("\"maildir:wom bat\"", 0);
|
||||
search ("\"maildir:/wombat\"", 0);
|
||||
search ("subject:atoms", 1);
|
||||
}
|
||||
|
||||
|
||||
/* static void */
|
||||
/* test_mu_find_mime_types (void) */
|
||||
/* { */
|
||||
/* /\* ensure that maldirs with spaces in their names work... *\/ */
|
||||
/* search ("\"maildir:/wom bat\" subject:atoms", 1); */
|
||||
/* search ("\"maildir:/wOm_bàT\"", 3); */
|
||||
/* search ("subject:atoms", 1); */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_extract_01 (void)
|
||||
{
|
||||
gchar *cmdline, *output, *erroutput, *tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
|
||||
if (g_test_verbose())
|
||||
g_print ("cmd: %s\n", cmdline);
|
||||
|
||||
output = erroutput = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output,
|
||||
==,
|
||||
"MIME-parts in this message:\n"
|
||||
" 0 <none> text/plain [<none>] (0.0 kB)\n"
|
||||
" 1 sittingbull.jpg image/jpeg [inline] (23.9 kB)\n"
|
||||
" 2 custer.jpg image/jpeg [inline] (21.6 kB)\n");
|
||||
|
||||
/* we expect zero lines of error output */
|
||||
g_assert_cmpuint (newlines_in_output(erroutput),==,0);
|
||||
|
||||
g_free (output);
|
||||
g_free (erroutput);
|
||||
g_free (cmdline);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
static gint64
|
||||
get_file_size (const char* path)
|
||||
{
|
||||
int rv;
|
||||
struct stat statbuf;
|
||||
|
||||
rv = stat (path, &statbuf);
|
||||
if (rv != 0)
|
||||
return -1;
|
||||
|
||||
return (gint64)statbuf.st_size;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_extract_02 (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
gchar *att1, *att2;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s -a "
|
||||
"--target-dir=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
|
||||
att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR);
|
||||
att2 = g_strdup_printf ("%s%csittingbull.jpg", tmpdir, G_DIR_SEPARATOR);
|
||||
|
||||
g_assert_cmpint (get_file_size(att1),==,15960);
|
||||
g_assert_cmpint (get_file_size(att2),==,17674);
|
||||
|
||||
g_free (output);
|
||||
g_free (tmpdir);
|
||||
g_free (cmdline);
|
||||
g_free (att1);
|
||||
g_free (att2);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_extract_03 (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
gchar *att1, *att2;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s --parts 2 "
|
||||
"--target-dir=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
|
||||
att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR);
|
||||
att2 = g_strdup_printf ("%s%csittingbull.jpg", tmpdir, G_DIR_SEPARATOR);
|
||||
|
||||
g_assert_cmpint (get_file_size(att1),==,15960); /* should not exist */
|
||||
g_assert_cmpint (get_file_size(att2),==,-1);
|
||||
|
||||
g_free (output);
|
||||
g_free (tmpdir);
|
||||
g_free (cmdline);
|
||||
g_free (att1);
|
||||
g_free (att2);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_extract_overwrite (void)
|
||||
{
|
||||
gchar *cmdline, *output, *erroutput, *tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s -a "
|
||||
"--target-dir=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM, tmpdir, tmpdir,
|
||||
MU_TESTMAILDIR2, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
g_assert_cmpstr (erroutput, ==, "");
|
||||
g_free (erroutput);
|
||||
g_free (output);
|
||||
|
||||
/* now, it should fail, because we don't allow overwrites
|
||||
* without --overwrite */
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
g_assert_cmpstr (erroutput, !=, "");
|
||||
g_free (erroutput);
|
||||
g_free (output);
|
||||
|
||||
g_free (cmdline);
|
||||
/* this should work now, because we have specified --overwrite */
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s -a --overwrite "
|
||||
"--target-dir=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM, tmpdir, tmpdir,
|
||||
MU_TESTMAILDIR2, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
g_assert_cmpstr (erroutput, ==, "");
|
||||
g_free (erroutput);
|
||||
g_free (output);
|
||||
|
||||
g_free (tmpdir);
|
||||
g_free (cmdline);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_extract_by_name (void)
|
||||
{
|
||||
gchar *cmdline, *output, *erroutput, *tmpdir, *path;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s extract --muhome=%s "
|
||||
"--target-dir=%s %s%cFoo%ccur%cmail5 "
|
||||
"sittingbull.jpg",
|
||||
MU_PROGRAM, tmpdir, tmpdir,
|
||||
MU_TESTMAILDIR2, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
g_assert_cmpstr (erroutput, ==, "");
|
||||
path = g_strdup_printf ("%s%c%s", tmpdir, G_DIR_SEPARATOR,
|
||||
"sittingbull.jpg");
|
||||
g_assert (access (path, F_OK) == 0);
|
||||
g_free (path);
|
||||
|
||||
g_free (erroutput);
|
||||
g_free (output);
|
||||
|
||||
g_free (tmpdir);
|
||||
g_free (cmdline);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_view_01 (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
int len;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s view --muhome=%s %s%cbar%ccur%cmail4",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, !=, NULL);
|
||||
|
||||
/*
|
||||
* note: there are two possibilities here; older versions of
|
||||
* GMime will produce:
|
||||
*
|
||||
* From: "=?iso-8859-1?Q? =F6tzi ?=" <oetzi@web.de>
|
||||
*
|
||||
* while newer ones return something like:
|
||||
*
|
||||
* From: ?tzi <oetzi@web.de>
|
||||
*
|
||||
* or even
|
||||
*
|
||||
* From: \xc3\xb6tzi <oetzi@web.de>
|
||||
*
|
||||
* both are 'okay' from mu's perspective; it'd be even better
|
||||
* to have some #ifdefs for the GMime versions, but this
|
||||
* should work for now
|
||||
*
|
||||
* Added 350 as 'okay', which comes with gmime 2.4.24 (ubuntu 10.04)
|
||||
*/
|
||||
len = strlen(output);
|
||||
/* g_print ("\n[%s] (%d)\n", output, len); */
|
||||
g_assert (len > 349);
|
||||
|
||||
g_free (output);
|
||||
g_free (cmdline);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_view_multi (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
int len;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s view --muhome=%s "
|
||||
"%s%cbar%ccur%cmail5 "
|
||||
"%s%cbar%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, !=, NULL);
|
||||
|
||||
len = strlen(output);
|
||||
/* g_print ("\n[%s](%u)\n", output, len); */
|
||||
g_assert_cmpuint (len,>,150);
|
||||
|
||||
g_free (output);
|
||||
g_free (cmdline);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_view_multi_separate (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
int len;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s view --terminate --muhome=%s "
|
||||
"%s%cbar%ccur%cmail5 "
|
||||
"%s%cbar%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, !=, NULL);
|
||||
|
||||
len = strlen(output);
|
||||
/* g_print ("\n[%s](%u)\n", output, len); */
|
||||
g_assert_cmpuint (len,>,150);
|
||||
|
||||
g_free (output);
|
||||
g_free (cmdline);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_view_attach (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
int len;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s view --muhome=%s %s%cFoo%ccur%cmail5",
|
||||
MU_PROGRAM,
|
||||
tmpdir,
|
||||
MU_TESTMAILDIR2,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, !=, NULL);
|
||||
|
||||
len = strlen(output);
|
||||
/* g_print ("\n[%s] (%d)\n", output, len);*/
|
||||
g_assert (len == 170 || len == 168);
|
||||
|
||||
g_free (output);
|
||||
g_free (cmdline);
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_mkdir_01 (void)
|
||||
{
|
||||
gchar *cmdline, *output, *tmpdir;
|
||||
gchar *dir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
|
||||
|
||||
cmdline = g_strdup_printf ("%s mkdir --muhome=%s %s%ctest1 %s%ctest2",
|
||||
MU_PROGRAM,tmpdir,
|
||||
tmpdir, G_DIR_SEPARATOR,
|
||||
tmpdir, G_DIR_SEPARATOR);
|
||||
|
||||
output = NULL;
|
||||
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL,
|
||||
NULL, NULL));
|
||||
g_assert_cmpstr (output, ==, "");
|
||||
|
||||
dir = g_strdup_printf ("%s%ctest1%ccur", tmpdir, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
g_assert (access (dir, F_OK) == 0);
|
||||
g_free (dir);
|
||||
|
||||
dir = g_strdup_printf ("%s%ctest2%ctmp", tmpdir, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
g_assert (access (dir, F_OK) == 0);
|
||||
g_free (dir);
|
||||
|
||||
dir = g_strdup_printf ("%s%ctest1%cnew", tmpdir, G_DIR_SEPARATOR,
|
||||
G_DIR_SEPARATOR);
|
||||
g_assert (access (dir, F_OK) == 0);
|
||||
g_free (dir);
|
||||
|
||||
g_free (output);
|
||||
g_free (tmpdir);
|
||||
g_free (cmdline);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
if (!set_en_us_utf8_locale())
|
||||
return 0; /* don't error out... */
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-index", test_mu_index);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-empty-query",
|
||||
test_mu_find_empty_query);
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-01", test_mu_find_01);
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-02", test_mu_find_02);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-file", test_mu_find_file);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-mime", test_mu_find_mime);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-links", test_mu_find_links);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-text-in-rfc822",
|
||||
test_mu_find_text_in_rfc822);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-03", test_mu_find_03);
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-04", test_mu_find_04);
|
||||
g_test_add_func ("/mu-cmd/test-mu-find-maildir-special",
|
||||
test_mu_find_maildir_special);
|
||||
g_test_add_func ("/mu-cmd/test-mu-extract-01", test_mu_extract_01);
|
||||
g_test_add_func ("/mu-cmd/test-mu-extract-02", test_mu_extract_02);
|
||||
g_test_add_func ("/mu-cmd/test-mu-extract-03", test_mu_extract_03);
|
||||
g_test_add_func ("/mu-cmd/test-mu-extract-overwrite",
|
||||
test_mu_extract_overwrite);
|
||||
g_test_add_func ("/mu-cmd/test-mu-extract-by-name",
|
||||
test_mu_extract_by_name);
|
||||
|
||||
g_test_add_func ("/mu-cmd/test-mu-view-01", test_mu_view_01);
|
||||
g_test_add_func ("/mu-cmd/test-mu-view-multi",
|
||||
test_mu_view_multi);
|
||||
g_test_add_func ("/mu-cmd/test-mu-view-multi-separate",
|
||||
test_mu_view_multi_separate);
|
||||
g_test_add_func ("/mu-cmd/test-mu-view-attach", test_mu_view_attach);
|
||||
g_test_add_func ("/mu-cmd/test-mu-mkdir-01", test_mu_mkdir_01);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_LEVEL_WARNING|
|
||||
G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
rv = g_test_run ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
184
mu/tests/test-mu-contacts.c
Normal file
184
mu/tests/test-mu-contacts.c
Normal file
@ -0,0 +1,184 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "mu-contacts.h"
|
||||
|
||||
static gchar*
|
||||
fill_database (void)
|
||||
{
|
||||
gchar *cmdline, *tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM, tmpdir, MU_TESTMAILDIR);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
g_free (cmdline);
|
||||
|
||||
return tmpdir;
|
||||
}
|
||||
|
||||
|
||||
struct _Contact {
|
||||
char *name, *email;
|
||||
time_t tstamp;
|
||||
};
|
||||
typedef struct _Contact Contact;
|
||||
|
||||
static Contact*
|
||||
contact_new (const char *email, const char *name, size_t tstamp)
|
||||
{
|
||||
Contact *contact;
|
||||
|
||||
contact = g_slice_new (Contact);
|
||||
contact->name = name ? g_strdup (name) :NULL;
|
||||
contact->email = email ? g_strdup (email) : NULL;
|
||||
contact->tstamp = tstamp;
|
||||
|
||||
return contact;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
contact_destroy (Contact *contact)
|
||||
{
|
||||
if (contact) {
|
||||
g_free (contact->name);
|
||||
g_free (contact->email);
|
||||
g_slice_free (Contact, contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
each_contact (const char *email, const char *name, time_t tstamp,
|
||||
GSList **lst)
|
||||
{
|
||||
Contact *contact;
|
||||
|
||||
/* g_print ("[n:%s, e:%s]\n", name, email); */
|
||||
|
||||
contact = contact_new (email, name, tstamp);
|
||||
*lst = g_slist_prepend (*lst, contact);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
has_contact (GSList *lst, const char* name_or_email, gboolean use_name)
|
||||
{
|
||||
while (lst) {
|
||||
Contact *c;
|
||||
c = (Contact*)lst->data;
|
||||
|
||||
/* g_print ("{n:%s,e:%s}\n", c->name, c->email); */
|
||||
|
||||
if (use_name && g_strcmp0(name_or_email, c->name) == 0)
|
||||
return TRUE;
|
||||
if (g_strcmp0 (name_or_email, c->email) == 0)
|
||||
return TRUE;
|
||||
|
||||
lst = g_slist_next (lst);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GSList*
|
||||
accumulate_contacts (MuContacts *contacts, const gchar *pattern)
|
||||
{
|
||||
GSList *lst;
|
||||
|
||||
lst = NULL;
|
||||
g_assert (mu_contacts_foreach (contacts,
|
||||
(MuContactsForeachFunc)each_contact,
|
||||
&lst, pattern, NULL));
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_contacts_01 (void)
|
||||
{
|
||||
MuContacts *contacts;
|
||||
gchar *muhome, *contactsfile;
|
||||
GSList *clist;
|
||||
|
||||
muhome = fill_database ();
|
||||
g_assert (muhome != NULL);
|
||||
contactsfile = g_strdup_printf ("%s%ccache%ccontacts",
|
||||
muhome, G_DIR_SEPARATOR, G_DIR_SEPARATOR);
|
||||
/* g_print ("[%s]\n", contactsfile); */
|
||||
|
||||
contacts = mu_contacts_new (contactsfile);
|
||||
g_assert (contacts);
|
||||
|
||||
clist = accumulate_contacts (contacts, "Mü");
|
||||
g_assert_cmpint (g_slist_length (clist), ==, 1);
|
||||
g_assert (has_contact (clist, "Mü", TRUE));
|
||||
g_assert (has_contact (clist, "testmu@testmu.xx", FALSE));
|
||||
g_slist_foreach (clist, (GFunc)contact_destroy, NULL);
|
||||
g_slist_free (clist);
|
||||
|
||||
clist = accumulate_contacts (contacts, "testmu\\.xxx?");
|
||||
g_assert_cmpint (g_slist_length (clist), ==, 2);
|
||||
g_assert (has_contact (clist, "Mü", TRUE));
|
||||
g_assert (has_contact (clist, "testmu@testmu.xx", FALSE));
|
||||
g_assert (has_contact (clist, "Helmut Kröger", TRUE));
|
||||
g_assert (has_contact (clist, "hk@testmu.xxx", FALSE));
|
||||
|
||||
g_slist_foreach (clist, (GFunc)contact_destroy, NULL);
|
||||
g_slist_free (clist);
|
||||
|
||||
mu_contacts_destroy (contacts);
|
||||
|
||||
g_free (contactsfile);
|
||||
g_free (muhome);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_add_func ("/mu-contacts/test-mu-contacts-01", test_mu_contacts_01);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
rv = g_test_run ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
690
mu/tests/test-mu-query.c
Normal file
690
mu/tests/test-mu-query.c
Normal file
@ -0,0 +1,690 @@
|
||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "mu-query.h"
|
||||
#include "mu-str.h"
|
||||
#include "mu-store.h"
|
||||
|
||||
static gchar*
|
||||
fill_database (const char *testdir)
|
||||
{
|
||||
gchar *cmdline, *tmpdir, *xpath;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM, tmpdir, testdir);
|
||||
|
||||
if (g_test_verbose())
|
||||
g_printerr ("\n%s\n", cmdline);
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
g_free (cmdline);
|
||||
|
||||
xpath= g_strdup_printf ("%s%c%s", tmpdir,
|
||||
G_DIR_SEPARATOR, "xapian");
|
||||
g_free (tmpdir);
|
||||
|
||||
return xpath;
|
||||
}
|
||||
|
||||
static void
|
||||
assert_no_dups (MuMsgIter *iter)
|
||||
{
|
||||
GHashTable *hash;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify)g_free, NULL);
|
||||
|
||||
mu_msg_iter_reset (iter);
|
||||
while (!mu_msg_iter_is_done(iter)) {
|
||||
MuMsg *msg;
|
||||
msg = mu_msg_iter_get_msg_floating (iter);
|
||||
/* make sure there are no duplicates */
|
||||
g_assert (!g_hash_table_lookup (hash, mu_msg_get_path (msg)));
|
||||
g_hash_table_insert (hash, g_strdup (mu_msg_get_path(msg)),
|
||||
GUINT_TO_POINTER(TRUE));
|
||||
mu_msg_iter_next (iter);
|
||||
}
|
||||
mu_msg_iter_reset (iter);
|
||||
g_hash_table_destroy (hash);
|
||||
}
|
||||
|
||||
|
||||
/* note: this also *moves the iter* */
|
||||
static guint
|
||||
run_and_count_matches (const char *xpath, const char *query)
|
||||
{
|
||||
MuQuery *mquery;
|
||||
MuMsgIter *iter;
|
||||
MuStore *store;
|
||||
guint count1, count2;
|
||||
|
||||
store = mu_store_new_read_only (xpath, NULL);
|
||||
g_assert (store);
|
||||
|
||||
mquery = mu_query_new (store, NULL);
|
||||
g_assert (query);
|
||||
|
||||
mu_store_unref (store);
|
||||
|
||||
if (g_test_verbose()) {
|
||||
char *xs;
|
||||
g_print ("\n==> query: %s\n", query);
|
||||
xs = mu_query_preprocess (query, NULL);
|
||||
g_print ("==> preproc: '%s'\n", xs);
|
||||
g_free (xs);
|
||||
xs = mu_query_as_string (mquery, query, NULL);
|
||||
g_print ("==> xquery: '%s'\n", xs);
|
||||
g_free (xs);
|
||||
}
|
||||
|
||||
|
||||
iter = mu_query_run (mquery, query, FALSE, MU_MSG_FIELD_ID_NONE,
|
||||
FALSE, -1, NULL);
|
||||
mu_query_destroy (mquery);
|
||||
g_assert (iter);
|
||||
|
||||
assert_no_dups (iter);
|
||||
|
||||
/* run query twice, to test mu_msg_iter_reset */
|
||||
for (count1 = 0; !mu_msg_iter_is_done(iter);
|
||||
mu_msg_iter_next(iter), ++count1);
|
||||
|
||||
mu_msg_iter_reset (iter);
|
||||
|
||||
assert_no_dups (iter);
|
||||
|
||||
for (count2 = 0; !mu_msg_iter_is_done(iter);
|
||||
mu_msg_iter_next(iter), ++count2);
|
||||
|
||||
mu_msg_iter_destroy (iter);
|
||||
|
||||
g_assert_cmpuint (count1, ==, count2);
|
||||
|
||||
return count1;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *query;
|
||||
size_t count; /* expected number of matches */
|
||||
} QResults;
|
||||
|
||||
static void
|
||||
test_mu_query_01 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "basic", 3 },
|
||||
{ "question", 5 },
|
||||
{ "thanks", 2 },
|
||||
{ "html", 4 },
|
||||
{ "subject:elisp", 1 },
|
||||
{ "html AND contains", 1 },
|
||||
{ "html and contains", 1 },
|
||||
{ "from:pepernoot", 0 },
|
||||
{ "foo:pepernoot", 0 },
|
||||
{ "funky", 1 },
|
||||
{ "fünkÿ", 1 },
|
||||
{ "", 17 }
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_query_02 (void)
|
||||
{
|
||||
const char* q;
|
||||
gchar *xpath;
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath);
|
||||
|
||||
q = "i:f7ccd24b0808061357t453f5962w8b61f9a453b684d0@mail.gmail.com";
|
||||
|
||||
g_assert_cmpuint (run_and_count_matches(xpath, q), ==, 1);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_03 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "ploughed", 1},
|
||||
{ "i:3BE9E6535E3029448670913581E7A1A20D852173@"
|
||||
"emss35m06.us.lmco.com", 1},
|
||||
|
||||
/* subsets of the words in the subject should match */
|
||||
{ "s:gcc include search order" , 1},
|
||||
{ "s:gcc include search" , 1},
|
||||
{ "s:search order" , 1},
|
||||
{ "s:include" , 1},
|
||||
|
||||
{ "s:lisp", 1},
|
||||
{ "s:LISP", 1},
|
||||
|
||||
{ "s:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
||||
{ "subject:Re: Learning LISP; Scheme vs elisp.", 0},
|
||||
{ "subject:\"Re: Learning LISP; Scheme vs elisp.\"", 1},
|
||||
{ "to:help-gnu-emacs@gnu.org", 4},
|
||||
{ "t:help-gnu-emacs", 0},
|
||||
{ "flag:flagged", 1}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_04 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "frodo@example.com", 1},
|
||||
{ "f:frodo@example.com", 1},
|
||||
{ "f:Frodo Baggins", 1},
|
||||
{ "bilbo@anotherexample.com", 1},
|
||||
{ "t:bilbo@anotherexample.com", 1},
|
||||
{ "t:bilbo", 1},
|
||||
{ "f:bilbo", 0},
|
||||
{ "baggins", 1},
|
||||
{ "prio:h", 1},
|
||||
{ "prio:high", 1},
|
||||
{ "prio:normal", 9},
|
||||
{ "prio:l", 7},
|
||||
{ "not prio:l", 10},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_logic (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "subject:gcc" , 1},
|
||||
{ "subject:lisp" , 1},
|
||||
{ "subject:gcc OR subject:lisp" , 2},
|
||||
{ "subject:gcc or subject:lisp" , 2},
|
||||
{ "subject:gcc AND subject:lisp" , 0},
|
||||
|
||||
{ "subject:gcc OR (subject:scheme AND subject:elisp)" , 2},
|
||||
{ "(subject:gcc OR subject:scheme) AND subject:elisp" , 1}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_accented_chars_01 (void)
|
||||
{
|
||||
MuQuery *query;
|
||||
MuMsgIter *iter;
|
||||
MuMsg *msg;
|
||||
MuStore *store;
|
||||
gchar *xpath;
|
||||
GError *err;
|
||||
gchar *summ;
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
store = mu_store_new_read_only (xpath, NULL);
|
||||
g_assert (store);
|
||||
|
||||
query = mu_query_new (store, NULL);
|
||||
mu_store_unref (store);
|
||||
|
||||
iter = mu_query_run (query, "fünkÿ", FALSE, MU_MSG_FIELD_ID_NONE,
|
||||
FALSE, -1, NULL);
|
||||
err = NULL;
|
||||
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
|
||||
if (!msg) {
|
||||
g_warning ("error getting message: %s", err->message);
|
||||
g_error_free (err);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_assert_cmpstr (mu_msg_get_subject(msg),==,
|
||||
"Greetings from Lothlórien");
|
||||
/* TODO: fix this again */
|
||||
|
||||
summ = mu_str_summarize (mu_msg_get_body_text(msg), 5);
|
||||
g_assert_cmpstr (summ,==, "Let's write some fünkÿ text using umlauts. Foo.");
|
||||
g_free (summ);
|
||||
|
||||
mu_msg_iter_destroy (iter);
|
||||
mu_query_destroy (query);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_query_accented_chars_02 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "f:mü", 1},
|
||||
{ "s:motörhead", 1},
|
||||
{ "t:Helmut", 1},
|
||||
{ "t:Kröger", 1},
|
||||
{ "s:MotorHeäD", 1},
|
||||
{ "queensryche", 1},
|
||||
{ "Queensrÿche", 1},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
g_free (xpath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_wildcards (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "f:mü", 1},
|
||||
{ "s:mo*", 1},
|
||||
{ "t:Helm*", 1},
|
||||
{ "queensryche", 1},
|
||||
{ "Queen*", 1},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_dates_helsinki (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
const char *old_tz;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "date:20080731..20080804", 5},
|
||||
/* { "date:20080804..20080731", 5}, */
|
||||
{ "date:20080731..20080804", 5},
|
||||
{ "date:20080731..20080804 s:gcc", 1},
|
||||
{ "date:200808110803..now", 5},
|
||||
{ "date:200808110803..today", 5},
|
||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||
{ "date:200808110801..now", 5},
|
||||
};
|
||||
|
||||
old_tz = set_tz ("Europe/Helsinki");
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
set_tz (old_tz);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_query_dates_sydney (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
const char *old_tz;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "date:20080731..20080804", 5},
|
||||
/* { "date:20080804..20080731", 5}, */
|
||||
{ "date:20080731..20080804", 5},
|
||||
{ "date:20080731..20080804 s:gcc", 1},
|
||||
{ "date:200808110803..now", 5},
|
||||
{ "date:200808110803..today", 5},
|
||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||
{ "date:200808110801..now", 5},
|
||||
};
|
||||
|
||||
old_tz = set_tz ("Australia/Sydney");
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
set_tz (old_tz);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
test_mu_query_dates_la (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
const char *old_tz;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "date:20080731..20080804", 5},
|
||||
/* { "date:20080804..20080731", 5}, */
|
||||
{ "date:20080731..20080804", 5},
|
||||
{ "date:20080731..20080804 s:gcc", 1},
|
||||
{ "date:200808110803..now", 4},
|
||||
{ "date:200808110803..today", 4},
|
||||
/* { "date:now..2008-08-11-08-03", 1}, */
|
||||
/* { "date:today..2008-08-11-08-03", 1}, */
|
||||
{ "date:200808110801..now", 4}, /* does not match in LA */
|
||||
};
|
||||
|
||||
old_tz = set_tz ("America/Los_Angeles");
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
set_tz (old_tz);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_sizes (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "size:0b..2m", 17},
|
||||
{ "size:2k..4k", 4},
|
||||
{ "size:2m..0b", 17}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_attach (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "j:sittingbull.jpg", 1},
|
||||
{ "file:custer", 0},
|
||||
{ "file:custer.jpg", 1}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR2);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
/* g_print ("(%s)\n", xpath); */
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_tags (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "x:paradise", 1},
|
||||
{ "tag:lost", 1},
|
||||
{ "tag:lost tag:paradise", 1},
|
||||
{ "tag:lost tag:horizon", 0},
|
||||
{ "tag:lost OR tag:horizon", 1},
|
||||
{ "x:paradise,lost", 0},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR2);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
/* g_print ("(%s)\n", xpath); */
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_signed_encrypted (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "flag:encrypted", 2},
|
||||
{ "flag:signed", 2},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
/* g_print ("(%s)\n", xpath); */
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i)
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_tags_02 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
int i;
|
||||
|
||||
QResults queries[] = {
|
||||
{ "x:paradise", 1},
|
||||
{ "tag:@NextActions", 1},
|
||||
{ "x:queensrÿche", 1},
|
||||
{ "tag:lost OR tag:operation*", 2},
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR2);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
/* g_print ("(%s)\n", xpath); */
|
||||
|
||||
for (i = 0; i != G_N_ELEMENTS(queries); ++i) {
|
||||
/* g_print ("%s\n", queries[i].query); */
|
||||
g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query),
|
||||
==, queries[i].count);
|
||||
}
|
||||
|
||||
g_free (xpath);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_query_preprocess (void)
|
||||
{
|
||||
unsigned u;
|
||||
struct {
|
||||
const gchar *expr, *expected;
|
||||
} testcases [] = {
|
||||
{ "hello", "hello" },
|
||||
{ "/[Gmail].Sent Mail", "__gmail__sent mail" }
|
||||
/* add more */
|
||||
};
|
||||
|
||||
|
||||
for (u = 0; u != G_N_ELEMENTS(testcases); ++u) {
|
||||
gchar *prep;
|
||||
prep = mu_query_preprocess (testcases[u].expr, NULL);
|
||||
g_assert_cmpstr (prep, ==, testcases[u].expected);
|
||||
g_free (prep);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-preprocess",
|
||||
test_mu_query_preprocess);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-01", test_mu_query_01);
|
||||
g_test_add_func ("/mu-query/test-mu-query-02", test_mu_query_02);
|
||||
g_test_add_func ("/mu-query/test-mu-query-03", test_mu_query_03);
|
||||
g_test_add_func ("/mu-query/test-mu-query-04", test_mu_query_04);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-signed-encrypted",
|
||||
test_mu_query_signed_encrypted);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-logic", test_mu_query_logic);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-accented-chars-1",
|
||||
test_mu_query_accented_chars_01);
|
||||
g_test_add_func ("/mu-query/test-mu-query-accented-chars-2",
|
||||
test_mu_query_accented_chars_02);
|
||||
g_test_add_func ("/mu-query/test-mu-query-wildcards",
|
||||
test_mu_query_wildcards);
|
||||
g_test_add_func ("/mu-query/test-mu-query-sizes",
|
||||
test_mu_query_sizes);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-dates-helsinki",
|
||||
test_mu_query_dates_helsinki); /* finland */
|
||||
g_test_add_func ("/mu-query/test-mu-query-dates-sydney",
|
||||
test_mu_query_dates_sydney);
|
||||
g_test_add_func ("/mu-query/test-mu-query-dates-la",
|
||||
test_mu_query_dates_la);
|
||||
|
||||
g_test_add_func ("/mu-query/test-mu-query-attach",
|
||||
test_mu_query_attach);
|
||||
g_test_add_func ("/mu-query/test-mu-query-tags",
|
||||
test_mu_query_tags);
|
||||
g_test_add_func ("/mu-query/test-mu-query-tags_02",
|
||||
test_mu_query_tags_02);
|
||||
|
||||
if (!g_test_verbose())
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
|
||||
rv = g_test_run ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
98
mu/tests/test-mu-runtime.c
Normal file
98
mu/tests/test-mu-runtime.c
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "src/mu-runtime.h"
|
||||
|
||||
static void
|
||||
test_mu_runtime_init (void)
|
||||
{
|
||||
gchar* tmpdir;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (tmpdir);
|
||||
g_assert (mu_runtime_init (tmpdir, "test-mu-runtime") == TRUE);
|
||||
mu_runtime_uninit ();
|
||||
|
||||
g_assert (mu_runtime_init (tmpdir, "test-mu-runtime") == TRUE);
|
||||
mu_runtime_uninit ();
|
||||
|
||||
g_free (tmpdir);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_runtime_data (void)
|
||||
{
|
||||
gchar *homedir, *xdir, *bmfile;
|
||||
|
||||
homedir = test_mu_common_get_random_tmpdir();
|
||||
g_assert (homedir);
|
||||
|
||||
xdir = g_strdup_printf ("%s%c%s", homedir,
|
||||
G_DIR_SEPARATOR, "xapian" );
|
||||
|
||||
bmfile = g_strdup_printf ("%s%c%s", homedir,
|
||||
G_DIR_SEPARATOR, "bookmarks");
|
||||
|
||||
g_assert (mu_runtime_init (homedir, "test-mu-runtime") == TRUE);
|
||||
|
||||
g_assert_cmpstr (homedir, ==, mu_runtime_path (MU_RUNTIME_PATH_MUHOME));
|
||||
g_assert_cmpstr (xdir, ==, mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB));
|
||||
g_assert_cmpstr (bmfile, ==, mu_runtime_path (MU_RUNTIME_PATH_BOOKMARKS));
|
||||
|
||||
mu_runtime_uninit ();
|
||||
|
||||
g_free (homedir);
|
||||
g_free (xdir);
|
||||
g_free (bmfile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
/* mu_runtime_init/uninit */
|
||||
g_test_add_func ("/mu-runtime/mu-runtime-init",
|
||||
test_mu_runtime_init);
|
||||
g_test_add_func ("/mu-runtime/mu-runtime-data",
|
||||
test_mu_runtime_data);
|
||||
|
||||
g_log_set_handler (NULL,
|
||||
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
|
||||
246
mu/tests/test-mu-threads.c
Normal file
246
mu/tests/test-mu-threads.c
Normal file
@ -0,0 +1,246 @@
|
||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify it
|
||||
** under the terms of the GNU General Public License as published by the
|
||||
** Free Software Foundation; either version 3, or (at your option) any
|
||||
** later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software Foundation,
|
||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "test-mu-common.h"
|
||||
#include "mu-query.h"
|
||||
#include "mu-str.h"
|
||||
|
||||
static gchar*
|
||||
fill_database (const char *testdir)
|
||||
{
|
||||
gchar *cmdline, *tmpdir, *xpath;
|
||||
|
||||
tmpdir = test_mu_common_get_random_tmpdir();
|
||||
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
|
||||
" --quiet",
|
||||
MU_PROGRAM, tmpdir, testdir);
|
||||
/* g_print ("%s\n", cmdline); */
|
||||
|
||||
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
|
||||
NULL, NULL));
|
||||
g_free (cmdline);
|
||||
xpath= g_strdup_printf ("%s%c%s", tmpdir,
|
||||
G_DIR_SEPARATOR, "xapian");
|
||||
g_free (tmpdir);
|
||||
|
||||
return xpath;
|
||||
}
|
||||
|
||||
/* note: this also *moves the iter* */
|
||||
static MuMsgIter*
|
||||
run_and_get_iter (const char *xpath, const char *query)
|
||||
{
|
||||
MuQuery *mquery;
|
||||
MuStore *store;
|
||||
MuMsgIter *iter;
|
||||
|
||||
store = mu_store_new_read_only (xpath, NULL);
|
||||
g_assert (store);
|
||||
|
||||
mquery = mu_query_new (store, NULL);
|
||||
mu_store_unref (store);
|
||||
g_assert (query);
|
||||
|
||||
iter = mu_query_run (mquery, query, TRUE, MU_MSG_FIELD_ID_DATE,
|
||||
FALSE, -1, NULL);
|
||||
mu_query_destroy (mquery);
|
||||
g_assert (iter);
|
||||
|
||||
return iter;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_mu_threads_01 (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
MuMsgIter *iter;
|
||||
unsigned u;
|
||||
|
||||
struct {
|
||||
const char* threadpath;
|
||||
const char *msgid;
|
||||
const char* subject;
|
||||
} items [] = {
|
||||
{"0", "root0@msg.id", "root0"},
|
||||
{"0:0", "child0.0@msg.id", "Re: child 0.0"},
|
||||
{"0:1", "child0.1@msg.id", "Re: child 0.1"},
|
||||
{"0:1:0", "child0.1.0@msg.id", "Re: child 0.1.0"},
|
||||
{"1", "root1@msg.id", "root1"},
|
||||
{"2", "root2@msg.id", "root2"},
|
||||
/* next one's been promoted 2.0.0 => 2.0 */
|
||||
{"2:0", "child2.0.0@msg.id", "Re: child 2.0.0"},
|
||||
/* next one's been promoted 3.0.0.0.0 => 3 */
|
||||
{"3", "child3.0.0.0.0@msg.id", "Re: child 3.0.0.0"},
|
||||
|
||||
/* two children of absent root 4.0 */
|
||||
{"4:0", "child4.0@msg.id", "Re: child 4.0"},
|
||||
{"4:1", "child4.1@msg.id", "Re: child 4.1"}
|
||||
};
|
||||
|
||||
xpath = fill_database (MU_TESTMAILDIR3);
|
||||
g_assert (xpath != NULL);
|
||||
|
||||
iter = run_and_get_iter (xpath, "abc");
|
||||
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 for %u\n",
|
||||
__FUNCTION__, (unsigned)mu_msg_iter_get_docid(iter));
|
||||
g_assert(ti);
|
||||
|
||||
msg = mu_msg_iter_get_msg_floating (iter);
|
||||
g_assert (msg);
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
||||
struct _tinfo {
|
||||
const char* threadpath;
|
||||
const char *msgid;
|
||||
const char* subject;
|
||||
};
|
||||
typedef struct _tinfo tinfo;
|
||||
|
||||
static void
|
||||
test_mu_threads_rogue (void)
|
||||
{
|
||||
gchar *xpath;
|
||||
MuMsgIter *iter;
|
||||
unsigned u;
|
||||
tinfo *items;
|
||||
|
||||
tinfo items1 [] = {
|
||||
{"0", "cycle0@msg.id", "cycle0"},
|
||||
{"0:0", "cycle0.0@msg.id", "cycle0.0"},
|
||||
{"0:0:0", "cycle0.0.0@msg.id", "cycle0.0.0"},
|
||||
{"0:1", "rogue0@msg.id", "rogue0"},
|
||||
};
|
||||
|
||||
tinfo items2 [] = {
|
||||
{"0", "cycle0.0@msg.id", "cycle0.0"},
|
||||
{"0:0", "cycle0@msg.id", "cycle0"},
|
||||
{"0:0:0", "rogue0@msg.id", "rogue0" },
|
||||
{"0:1", "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));
|
||||
|
||||
/* due to the random order in files can be indexed, there are two possible ways
|
||||
* for the threads to be built-up; both are okay */
|
||||
if (g_strcmp0 (mu_msg_get_msgid(mu_msg_iter_get_msg_floating (iter)),
|
||||
"cycle0@msg.id") == 0)
|
||||
items = items1;
|
||||
else
|
||||
items = items2;
|
||||
|
||||
u = 0;
|
||||
while (!mu_msg_iter_is_done (iter) && u < G_N_ELEMENTS(items1)) {
|
||||
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_floating (iter)));
|
||||
g_assert(ti);
|
||||
|
||||
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
|
||||
/* g_print ("%s %s %s\n", ti->threadpath, */
|
||||
/* mu_msg_get_msgid(msg), */
|
||||
/* mu_msg_get_path (msg) */
|
||||
/* ); */
|
||||
|
||||
g_assert (u < G_N_ELEMENTS(items1));
|
||||
|
||||
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(items1));
|
||||
|
||||
g_free (xpath);
|
||||
mu_msg_iter_destroy (iter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int rv;
|
||||
|
||||
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,
|
||||
(GLogFunc)black_hole, NULL);
|
||||
|
||||
rv = g_test_run ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
Reference in New Issue
Block a user