From 49f42ad032fe1ac921e334b29b2b2b76c9e67087 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Mon, 13 Jul 2015 17:41:41 -0700 Subject: [PATCH] Move global static functions in db_test_util to DBTestBase Summary: Move global static functions in db_test_util to DBTestBase. This is to prevent unused function warning when decoupling db_test.cc into multiple files. Test Plan: db_test Reviewers: igor, sdong, anthony, IslamAbdelRahman, kradhakrishnan Reviewed By: kradhakrishnan Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D42009 --- db/db_test.cc | 12 ++++++------ util/db_test_util.h | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 90fcd0d45..2aac2d15c 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -4383,8 +4383,8 @@ void MinLevelHelper(DBTest* self, Options& options) { std::vector values; // Write 120KB (12 values, each 10K) for (int i = 0; i < 12; i++) { - values.push_back(RandomString(&rnd, 10000)); - ASSERT_OK(self->Put(Key(i), values[i])); + values.push_back(DBTestBase::RandomString(&rnd, 10000)); + ASSERT_OK(self->Put(DBTestBase::Key(i), values[i])); } self->dbfull()->TEST_WaitForFlushMemTable(); ASSERT_EQ(self->NumTableFilesAtLevel(0), num + 1); @@ -4393,8 +4393,8 @@ void MinLevelHelper(DBTest* self, Options& options) { //generate one more file in level-0, and should trigger level-0 compaction std::vector values; for (int i = 0; i < 12; i++) { - values.push_back(RandomString(&rnd, 10000)); - ASSERT_OK(self->Put(Key(i), values[i])); + values.push_back(DBTestBase::RandomString(&rnd, 10000)); + ASSERT_OK(self->Put(DBTestBase::Key(i), values[i])); } self->dbfull()->TEST_WaitForCompact(); @@ -9211,7 +9211,7 @@ static void RandomTimeoutWriter(void* arg) { for (int k = 0; k < num_keys; ++k) { int key = k + thread_id * num_keys; - std::string value = RandomString(&rnd, kValueSize); + std::string value = DBTestBase::RandomString(&rnd, kValueSize); // only the second-half is randomized if (k > num_keys / 2) { switch (rnd.Next() % 5) { @@ -9231,7 +9231,7 @@ static void RandomTimeoutWriter(void* arg) { } uint64_t time_before_put = db->GetEnv()->NowMicros(); - Status s = db->Put(write_opt, Key(key), value); + Status s = db->Put(write_opt, DBTestBase::Key(key), value); uint64_t put_duration = db->GetEnv()->NowMicros() - time_before_put; if (write_opt.timeout_hint_us == 0 || put_duration + kTimerBias < write_opt.timeout_hint_us) { diff --git a/util/db_test_util.h b/util/db_test_util.h index c64c62a43..440442f6e 100644 --- a/util/db_test_util.h +++ b/util/db_test_util.h @@ -55,12 +55,6 @@ namespace rocksdb { -static std::string RandomString(Random* rnd, int len) { - std::string r; - test::RandomString(rnd, len, &r); - return r; -} - namespace anon { class AtomicCounter { public: @@ -118,12 +112,6 @@ struct OptionsOverride { } // namespace anon -static std::string Key(int i) { - char buf[100]; - snprintf(buf, sizeof(buf), "key%06d", i); - return std::string(buf); -} - // Special Env used to delay background operations class SpecialEnv : public EnvWrapper { public: @@ -456,6 +444,18 @@ class DBTestBase : public testing::Test { ~DBTestBase(); + static std::string RandomString(Random* rnd, int len) { + std::string r; + test::RandomString(rnd, len, &r); + return r; + } + + static std::string Key(int i) { + char buf[100]; + snprintf(buf, sizeof(buf), "key%06d", i); + return std::string(buf); + } + // Switch to a fresh database with the next option configuration to // test. Return false if there are no more configurations to test. bool ChangeOptions(int skip_mask = kNoSkip);