Changeset View
Changeset View
Standalone View
Standalone View
src/test/util_tests.cpp
Show First 20 Lines • Show All 1,318 Lines • ▼ Show 20 Lines | while (true) { | ||||
default: | default: | ||||
assert(0); | assert(0); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
BOOST_AUTO_TEST_CASE(test_LockDirectory) { | BOOST_AUTO_TEST_CASE(test_LockDirectory) { | ||||
fs::path dirname = SetDataDir("test_LockDirectory") / fs::unique_path(); | fs::path dirname = GetDataDir() / "lock_dir"; | ||||
const std::string lockname = ".lock"; | const std::string lockname = ".lock"; | ||||
#ifndef WIN32 | #ifndef WIN32 | ||||
// Revert SIGCHLD to default, otherwise boost.test will catch and fail on | // Revert SIGCHLD to default, otherwise boost.test will catch and fail on | ||||
// it: there is BOOST_TEST_IGNORE_SIGCHLD but that only works when defined | // it: there is BOOST_TEST_IGNORE_SIGCHLD but that only works when defined | ||||
// at build-time of the boost library | // at build-time of the boost library | ||||
void (*old_handler)(int) = signal(SIGCHLD, SIG_DFL); | void (*old_handler)(int) = signal(SIGCHLD, SIG_DFL); | ||||
// Fork another process for testing before creating the lock, so that we | // Fork another process for testing before creating the lock, so that we | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
// Clean up | // Clean up | ||||
ReleaseDirectoryLocks(); | ReleaseDirectoryLocks(); | ||||
fs::remove_all(dirname); | fs::remove_all(dirname); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(test_DirIsWritable) { | BOOST_AUTO_TEST_CASE(test_DirIsWritable) { | ||||
// Should be able to write to the data dir. | // Should be able to write to the data dir. | ||||
fs::path tmpdirname = SetDataDir("test_DirIsWritable"); | fs::path tmpdirname = GetDataDir(); | ||||
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true); | BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true); | ||||
// Should not be able to write to a non-existent dir. | // Should not be able to write to a non-existent dir. | ||||
tmpdirname = tmpdirname / fs::unique_path(); | tmpdirname = tmpdirname / fs::unique_path(); | ||||
BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), false); | BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), false); | ||||
fs::create_directory(tmpdirname); | fs::create_directory(tmpdirname); | ||||
// Should be able to write to it now. | // Should be able to write to it now. | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |