aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authormurrayn <github@nesbitt.ca>2018-03-07 03:08:55 -0800
committermurrayn <github@nesbitt.ca>2018-03-14 19:07:30 -0700
commit8674e74b47c1f6e86a367cfbc738fcc9812b616b (patch)
treeacf9d52938e2021e4dcb9ad1c89e02ae8362d82a /src/test
parentb225010a808d475cbb53aeed484295f8dc8751c4 (diff)
downloadbitcoin-8674e74b47c1f6e86a367cfbc738fcc9812b616b.tar.xz
Provide relevant error message if datadir is not writable.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/util_tests.cpp16
1 files changed, 16 insertions, 0 deletions
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()