remove some dead code

This commit is contained in:
Dirk-Jan C. Binnema
2021-01-20 11:18:33 +02:00
parent 362c53a7e7
commit 98744c66f7
14 changed files with 49 additions and 1092 deletions

View File

@ -191,207 +191,6 @@ test_mu_maildir_mkdir_05 (void)
==, FALSE);
}
static gchar*
copy_test_data (void)
{
gchar *dir, *cmd;
dir = test_mu_common_get_random_tmpdir();
cmd = g_strdup_printf ("mkdir -p -m 0700 %s", dir);
if (g_test_verbose())
g_debug ("cmd: %s\n", cmd);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
cmd = g_strdup_printf ("cp -R %s %s", MU_TESTMAILDIR, dir);
if (g_test_verbose())
g_debug ("cmd: %s\n", cmd);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
return dir;
}
typedef struct {
int _file_count;
int _dir_entered;
int _dir_left;
} WalkData;
static MuError
dir_cb (const char *fullpath, gboolean enter, WalkData *data)
{
if (enter)
++data->_dir_entered;
else
++data->_dir_left;
if (g_test_verbose())
g_debug ("%s: %s: %s (%u)\n", __func__, enter ? "entering" : "leaving",
fullpath, enter ? data->_dir_entered : data->_dir_left);
return MU_OK;
}
static MuError
msg_cb (const char *fullpath, const char* mdir, struct stat *statinfo,
WalkData *data)
{
++data->_file_count;
return MU_OK;
}
static void
test_mu_maildir_walk_01 (void)
{
char *tmpdir;
WalkData data;
MuError rv;
tmpdir = copy_test_data ();
memset (&data, 0, sizeof(WalkData));
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
TRUE,
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 19);
g_assert_cmpuint (data._dir_entered,==, 5);
g_assert_cmpuint (data._dir_left,==, 5);
g_free (tmpdir);
}
static void
test_mu_maildir_walk (void)
{
char *tmpdir, *cmd, *dir;
WalkData data;
MuError rv;
tmpdir = copy_test_data ();
memset (&data, 0, sizeof(WalkData));
/* mark the 'new' dir with '.noindex', to ignore it */
dir = g_strdup_printf ("%s%ctestdir%cnew", tmpdir,
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
cmd = g_strdup_printf ("chmod 700 %s", dir);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
cmd = g_strdup_printf ("touch %s%c.noindex", dir, G_DIR_SEPARATOR);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
g_free (dir);
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
TRUE,
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 15);
g_assert_cmpuint (data._dir_entered,==, 4);
g_assert_cmpuint (data._dir_left,==, 4);
g_free (tmpdir);
}
static void
test_mu_maildir_walk_with_noupdate (void)
{
char *tmpdir, *cmd, *dir;
WalkData data;
MuError rv;
tmpdir = copy_test_data ();
/* mark the 'new' dir with '.noindex', to ignore it */
dir = g_strdup_printf ("%s%ctestdir%cnew", tmpdir,
G_DIR_SEPARATOR, G_DIR_SEPARATOR);
cmd = g_strdup_printf ("chmod 700 %s", dir);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
memset (&data, 0, sizeof(WalkData));
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
FALSE, /* ie., non-full update */
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 19);
g_assert_cmpuint (data._dir_entered,==, 5);
g_assert_cmpuint (data._dir_left,==, 5);
/* again, full update. results should be the same, since there
* is no noupdate yet */
memset (&data, 0, sizeof(WalkData));
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
TRUE, /* ie., full update */
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 19);
g_assert_cmpuint (data._dir_entered,==, 5);
g_assert_cmpuint (data._dir_left,==, 5);
/* add a '.noupdate' file; this affects the outcome when the
* 4th arg to mu_maildir_walk is FALSE */
cmd = g_strdup_printf ("touch %s%c.noupdate", dir, G_DIR_SEPARATOR);
g_assert (g_spawn_command_line_sync (cmd, NULL, NULL, NULL, NULL));
g_free (cmd);
memset (&data, 0, sizeof(WalkData));
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
FALSE, /* non-full update */
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 15);
g_assert_cmpuint (data._dir_entered,==, 4);
g_assert_cmpuint (data._dir_left,==, 4);
/* now run again, but do a full update */
memset (&data, 0, sizeof(WalkData));
rv = mu_maildir_walk (tmpdir,
(MuMaildirWalkMsgCallback)msg_cb,
(MuMaildirWalkDirCallback)dir_cb,
TRUE, /* full update */
&data);
g_assert_cmpuint (MU_OK, ==, rv);
g_assert_cmpuint (data._file_count, ==, 19);
g_assert_cmpuint (data._dir_entered,==, 5);
g_assert_cmpuint (data._dir_left,==, 5);
g_free (dir);
g_free (tmpdir);
}
static void
test_mu_maildir_get_flags_from_path (void)
{
@ -661,15 +460,6 @@ main (int argc, char *argv[])
g_test_add_func ("/mu-maildir/mu-maildir-mkdir-05",
test_mu_maildir_mkdir_05);
/* mu_util_maildir_walk */
g_test_add_func ("/mu-maildir/mu-maildir-walk-01",
test_mu_maildir_walk_01);
g_test_add_func ("/mu-maildir/mu-maildir-walk",
test_mu_maildir_walk);
g_test_add_func ("/mu-maildir/mu-maildir-walk-with-noupdate",
test_mu_maildir_walk_with_noupdate);
/* get/set flags */
g_test_add_func("/mu-maildir/mu-maildir-get-new-path-new",
test_mu_maildir_get_new_path_new);