From e7697b8ce82bf48be4aac168303aebd1c2f61419 Mon Sep 17 00:00:00 2001 From: Siying Dong Date: Wed, 26 Jul 2017 21:02:53 -0700 Subject: [PATCH] Fix LITE unit tests Summary: Closes https://github.com/facebook/rocksdb/pull/2649 Differential Revision: D5505778 Pulled By: siying fbshipit-source-id: 7e935603ede3d958ea087ed6b8cfc4121e8797bc --- db/db_io_failure_test.cc | 2 +- db/db_test2.cc | 3 ++- db/db_test_util.cc | 17 ++++++++++++++--- util/file_reader_writer_test.cc | 8 +++++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/db/db_io_failure_test.cc b/db/db_io_failure_test.cc index e93961c13..9f4dcc5d0 100644 --- a/db/db_io_failure_test.cc +++ b/db/db_io_failure_test.cc @@ -204,7 +204,6 @@ TEST_F(DBIOFailureTest, ManifestWriteError) { ASSERT_EQ("bar2", Get("foo2")); } } -#endif // ROCKSDB_LITE TEST_F(DBIOFailureTest, PutFailsParanoid) { // Test the following: @@ -559,6 +558,7 @@ TEST_F(DBIOFailureTest, CompactionSstSyncError) { ASSERT_EQ("bar3", Get(1, "foo")); } #endif // !(defined NDEBUG) || !defined(OS_WIN) +#endif // ROCKSDB_LITE } // namespace rocksdb int main(int argc, char** argv) { diff --git a/db/db_test2.cc b/db/db_test2.cc index aa10789c8..ca8986c4d 100644 --- a/db/db_test2.cc +++ b/db/db_test2.cc @@ -2236,6 +2236,7 @@ TEST_F(DBTest2, LowPriWrite) { ASSERT_EQ(1, rate_limit_count.load()); } +#ifndef ROCKSDB_LITE TEST_F(DBTest2, RateLimitedCompactionReads) { // compaction input has 512KB data const int kNumKeysPerFile = 128; @@ -2299,7 +2300,7 @@ TEST_F(DBTest2, RateLimitedCompactionReads) { options.rate_limiter->GetTotalBytesThrough(Env::IO_LOW))); } } - +#endif // ROCKSDB_LITE } // namespace rocksdb int main(int argc, char** argv) { diff --git a/db/db_test_util.cc b/db/db_test_util.cc index 5ca4b19a2..c4d465ba1 100644 --- a/db/db_test_util.cc +++ b/db/db_test_util.cc @@ -42,13 +42,24 @@ SpecialEnv::SpecialEnv(Env* base) non_writable_count_ = 0; table_write_callback_ = nullptr; } - +#ifndef ROCKSDB_LITE ROT13BlockCipher rot13Cipher_(16); +#endif // ROCKSDB_LITE DBTestBase::DBTestBase(const std::string path) : mem_env_(!getenv("MEM_ENV") ? nullptr : new MockEnv(Env::Default())), - encrypted_env_(!getenv("ENCRYPTED_ENV") ? nullptr : NewEncryptedEnv(mem_env_ ? mem_env_ : Env::Default(), new CTREncryptionProvider(rot13Cipher_))), - env_(new SpecialEnv(encrypted_env_ ? encrypted_env_ : (mem_env_ ? mem_env_ : Env::Default()))), +#ifndef ROCKSDB_LITE + encrypted_env_( + !getenv("ENCRYPTED_ENV") + ? nullptr + : NewEncryptedEnv(mem_env_ ? mem_env_ : Env::Default(), + new CTREncryptionProvider(rot13Cipher_))), +#else + encrypted_env_(nullptr), +#endif // ROCKSDB_LITE + env_(new SpecialEnv(encrypted_env_ + ? encrypted_env_ + : (mem_env_ ? mem_env_ : Env::Default()))), option_config_(kDefault) { env_->SetBackgroundThreads(1, Env::LOW); env_->SetBackgroundThreads(1, Env::HIGH); diff --git a/util/file_reader_writer_test.cc b/util/file_reader_writer_test.cc index dac518245..45675e9dd 100644 --- a/util/file_reader_writer_test.cc +++ b/util/file_reader_writer_test.cc @@ -143,7 +143,13 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) { env_options.writable_file_max_buffer_size = (attempt < kNumAttempts / 2) ? 512 * 1024 : 700 * 1024; std::string actual; - unique_ptr wf(new FakeWF(&actual, attempt % 2 == 1, no_flush)); + unique_ptr wf(new FakeWF(&actual, +#ifndef ROCKSDB_LITE + attempt % 2 == 1, +#else + false, +#endif + no_flush)); unique_ptr writer( new WritableFileWriter(std::move(wf), env_options));