* tests: add unit-tests for 'mu cfind'

This commit is contained in:
Dirk-Jan C. Binnema 2011-05-19 19:55:50 +03:00
parent 53a2a5c3ab
commit 51fb5fe8e9
3 changed files with 290 additions and 274 deletions

View File

@ -64,6 +64,11 @@ TEST_PROGS += test-mu-cmd
test_mu_cmd_SOURCES= test-mu-cmd.c dummy.cc test_mu_cmd_SOURCES= test-mu-cmd.c dummy.cc
test_mu_cmd_LDADD= libtestmucommon.la test_mu_cmd_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-cmd-cfind
test_mu_cmd_cfind_SOURCES= test-mu-cmd-cfind.c dummy.cc
test_mu_cmd_cfind_LDADD= libtestmucommon.la
TEST_PROGS += test-mu-msg TEST_PROGS += test-mu-msg
test_mu_msg_SOURCES= test-mu-msg.c dummy.cc test_mu_msg_SOURCES= test-mu-msg.c dummy.cc
test_mu_msg_LDADD= libtestmucommon.la test_mu_msg_LDADD= libtestmucommon.la

View File

@ -1,4 +1,5 @@
/* /* -*- mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
**
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
@ -39,34 +40,35 @@
static gchar* static gchar*
fill_database (void) fill_database (void)
{ {
gchar *cmdline, *tmpdir; gchar *cmdline, *tmpdir;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s" cmdline = g_strdup_printf ("%s index --muhome=%s --maildir=%s"
" --quiet", " --quiet",
MU_PROGRAM, tmpdir, MU_TESTMAILDIR2); MU_PROGRAM,
tmpdir, MU_TESTMAILDIR2);
g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL, g_assert (g_spawn_command_line_sync (cmdline, NULL, NULL,
NULL, NULL)); NULL, NULL));
g_free (cmdline); g_free (cmdline);
return tmpdir; return tmpdir;
} }
static unsigned static unsigned
newlines_in_output (const char* str) newlines_in_output (const char* str)
{ {
int count; int count;
count = 0; count = 0;
while (str && *str) { while (str && *str) {
if (*str == '\n') if (*str == '\n')
++count; ++count;
++str; ++str;
} }
return count; return count;
} }
static void static void
@ -74,50 +76,50 @@ search (const char* query, unsigned expected)
{ {
gchar *muhome, *cmdline, *output, *erroutput; gchar *muhome, *cmdline, *output, *erroutput;
muhome = fill_database (); muhome = fill_database ();
g_assert (muhome); g_assert (muhome);
cmdline = g_strdup_printf ("%s find --muhome=%s %s", cmdline = g_strdup_printf ("%s find --muhome=%s %s",
MU_PROGRAM, muhome, query); MU_PROGRAM, muhome, query);
/* g_printerr ("%s\n", cmdline); */ /* g_printerr ("%s\n", cmdline); */
g_assert (g_spawn_command_line_sync (cmdline, g_assert (g_spawn_command_line_sync (cmdline,
&output, &erroutput, &output, &erroutput,
NULL, NULL)); NULL, NULL));
g_assert_cmpuint (newlines_in_output(output),==,expected); g_assert_cmpuint (newlines_in_output(output),==,expected);
/* we expect zero lines of error output if there is a match; /* we expect zero lines of error output if there is a match;
* otherwise there should be one line 'No matches found' */ * otherwise there should be one line 'No matches found' */
/* g_assert_cmpuint (newlines_in_output(erroutput),==, */ /* g_assert_cmpuint (newlines_in_output(erroutput),==, */
/* expected == 0 ? 1 : 0); */ /* expected == 0 ? 1 : 0); */
g_free (output); g_free (output);
g_free (erroutput); g_free (erroutput);
g_free (cmdline); g_free (cmdline);
g_free (muhome); g_free (muhome);
} }
/* index testdir2, and make sure it adds two documents */ /* index testdir2, and make sure it adds two documents */
static void static void
test_mu_index (void) test_mu_index (void)
{ {
MuStore *store; MuStore *store;
gchar *muhome, *xpath; gchar *muhome, *xpath;
muhome = fill_database (); muhome = fill_database ();
g_assert (muhome != NULL); g_assert (muhome != NULL);
xpath = g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR, "xapian"); xpath = g_strdup_printf ("%s%c%s", muhome, G_DIR_SEPARATOR, "xapian");
store = mu_store_new (xpath, NULL, NULL); store = mu_store_new (xpath, NULL, NULL);
g_assert (store); g_assert (store);
g_assert_cmpuint (mu_store_count (store), ==, 5); g_assert_cmpuint (mu_store_count (store), ==, 5);
mu_store_destroy (store); mu_store_destroy (store);
g_free (muhome); g_free (muhome);
g_free (xpath); g_free (xpath);
} }
@ -125,15 +127,15 @@ test_mu_index (void)
static void static void
test_mu_find_01 (void) test_mu_find_01 (void)
{ {
search ("f:john fruit", 1); search ("f:john fruit", 1);
search ("f:soc@example.com", 1); search ("f:soc@example.com", 1);
search ("t:alki@example.com", 1); search ("t:alki@example.com", 1);
search ("t:alcibiades", 1); search ("t:alcibiades", 1);
search ("f:soc@example.com OR f:john", 2); search ("f:soc@example.com OR f:john", 2);
search ("f:soc@example.com OR f:john OR t:edmond", 3); search ("f:soc@example.com OR f:john OR t:edmond", 3);
search ("t:julius", 1); search ("t:julius", 1);
search ("s:dude", 1); search ("s:dude", 1);
search ("t:dantès", 1); search ("t:dantès", 1);
} }
@ -141,14 +143,14 @@ test_mu_find_01 (void)
static void static void
test_mu_find_02 (void) test_mu_find_02 (void)
{ {
search ("bull", 1); search ("bull", 1);
search ("bull m:foo", 0); search ("bull m:foo", 0);
search ("bull m:/foo", 1); search ("bull m:/foo", 1);
search ("bull m:/Foo", 1); search ("bull m:/Foo", 1);
search ("bull flag:a", 1); search ("bull flag:a", 1);
search ("g:x", 0); search ("g:x", 0);
search ("flag:encrypted", 0); search ("flag:encrypted", 0);
search ("flag:attach", 1); search ("flag:attach", 1);
} }
@ -156,10 +158,10 @@ test_mu_find_02 (void)
static void static void
test_mu_find_03 (void) test_mu_find_03 (void)
{ {
search ("bull", 1); search ("bull", 1);
search ("bull m:foo", 0); search ("bull m:foo", 0);
search ("bull m:/foo", 1); search ("bull m:/foo", 1);
search ("i:3BE9E6535E0D852173@emss35m06.us.lmco.com", 1); search ("i:3BE9E6535E0D852173@emss35m06.us.lmco.com", 1);
} }
@ -168,24 +170,25 @@ test_mu_find_04 (void)
{ {
gchar *muhome, *cmdline, *erroutput; gchar *muhome, *cmdline, *erroutput;
muhome = fill_database (); muhome = fill_database ();
g_assert (muhome); g_assert (muhome);
cmdline = g_strdup_printf ("%s --muhome=%cfoo%cbar%cnonexistent find f:socrates", cmdline = g_strdup_printf ("%s --muhome=%cfoo%cbar%cnonexistent "
MU_PROGRAM, "find f:socrates",
G_DIR_SEPARATOR, MU_PROGRAM,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR,
G_DIR_SEPARATOR);
g_assert (g_spawn_command_line_sync (cmdline, NULL, &erroutput, g_assert (g_spawn_command_line_sync (cmdline, NULL, &erroutput,
NULL, NULL)); NULL, NULL));
/* we expect multiple lines of error output */ /* we expect multiple lines of error output */
g_assert_cmpuint (newlines_in_output(erroutput),>=,1); g_assert_cmpuint (newlines_in_output(erroutput),>=,1);
g_free (erroutput); g_free (erroutput);
g_free (cmdline); g_free (cmdline);
g_free (muhome); g_free (muhome);
} }
@ -194,49 +197,50 @@ test_mu_extract_01 (void)
{ {
gchar *cmdline, *output, *erroutput, *tmpdir; gchar *cmdline, *output, *erroutput, *tmpdir;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
cmdline = g_strdup_printf ("%s extract --muhome=%s %s%cFoo%ccur%cmail5", cmdline = g_strdup_printf ("%s extract --muhome=%s %s%cFoo%ccur%cmail5",
MU_PROGRAM, MU_PROGRAM,
tmpdir, tmpdir,
MU_TESTMAILDIR2, MU_TESTMAILDIR2,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
/* g_print ("[%s]", cmdline); */ /* g_print ("[%s]", cmdline); */
output = erroutput = NULL; output = erroutput = NULL;
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput, NULL, NULL)); g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
g_assert_cmpstr (output, NULL, NULL));
==, g_assert_cmpstr (output,
"MIME-parts in this message:\n" ==,
" 0 <none> multipart/mixed [<none>]\n" "MIME-parts in this message:\n"
" 1 <none> text/plain [<none>]\n" " 0 <none> multipart/mixed [<none>]\n"
" 2 sittingbull.jpg image/jpeg [inline]\n" " 1 <none> text/plain [<none>]\n"
" 3 custer.jpg image/jpeg [inline]\n"); " 2 sittingbull.jpg image/jpeg [inline]\n"
" 3 custer.jpg image/jpeg [inline]\n");
/* we expect zero lines of error output */ /* we expect zero lines of error output */
g_assert_cmpuint (newlines_in_output(erroutput),==,0); g_assert_cmpuint (newlines_in_output(erroutput),==,0);
g_free (output); g_free (output);
g_free (erroutput); g_free (erroutput);
g_free (cmdline); g_free (cmdline);
g_free (tmpdir); g_free (tmpdir);
} }
static gint64 static gint64
get_file_size (const char* path) get_file_size (const char* path)
{ {
int rv; int rv;
struct stat statbuf; struct stat statbuf;
rv = stat (path, &statbuf); rv = stat (path, &statbuf);
if (rv != 0) if (rv != 0)
return -1; return -1;
return (gint64)statbuf.st_size; return (gint64)statbuf.st_size;
} }
@ -244,36 +248,37 @@ static void
test_mu_extract_02 (void) test_mu_extract_02 (void)
{ {
gchar *cmdline, *output, *tmpdir; gchar *cmdline, *output, *tmpdir;
gchar *att1, *att2; gchar *att1, *att2;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); 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", cmdline = g_strdup_printf ("%s extract --muhome=%s -a "
MU_PROGRAM, "--target-dir=%s %s%cFoo%ccur%cmail5",
tmpdir, MU_PROGRAM,
tmpdir, tmpdir,
MU_TESTMAILDIR2, tmpdir,
G_DIR_SEPARATOR, MU_TESTMAILDIR2,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR,
G_DIR_SEPARATOR);
output = NULL; output = NULL;
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL)); g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL));
g_assert_cmpstr (output, ==, ""); g_assert_cmpstr (output, ==, "");
att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR); att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR);
att2 = g_strdup_printf ("%s%csittingbull.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(att1),==,15960);
g_assert_cmpint (get_file_size(att2),==,17674); g_assert_cmpint (get_file_size(att2),==,17674);
g_free (output); g_free (output);
g_free (tmpdir); g_free (tmpdir);
g_free (cmdline); g_free (cmdline);
g_free (att1); g_free (att1);
g_free (att2); g_free (att2);
} }
@ -281,36 +286,36 @@ static void
test_mu_extract_03 (void) test_mu_extract_03 (void)
{ {
gchar *cmdline, *output, *tmpdir; gchar *cmdline, *output, *tmpdir;
gchar *att1, *att2; gchar *att1, *att2;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
cmdline = g_strdup_printf ("%s extract --muhome=%s --parts 3 " cmdline = g_strdup_printf ("%s extract --muhome=%s --parts 3 "
"--target-dir=%s %s%cFoo%ccur%cmail5", "--target-dir=%s %s%cFoo%ccur%cmail5",
MU_PROGRAM, MU_PROGRAM,
tmpdir, tmpdir,
tmpdir, tmpdir,
MU_TESTMAILDIR2, MU_TESTMAILDIR2,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
output = NULL; output = NULL;
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL)); g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL));
g_assert_cmpstr (output, ==, ""); g_assert_cmpstr (output, ==, "");
att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR); att1 = g_strdup_printf ("%s%ccuster.jpg", tmpdir, G_DIR_SEPARATOR);
att2 = g_strdup_printf ("%s%csittingbull.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(att1),==,15960); /* should not exist */
g_assert_cmpint (get_file_size(att2),==,-1); g_assert_cmpint (get_file_size(att2),==,-1);
g_free (output); g_free (output);
g_free (tmpdir); g_free (tmpdir);
g_free (cmdline); g_free (cmdline);
g_free (att1); g_free (att1);
g_free (att2); g_free (att2);
} }
@ -319,42 +324,48 @@ test_mu_extract_04 (void)
{ {
gchar *cmdline, *output, *erroutput, *tmpdir; gchar *cmdline, *output, *erroutput, *tmpdir;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); 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", cmdline = g_strdup_printf ("%s extract --muhome=%s -a "
MU_PROGRAM, tmpdir, tmpdir, "--target-dir=%s %s%cFoo%ccur%cmail5",
MU_TESTMAILDIR2, G_DIR_SEPARATOR, MU_PROGRAM, tmpdir, tmpdir,
G_DIR_SEPARATOR, G_DIR_SEPARATOR); 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 (g_spawn_command_line_sync (cmdline, &output, &erroutput,
g_assert_cmpstr (output, ==, ""); NULL, NULL));
g_assert_cmpstr (erroutput, ==, ""); g_assert_cmpstr (output, ==, "");
g_free (erroutput); g_assert_cmpstr (erroutput, ==, "");
g_free (output); g_free (erroutput);
g_free (output);
/* now, it should fail, because we don't allow overwrites without --overwrite */ /* now, it should fail, because we don't allow overwrites
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput, NULL, NULL)); * without --overwrite */
g_assert_cmpstr (output, ==, ""); g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
g_assert_cmpstr (erroutput, !=, ""); NULL, NULL));
g_free (erroutput); g_assert_cmpstr (output, ==, "");
g_free (output); g_assert_cmpstr (erroutput, !=, "");
g_free (erroutput);
g_free (output);
g_free (cmdline); g_free (cmdline);
/* this should work now, because we have specified --overwrite */ /* this should work now, because we have specified --overwrite */
cmdline = g_strdup_printf ("%s extract --muhome=%s -a --overwrite " cmdline = g_strdup_printf ("%s extract --muhome=%s -a --overwrite "
"--target-dir=%s %s%cFoo%ccur%cmail5", "--target-dir=%s %s%cFoo%ccur%cmail5",
MU_PROGRAM, tmpdir, tmpdir, MU_TESTMAILDIR2, G_DIR_SEPARATOR, MU_PROGRAM, tmpdir, tmpdir,
G_DIR_SEPARATOR, G_DIR_SEPARATOR); MU_TESTMAILDIR2, G_DIR_SEPARATOR,
g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput, NULL, NULL)); G_DIR_SEPARATOR, G_DIR_SEPARATOR);
g_assert_cmpstr (output, ==, ""); g_assert (g_spawn_command_line_sync (cmdline, &output, &erroutput,
g_assert_cmpstr (erroutput, ==, ""); NULL, NULL));
g_free (erroutput); g_assert_cmpstr (output, ==, "");
g_free (output); g_assert_cmpstr (erroutput, ==, "");
g_free (erroutput);
g_free (output);
g_free (tmpdir); g_free (tmpdir);
g_free (cmdline); g_free (cmdline);
} }
@ -363,49 +374,49 @@ static void
test_mu_view_01 (void) test_mu_view_01 (void)
{ {
gchar *cmdline, *output, *tmpdir; gchar *cmdline, *output, *tmpdir;
int len; int len;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
cmdline = g_strdup_printf ("%s view --muhome=%s %s%cbar%ccur%cmail4", cmdline = g_strdup_printf ("%s view --muhome=%s %s%cbar%ccur%cmail4",
MU_PROGRAM, MU_PROGRAM,
tmpdir, tmpdir,
MU_TESTMAILDIR2, MU_TESTMAILDIR2,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
output = NULL; output = NULL;
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL)); g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL));
g_assert_cmpstr (output, !=, NULL); g_assert_cmpstr (output, !=, NULL);
/* /*
* note: there are two possibilities here; older versions of * note: there are two possibilities here; older versions of
* GMime will produce: * GMime will produce:
* *
* From: "=?iso-8859-1?Q? =F6tzi ?=" <oetzi@web.de> * From: "=?iso-8859-1?Q? =F6tzi ?=" <oetzi@web.de>
* *
* while newer ones return something like: * while newer ones return something like:
* *
* From: ?tzi <oetzi@web.de> * From: ?tzi <oetzi@web.de>
* *
* or even * or even
* *
* From: \xc3\xb6tzi <oetzi@web.de> * From: \xc3\xb6tzi <oetzi@web.de>
* *
* both are 'okay' from mu's perspective; it'd be even better * both are 'okay' from mu's perspective; it'd be even better
* to have some #ifdefs for the GMime versions, but this * to have some #ifdefs for the GMime versions, but this
* should work for now * should work for now
* *
* Added 350 as 'okay', which comes with gmime 2.4.24 (ubuntu 10.04) * Added 350 as 'okay', which comes with gmime 2.4.24 (ubuntu 10.04)
*/ */
len = strlen(output); len = strlen(output);
/* g_print ("\n[%s] (%d)\n", output, len); */ /* g_print ("\n[%s] (%d)\n", output, len); */
g_assert (len == 370 || len == 358 || len == 350 || len == 349); g_assert (len == 370 || len == 358 || len == 350 || len == 349);
g_free (output); g_free (output);
g_free (cmdline); g_free (cmdline);
g_free (tmpdir); g_free (tmpdir);
} }
@ -415,38 +426,38 @@ static void
test_mu_mkdir_01 (void) test_mu_mkdir_01 (void)
{ {
gchar *cmdline, *output, *tmpdir; gchar *cmdline, *output, *tmpdir;
gchar *dir; gchar *dir;
tmpdir = test_mu_common_get_random_tmpdir(); tmpdir = test_mu_common_get_random_tmpdir();
g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0);
cmdline = g_strdup_printf ("%s mkdir --muhome=%s %s%ctest1 %s%ctest2", cmdline = g_strdup_printf ("%s mkdir --muhome=%s %s%ctest1 %s%ctest2",
MU_PROGRAM,tmpdir, MU_PROGRAM,tmpdir,
tmpdir, G_DIR_SEPARATOR, tmpdir, G_DIR_SEPARATOR,
tmpdir, G_DIR_SEPARATOR); tmpdir, G_DIR_SEPARATOR);
output = NULL; output = NULL;
g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL)); g_assert (g_spawn_command_line_sync (cmdline, &output, NULL, NULL, NULL));
g_assert_cmpstr (output, ==, ""); g_assert_cmpstr (output, ==, "");
dir = g_strdup_printf ("%s%ctest1%ccur", tmpdir, G_DIR_SEPARATOR, dir = g_strdup_printf ("%s%ctest1%ccur", tmpdir, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
g_assert (access (dir, F_OK) == 0); g_assert (access (dir, F_OK) == 0);
g_free (dir); g_free (dir);
dir = g_strdup_printf ("%s%ctest2%ctmp", tmpdir, G_DIR_SEPARATOR, dir = g_strdup_printf ("%s%ctest2%ctmp", tmpdir, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
g_assert (access (dir, F_OK) == 0); g_assert (access (dir, F_OK) == 0);
g_free (dir); g_free (dir);
dir = g_strdup_printf ("%s%ctest1%cnew", tmpdir, G_DIR_SEPARATOR, dir = g_strdup_printf ("%s%ctest1%cnew", tmpdir, G_DIR_SEPARATOR,
G_DIR_SEPARATOR); G_DIR_SEPARATOR);
g_assert (access (dir, F_OK) == 0); g_assert (access (dir, F_OK) == 0);
g_free (dir); g_free (dir);
g_free (output); g_free (output);
g_free (tmpdir); g_free (tmpdir);
g_free (cmdline); g_free (cmdline);
} }
@ -454,28 +465,28 @@ test_mu_mkdir_01 (void)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
int rv; int rv;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mu-cmd/test-mu-index", test_mu_index); g_test_add_func ("/mu-cmd/test-mu-index", test_mu_index);
g_test_add_func ("/mu-cmd/test-mu-find-01", test_mu_find_01); 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-02", test_mu_find_02);
g_test_add_func ("/mu-cmd/test-mu-find-03", test_mu_find_03); 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-04", test_mu_find_04);
g_test_add_func ("/mu-cmd/test-mu-extract-01", test_mu_extract_01); 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-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-03", test_mu_extract_03);
g_test_add_func ("/mu-cmd/test-mu-extract-04", test_mu_extract_04); g_test_add_func ("/mu-cmd/test-mu-extract-04", test_mu_extract_04);
g_test_add_func ("/mu-cmd/test-mu-view-01", test_mu_view_01); g_test_add_func ("/mu-cmd/test-mu-view-01", test_mu_view_01);
g_test_add_func ("/mu-cmd/test-mu-mkdir-01", test_mu_mkdir_01); g_test_add_func ("/mu-cmd/test-mu-mkdir-01", test_mu_mkdir_01);
g_log_set_handler (NULL, g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_LEVEL_WARNING| G_LOG_LEVEL_MASK | G_LOG_LEVEL_WARNING|
G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,
(GLogFunc)black_hole, NULL); (GLogFunc)black_hole, NULL);
rv = g_test_run (); rv = g_test_run ();
return rv; return rv;
} }

View File

@ -171,7 +171,7 @@ main (int argc, char *argv[])
int rv; int rv;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
g_test_add_func ("/mu-contact/test-mu-contacts-01", test_mu_contacts_01); g_test_add_func ("/mu-contacts/test-mu-contacts-01", test_mu_contacts_01);
g_log_set_handler (NULL, g_log_set_handler (NULL,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION,