mirror of https://github.com/djcb/mu.git
store/index: and unit test for circular symlink
Check that we bail out early
This commit is contained in:
parent
885903c496
commit
6ad5cccc53
|
@ -783,8 +783,6 @@ main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
mu_test_init(&argc, &argv);
|
mu_test_init(&argc, &argv);
|
||||||
|
|
||||||
g_test_bug_base("https://github.com/djcb/mu/issues/");
|
|
||||||
|
|
||||||
g_test_add_func("/store/query/simple", test_simple);
|
g_test_add_func("/store/query/simple", test_simple);
|
||||||
g_test_add_func("/store/query/spam-address-components",
|
g_test_add_func("/store/query/spam-address-components",
|
||||||
test_spam_address_components);
|
test_spam_address_components);
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
static std::string MuTestMaildir = Mu::canonicalize_filename(MU_TESTMAILDIR, "/");
|
static std::string MuTestMaildir = Mu::canonicalize_filename(MU_TESTMAILDIR, "/");
|
||||||
static std::string MuTestMaildir2 = Mu::canonicalize_filename(MU_TESTMAILDIR2, "/");
|
static std::string MuTestMaildir2 = Mu::canonicalize_filename(MU_TESTMAILDIR2, "/");
|
||||||
|
|
||||||
|
@ -305,8 +307,6 @@ World!
|
||||||
static void
|
static void
|
||||||
test_index_move()
|
test_index_move()
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
|
||||||
|
|
||||||
const std::string msg_text =
|
const std::string msg_text =
|
||||||
R"(From: Valentine Michael Smith <mike@example.com>
|
R"(From: Valentine Michael Smith <mike@example.com>
|
||||||
To: Raul Endymion <raul@example.com>
|
To: Raul Endymion <raul@example.com>
|
||||||
|
@ -466,6 +466,37 @@ Yes, that would be excellent.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_store_circular_symlink(void)
|
||||||
|
{
|
||||||
|
allow_warnings();
|
||||||
|
|
||||||
|
g_test_bug("2517");
|
||||||
|
|
||||||
|
auto testhome{unwrap(make_temp_dir())};
|
||||||
|
auto dbpath{runtime_path(RuntimePath::XapianDb, testhome)};
|
||||||
|
|
||||||
|
/* create a writable copy */
|
||||||
|
const auto testmdir = join_paths(testhome, "test-maildir");
|
||||||
|
auto cres1 = run_command({CP_PROGRAM, "-r", MU_TESTMAILDIR, testmdir});
|
||||||
|
assert_valid_command(cres1);
|
||||||
|
// create a symink
|
||||||
|
auto cres2 = run_command({LN_PROGRAM, "-s", testmdir, join_paths(testmdir, "testlink")});
|
||||||
|
assert_valid_command(cres2);
|
||||||
|
|
||||||
|
auto&& store = unwrap(Store::make_new(dbpath, testmdir));
|
||||||
|
store.indexer().start({});
|
||||||
|
size_t n{};
|
||||||
|
while (store.indexer().is_running()) {
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
g_assert_cmpuint(n++,<=,25);
|
||||||
|
}
|
||||||
|
// there will be a lot of dups....
|
||||||
|
g_assert_false(store.empty());
|
||||||
|
|
||||||
|
remove_directory(testhome);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_store_fail()
|
test_store_fail()
|
||||||
|
@ -496,6 +527,7 @@ main(int argc, char* argv[])
|
||||||
test_message_attachments);
|
test_message_attachments);
|
||||||
g_test_add_func("/store/index/index-move", test_index_move);
|
g_test_add_func("/store/index/index-move", test_index_move);
|
||||||
g_test_add_func("/store/index/move-dups", test_store_move_dups);
|
g_test_add_func("/store/index/move-dups", test_store_move_dups);
|
||||||
|
g_test_add_func("/store/index/circular-symlink", test_store_circular_symlink);
|
||||||
g_test_add_func("/store/index/fail", test_store_fail);
|
g_test_add_func("/store/index/fail", test_store_fail);
|
||||||
|
|
||||||
return g_test_run();
|
return g_test_run();
|
||||||
|
|
|
@ -99,6 +99,8 @@ Mu::mu_test_init(int *argc, char ***argv)
|
||||||
|
|
||||||
g_test_init(argc, argv, NULL);
|
g_test_init(argc, argv, NULL);
|
||||||
|
|
||||||
|
g_test_bug_base("https://github.com/djcb/mu/issues/");
|
||||||
|
|
||||||
if (!g_test_verbose())
|
if (!g_test_verbose())
|
||||||
g_log_set_handler(
|
g_log_set_handler(
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
@ -144,8 +144,11 @@ endif
|
||||||
|
|
||||||
dependency('cld2', required : false)
|
dependency('cld2', required : false)
|
||||||
|
|
||||||
|
# note: these are for the unit-tests
|
||||||
|
|
||||||
cp=find_program('cp')
|
cp=find_program('cp')
|
||||||
mv=find_program('mv')
|
mv=find_program('mv')
|
||||||
|
ln=find_program('ln')
|
||||||
rm=find_program('rm')
|
rm=find_program('rm')
|
||||||
awk=find_program(['gawk', 'awk'])
|
awk=find_program(['gawk', 'awk'])
|
||||||
gzip=find_program('gzip')
|
gzip=find_program('gzip')
|
||||||
|
@ -153,6 +156,7 @@ gzip=find_program('gzip')
|
||||||
config_h_data.set_quoted('CP_PROGRAM', cp.full_path())
|
config_h_data.set_quoted('CP_PROGRAM', cp.full_path())
|
||||||
config_h_data.set_quoted('MV_PROGRAM', mv.full_path())
|
config_h_data.set_quoted('MV_PROGRAM', mv.full_path())
|
||||||
config_h_data.set_quoted('RM_PROGRAM', rm.full_path())
|
config_h_data.set_quoted('RM_PROGRAM', rm.full_path())
|
||||||
|
config_h_data.set_quoted('LN_PROGRAM', ln.full_path())
|
||||||
config_h_data.set_quoted('AWK_PROGRAM', awk.full_path())
|
config_h_data.set_quoted('AWK_PROGRAM', awk.full_path())
|
||||||
config_h_data.set_quoted('GZIP_PROGRAM', gzip.full_path())
|
config_h_data.set_quoted('GZIP_PROGRAM', gzip.full_path())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue