From c9d668c5848e3a69d16ca2f3c7857f40776194f3 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Thu, 14 Apr 2016 17:33:53 -0700 Subject: [PATCH] Fix unit tests issues on Windows (#1078) --- db/auto_roll_logger_test.cc | 9 +++++++++ db/column_family_test.cc | 4 ++++ db/db_test.cc | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/db/auto_roll_logger_test.cc b/db/auto_roll_logger_test.cc index 60c89a186..ecb605102 100644 --- a/db/auto_roll_logger_test.cc +++ b/db/auto_roll_logger_test.cc @@ -458,7 +458,16 @@ TEST_F(AutoRollLoggerTest, LogHeaderTest) { TEST_F(AutoRollLoggerTest, LogFileExistence) { rocksdb::DB* db; rocksdb::Options options; +#ifdef OS_WIN + // Replace all slashes in the path so windows CompSpec does not + // become confused + std::string testDir(kTestDir); + std::replace_if(testDir.begin(), testDir.end(), + [](char ch) { return ch == '/'; }, '\\'); + std::string deleteCmd = "if exist " + testDir + " rd /s /q " + testDir; +#else string deleteCmd = "rm -rf " + kTestDir; +#endif ASSERT_EQ(system(deleteCmd.c_str()), 0); options.max_log_file_size = 100 * 1024 * 1024; options.create_if_missing = true; diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 6e05a7da9..88e85bf15 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -2557,6 +2557,9 @@ TEST_F(ColumnFamilyTest, CompactionSpeedupTwoColumnFamilies) { ASSERT_EQ(2, dbfull()->BGCompactionsAllowed()); } +// Disable on windows because SyncWAL requires env->IsSyncThreadSafe() +// to return true which is not so in unbuffered mode. +#ifndef OS_WIN TEST_F(ColumnFamilyTest, LogSyncConflictFlush) { Open(); CreateColumnFamiliesAndReopen({"one", "two"}); @@ -2586,6 +2589,7 @@ TEST_F(ColumnFamilyTest, LogSyncConflictFlush) { rocksdb::SyncPoint::GetInstance()->DisableProcessing(); Close(); } +#endif } // namespace rocksdb int main(int argc, char** argv) { diff --git a/db/db_test.cc b/db/db_test.cc index 86500483f..52e7b8dbb 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5880,7 +5880,11 @@ TEST_F(DBTest, MmapAndBufferOptions) { Options options = CurrentOptions(); // If allow_mmap_reads is on allow_os_buffer must also be on + // On Windows you can have either memory mapped file or a file + // with unbuffered access. +#ifndef OS_WIN options.allow_os_buffer = false; +#endif options.allow_mmap_reads = true; ASSERT_NOK(TryReopen(options));