Index: third_party/leveldatabase/env_chromium_unittest.cc |
diff --git a/third_party/leveldatabase/env_chromium_unittest.cc b/third_party/leveldatabase/env_chromium_unittest.cc |
index d4819e89804399a2235a874de704265070ba03b0..e656132a7c9196bfb01b29c6ad381db66029de07 100644 |
--- a/third_party/leveldatabase/env_chromium_unittest.cc |
+++ b/third_party/leveldatabase/env_chromium_unittest.cc |
@@ -26,6 +26,10 @@ using leveldb::WriteOptions; |
using leveldb_env::ChromiumEnv; |
using leveldb_env::MethodID; |
+namespace leveldb_env { |
+extern size_t WriteBufferSize(int64_t disk_space); |
michaeln
2016/08/16 00:28:05
Is including env_chromium.h not enough, the functi
cmumford
2016/08/16 00:54:26
I overloaded WriteBuferSize and this is the versio
michaeln
2016/08/16 19:41:23
or maybe expose both functions in the .h file inst
|
+} |
+ |
TEST(ErrorEncoding, OnlyAMethod) { |
const MethodID in_method = leveldb_env::kSequentialFileRead; |
const Status s = MakeIOError("Somefile.txt", "message", in_method); |
@@ -169,4 +173,25 @@ TEST(ChromiumEnv, GetChildrenPriorResults) { |
EXPECT_EQ(1U, result.size()); |
} |
+TEST(ChromiumEnv, TestWriteBufferSize) { |
+ // If can't get disk size, use leveldb defaults. |
+ const int64_t MB = 1024 * 1024; |
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(-1)); |
+ |
+ // A very small disk (check lower clamp value). |
+ EXPECT_EQ(size_t(1 * MB), leveldb_env::WriteBufferSize(1 * MB)); |
+ |
+ // Some value on the linear equation between min and max. |
+ EXPECT_EQ(size_t(2.5 * MB), leveldb_env::WriteBufferSize(25 * MB)); |
+ |
+ // The disk size equating to the max buffer size |
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(40 * MB)); |
+ |
+ // Make sure sizes larger than 40MB are clamped to max buffer size. |
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(80 * MB)); |
+ |
+ // Check for very large disk size (catch overflow). |
+ EXPECT_EQ(size_t(4 * MB), leveldb_env::WriteBufferSize(100 * MB * MB)); |
+} |
+ |
int main(int argc, char** argv) { return base::TestSuite(argc, argv).Run(); } |