From 8674e74b47c1f6e86a367cfbc738fcc9812b616b Mon Sep 17 00:00:00 2001 From: murrayn Date: Wed, 7 Mar 2018 03:08:55 -0800 Subject: Provide relevant error message if datadir is not writable. --- src/test/util_tests.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/test/util_tests.cpp') diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 58f033cd89..e750969b65 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -800,4 +800,20 @@ BOOST_AUTO_TEST_CASE(test_LockDirectory) fs::remove_all(dirname); } +BOOST_AUTO_TEST_CASE(test_DirIsWritable) +{ + // Should be able to write to the system tmp dir. + fs::path tmpdirname = fs::temp_directory_path(); + BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true); + + // Should not be able to write to a non-existent dir. + tmpdirname = fs::temp_directory_path() / fs::unique_path(); + BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), false); + + fs::create_directory(tmpdirname); + // Should be able to write to it now. + BOOST_CHECK_EQUAL(DirIsWritable(tmpdirname), true); + fs::remove(tmpdirname); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3