Let TestEnv and FaultInjectEnv use Env of choice (#5886)
Summary: Instead of hard coding Env::Default in TestEnv and a few other places, use the DBTestBase::env_ that has been deduced from the constructor. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5886 Test Plan: ``` make check ``` Differential Revision: D17773029 Pulled By: riversand963 fbshipit-source-id: 7ce4e5175a487e9d281ea2c3aae3c41bffd44629
This commit is contained in:
parent
9905101c8c
commit
457bcfde02
@ -913,30 +913,30 @@ TEST_F(DBBasicTest, MmapAndBufferOptions) {
|
|||||||
|
|
||||||
class TestEnv : public EnvWrapper {
|
class TestEnv : public EnvWrapper {
|
||||||
public:
|
public:
|
||||||
explicit TestEnv() : EnvWrapper(Env::Default()),
|
explicit TestEnv(Env* base_env) : EnvWrapper(base_env), close_count(0) {}
|
||||||
close_count(0) { }
|
|
||||||
|
|
||||||
class TestLogger : public Logger {
|
class TestLogger : public Logger {
|
||||||
public:
|
public:
|
||||||
using Logger::Logv;
|
using Logger::Logv;
|
||||||
TestLogger(TestEnv *env_ptr) : Logger() { env = env_ptr; }
|
explicit TestLogger(TestEnv* env_ptr) : Logger() { env = env_ptr; }
|
||||||
~TestLogger() override {
|
~TestLogger() override {
|
||||||
if (!closed_) {
|
if (!closed_) {
|
||||||
CloseHelper();
|
CloseHelper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Logv(const char* /*format*/, va_list /*ap*/) override{};
|
void Logv(const char* /*format*/, va_list /*ap*/) override {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Status CloseImpl() override { return CloseHelper(); }
|
Status CloseImpl() override { return CloseHelper(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Status CloseHelper() {
|
Status CloseHelper() {
|
||||||
env->CloseCountInc();;
|
env->CloseCountInc();
|
||||||
return Status::IOError();
|
;
|
||||||
}
|
return Status::IOError();
|
||||||
TestEnv *env;
|
}
|
||||||
};
|
TestEnv* env;
|
||||||
|
};
|
||||||
|
|
||||||
void CloseCountInc() { close_count++; }
|
void CloseCountInc() { close_count++; }
|
||||||
|
|
||||||
@ -958,7 +958,8 @@ TEST_F(DBBasicTest, DBClose) {
|
|||||||
ASSERT_OK(DestroyDB(dbname, options));
|
ASSERT_OK(DestroyDB(dbname, options));
|
||||||
|
|
||||||
DB* db = nullptr;
|
DB* db = nullptr;
|
||||||
TestEnv* env = new TestEnv();
|
TestEnv* env = new TestEnv(env_);
|
||||||
|
std::unique_ptr<TestEnv> local_env_guard(env);
|
||||||
options.create_if_missing = true;
|
options.create_if_missing = true;
|
||||||
options.env = env;
|
options.env = env;
|
||||||
Status s = DB::Open(options, dbname, &db);
|
Status s = DB::Open(options, dbname, &db);
|
||||||
@ -992,13 +993,11 @@ TEST_F(DBBasicTest, DBClose) {
|
|||||||
ASSERT_EQ(env->GetCloseCount(), 2);
|
ASSERT_EQ(env->GetCloseCount(), 2);
|
||||||
options.info_log.reset();
|
options.info_log.reset();
|
||||||
ASSERT_EQ(env->GetCloseCount(), 3);
|
ASSERT_EQ(env->GetCloseCount(), 3);
|
||||||
|
|
||||||
delete options.env;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DBBasicTest, DBCloseFlushError) {
|
TEST_F(DBBasicTest, DBCloseFlushError) {
|
||||||
std::unique_ptr<FaultInjectionTestEnv> fault_injection_env(
|
std::unique_ptr<FaultInjectionTestEnv> fault_injection_env(
|
||||||
new FaultInjectionTestEnv(Env::Default()));
|
new FaultInjectionTestEnv(env_));
|
||||||
Options options = GetDefaultOptions();
|
Options options = GetDefaultOptions();
|
||||||
options.create_if_missing = true;
|
options.create_if_missing = true;
|
||||||
options.manual_wal_flush = true;
|
options.manual_wal_flush = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user