Tests to avoid to use TMPDIR directly

Summary: Directly using TMPDIR can cause problems when running tests using parallel option. Fix them.

Test Plan: Run all tests in parallel

Reviewers: kradhakrishnan, yhchiang, IslamAbdelRahman, anthony

Reviewed By: anthony

Subscribers: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D42807
This commit is contained in:
sdong 2015-07-21 17:22:49 -07:00
parent f09d45690b
commit 85ac65536b
5 changed files with 7 additions and 4 deletions

View File

@ -46,6 +46,7 @@ DBTestBase::DBTestBase(const std::string path) : option_config_(kDefault),
env_->SetBackgroundThreads(1, Env::HIGH);
dbname_ = test::TmpDir(env_) + path;
alternative_wal_dir_ = dbname_ + "/wal";
alternative_db_log_dir_ = dbname_ + "/db_log_dir";
auto options = CurrentOptions();
auto delete_options = options;
delete_options.wal_dir = alternative_wal_dir_;
@ -229,7 +230,7 @@ Options DBTestBase::CurrentOptions(
options.num_levels = 3;
break;
case kDBLogDir:
options.db_log_dir = test::TmpDir(env_);
options.db_log_dir = alternative_db_log_dir_;
break;
case kWalDirAndMmapReads:
options.wal_dir = alternative_wal_dir_;

View File

@ -428,6 +428,7 @@ class DBTestBase : public testing::Test {
public:
std::string dbname_;
std::string alternative_wal_dir_;
std::string alternative_db_log_dir_;
MockEnv* mem_env_;
SpecialEnv* env_;
DB* db_;

View File

@ -35,7 +35,7 @@ class GeoDBTest : public testing::Test {
}
};
const std::string GeoDBTest::kDefaultDbName = test::TmpDir();
const std::string GeoDBTest::kDefaultDbName = test::TmpDir() + "/geodb_test";
Options GeoDBTest::options = Options();
// Insert, Get and Remove

View File

@ -23,7 +23,7 @@ using namespace rocksdb;
namespace rocksdb {
// Path to the database on file system
const std::string kDbName = test::TmpDir();
const std::string kDbName = test::TmpDir() + "/stringappend_test";
namespace {
// OpenDb opens a (possibly new) rocksdb database with a StringAppendOperator

View File

@ -39,7 +39,8 @@ class RedisListsTest : public testing::Test {
}
};
const string RedisListsTest::kDefaultDbName = test::TmpDir();
const string RedisListsTest::kDefaultDbName =
test::TmpDir() + "/redis_lists_test";
Options RedisListsTest::options = Options();
// operator== and operator<< are defined below for vectors (lists)