summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorReilly Grant <reillyg@google.com>2023-03-28 14:37:48 -0700
committerReilly Grant <reillyg@google.com>2023-03-28 14:37:48 -0700
commit89ea7f26438001a796f3338222e5321c5571042f (patch)
treec749b9384e02b9dbadd2fe5350cca1e1cbc9e901 /db
parentfb644cb44539925a7f444b1b0314f402a456c5f4 (diff)
downloadleveldb-89ea7f26438001a796f3338222e5321c5571042f.tar.gz
Fix tests when run against ChromiumEnv
There are a couple differences between ChromiumEnv and PosixEnv/WindowsEnv which cause test failures that are fixed (or at least patched over) in this change: * NewSequentialFile() and NewRandomAccessFile() return Status::IOError rather than Status::NotFound when a file is not found, due to https://crbug.com/760362. This means a few tests need to expect a different error result. * GetChildren() never returns the '.' or '..' entries. * As allowed by the documentation for Env::Schedule(), ChromiumEnv may execute functions on multiple threads and guarantees no sequencing. EnvTest.RunMany assumed that functions ran in order. The test has been updated.
Diffstat (limited to 'db')
-rw-r--r--db/db_test.cc5
-rw-r--r--db/recovery_test.cc5
2 files changed, 10 insertions, 0 deletions
diff --git a/db/db_test.cc b/db/db_test.cc
index 472258b..a4d8d58 100644
--- a/db/db_test.cc
+++ b/db/db_test.cc
@@ -1722,8 +1722,13 @@ TEST_F(DBTest, DestroyEmptyDir) {
ASSERT_TRUE(env.FileExists(dbname));
std::vector<std::string> children;
ASSERT_LEVELDB_OK(env.GetChildren(dbname, &children));
+#if defined(LEVELDB_PLATFORM_CHROMIUM)
+ // Chromium's file system abstraction always filters out '.' and '..'.
+ ASSERT_EQ(0, children.size());
+#else
// The stock Env's do not filter out '.' and '..' special files.
ASSERT_EQ(2, children.size());
+#endif // defined(LEVELDB_PLATFORM_CHROMIUM)
ASSERT_LEVELDB_OK(DestroyDB(dbname, opts));
ASSERT_TRUE(!env.FileExists(dbname));
diff --git a/db/recovery_test.cc b/db/recovery_test.cc
index 1d9f621..8dc039a 100644
--- a/db/recovery_test.cc
+++ b/db/recovery_test.cc
@@ -328,7 +328,12 @@ TEST_F(RecoveryTest, ManifestMissing) {
RemoveManifestFile();
Status status = OpenWithStatus();
+#if defined(LEVELDB_PLATFORM_CHROMIUM)
+ // TODO(crbug.com/760362): See comment in MakeIOError() from env_chromium.cc.
+ ASSERT_TRUE(status.IsIOError());
+#else
ASSERT_TRUE(status.IsCorruption());
+#endif // defined(LEVELDB_PLATFORM_CHROMIUM)
}
} // namespace leveldb