Make "make all" work for CYGWIN

Summary: Some test and benchmark codes don't build for CYGWIN. Fix it.

Test Plan: Build "make all" with TARGET_OS=Cygwin on cygwin and make sure it passes.

Reviewers: rven, yhchiang, anthony, igor, kradhakrishnan

Reviewed By: igor, kradhakrishnan

Subscribers: leveldb, dhruba

Differential Revision: https://reviews.facebook.net/D39711
main
sdong 9 years ago
parent 62c3a95796
commit e409d3d745
  1. 2
      db/column_family_test.cc
  2. 6
      db/compact_files_test.cc
  3. 2
      db/compaction_job_stats_test.cc
  4. 5
      db/comparator_db_test.cc
  5. 6
      db/db_bench.cc
  6. 2
      db/db_test.cc
  7. 11
      db/memtable_list_test.cc
  8. 13
      utilities/backupable/backupable_db_test.cc
  9. 8
      utilities/ttl/ttl_test.cc
  10. 9
      utilities/write_batch_with_index/write_batch_with_index_test.cc

@ -121,7 +121,7 @@ class ColumnFamilyTest : public testing::Test {
#ifndef CYGWIN #ifndef CYGWIN
return std::stoi(value); return std::stoi(value);
#else #else
return std::strtol(value.c_str(), 0); return std::strtol(value.c_str(), 0 /* off */, 10 /* base */);
#endif #endif
} }

@ -9,6 +9,7 @@
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "util/string_util.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace rocksdb { namespace rocksdb {
@ -76,9 +77,8 @@ TEST_F(CompactFilesTest, ObsoleteFiles) {
// create couple files // create couple files
for (int i = 1000; i < 2000; ++i) { for (int i = 1000; i < 2000; ++i) {
db->Put(WriteOptions(), db->Put(WriteOptions(), ToString(i),
std::to_string(i), std::string(kWriteBufferSize / 10, 'a' + (i % 26)));
std::string(kWriteBufferSize / 10, 'a' + (i % 26)));
} }
auto l0_files = collector->GetFlushedFiles(); auto l0_files = collector->GetFlushedFiles();

@ -573,7 +573,7 @@ TEST_F(CompactionJobStatsTest, CompactionJobStatsTest) {
snprintf(buf, kBufSize, "%d", ++num_L0_files); snprintf(buf, kBufSize, "%d", ++num_L0_files);
ASSERT_EQ(std::string(buf), FilesPerLevel(1)); ASSERT_EQ(std::string(buf), FilesPerLevel(1));
} }
ASSERT_EQ(std::to_string(num_L0_files), FilesPerLevel(1)); ASSERT_EQ(ToString(num_L0_files), FilesPerLevel(1));
// 2nd Phase: perform L0 -> L1 compaction. // 2nd Phase: perform L0 -> L1 compaction.
int L0_compaction_count = 6; int L0_compaction_count = 6;

@ -177,8 +177,13 @@ class DoubleComparator : public Comparator {
virtual const char* Name() const override { return "DoubleComparator"; } virtual const char* Name() const override { return "DoubleComparator"; }
virtual int Compare(const Slice& a, const Slice& b) const override { virtual int Compare(const Slice& a, const Slice& b) const override {
#ifndef CYGWIN
double da = std::stod(a.ToString()); double da = std::stod(a.ToString());
double db = std::stod(b.ToString()); double db = std::stod(b.ToString());
#else
double da = std::strtod(a.ToString().c_str(), 0 /* endptr */);
double db = std::strtod(a.ToString().c_str(), 0 /* endptr */);
#endif
if (da == db) { if (da == db) {
return a.compare(b); return a.compare(b);
} else if (da > db) { } else if (da > db) {

@ -3665,7 +3665,11 @@ int main(int argc, char** argv) {
FLAGS_max_bytes_for_level_multiplier_additional, ','); FLAGS_max_bytes_for_level_multiplier_additional, ',');
for (unsigned int j= 0; j < fanout.size(); j++) { for (unsigned int j= 0; j < fanout.size(); j++) {
FLAGS_max_bytes_for_level_multiplier_additional_v.push_back( FLAGS_max_bytes_for_level_multiplier_additional_v.push_back(
std::stoi(fanout[j])); #ifndef CYGWIN
std::stoi(fanout[j]));
#else
stoi(fanout[j]));
#endif
} }
FLAGS_compression_type_e = FLAGS_compression_type_e =

@ -13282,7 +13282,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
pass); pass);
for (;;) { for (;;) {
std::string data(3000, j++ % 127 + 20); std::string data(3000, j++ % 127 + 20);
data += std::to_string(j); data += ToString(j);
batch.Put(handles_[0], Slice(data), Slice(data)); batch.Put(handles_[0], Slice(data), Slice(data));
if (batch.GetDataSize() > write_size) { if (batch.GetDataSize() > write_size) {
break; break;

@ -13,6 +13,7 @@
#include "db/writebuffer.h" #include "db/writebuffer.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "util/string_util.h"
#include "util/testharness.h" #include "util/testharness.h"
namespace rocksdb { namespace rocksdb {
@ -415,11 +416,11 @@ TEST_F(MemTableListTest, FlushPendingTest) {
std::string value; std::string value;
MergeContext merge_context; MergeContext merge_context;
mem->Add(++seq, kTypeValue, "key1", std::to_string(i)); mem->Add(++seq, kTypeValue, "key1", ToString(i));
mem->Add(++seq, kTypeValue, "keyN" + std::to_string(i), "valueN"); mem->Add(++seq, kTypeValue, "keyN" + ToString(i), "valueN");
mem->Add(++seq, kTypeValue, "keyX" + std::to_string(i), "value"); mem->Add(++seq, kTypeValue, "keyX" + ToString(i), "value");
mem->Add(++seq, kTypeValue, "keyM" + std::to_string(i), "valueM"); mem->Add(++seq, kTypeValue, "keyM" + ToString(i), "valueM");
mem->Add(++seq, kTypeDeletion, "keyX" + std::to_string(i), ""); mem->Add(++seq, kTypeDeletion, "keyX" + ToString(i), "");
tables.push_back(mem); tables.push_back(mem);
} }

@ -18,6 +18,7 @@
#include "util/testharness.h" #include "util/testharness.h"
#include "util/random.h" #include "util/random.h"
#include "util/mutexlock.h" #include "util/mutexlock.h"
#include "util/string_util.h"
#include "util/testutil.h" #include "util/testutil.h"
#include "util/auto_roll_logger.h" #include "util/auto_roll_logger.h"
@ -323,8 +324,8 @@ class FileManager : public EnvWrapper {
static size_t FillDB(DB* db, int from, int to) { static size_t FillDB(DB* db, int from, int to) {
size_t bytes_written = 0; size_t bytes_written = 0;
for (int i = from; i < to; ++i) { for (int i = from; i < to; ++i) {
std::string key = "testkey" + std::to_string(i); std::string key = "testkey" + ToString(i);
std::string value = "testvalue" + std::to_string(i); std::string value = "testvalue" + ToString(i);
bytes_written += key.size() + value.size(); bytes_written += key.size() + value.size();
EXPECT_OK(db->Put(WriteOptions(), Slice(key), Slice(value))); EXPECT_OK(db->Put(WriteOptions(), Slice(key), Slice(value)));
@ -334,17 +335,17 @@ static size_t FillDB(DB* db, int from, int to) {
static void AssertExists(DB* db, int from, int to) { static void AssertExists(DB* db, int from, int to) {
for (int i = from; i < to; ++i) { for (int i = from; i < to; ++i) {
std::string key = "testkey" + std::to_string(i); std::string key = "testkey" + ToString(i);
std::string value; std::string value;
Status s = db->Get(ReadOptions(), Slice(key), &value); Status s = db->Get(ReadOptions(), Slice(key), &value);
ASSERT_EQ(value, "testvalue" + std::to_string(i)); ASSERT_EQ(value, "testvalue" + ToString(i));
} }
} }
static void AssertEmpty(DB* db, int from, int to) { static void AssertEmpty(DB* db, int from, int to) {
for (int i = from; i < to; ++i) { for (int i = from; i < to; ++i) {
std::string key = "testkey" + std::to_string(i); std::string key = "testkey" + ToString(i);
std::string value = "testvalue" + std::to_string(i); std::string value = "testvalue" + ToString(i);
Status s = db->Get(ReadOptions(), Slice(key), &value); Status s = db->Get(ReadOptions(), Slice(key), &value);
ASSERT_TRUE(s.IsNotFound()); ASSERT_TRUE(s.IsNotFound());

@ -305,7 +305,13 @@ class TtlTest : public testing::Test {
size_t pos = key_string.find_first_of(search_str); size_t pos = key_string.find_first_of(search_str);
int num_key_end; int num_key_end;
if (pos != std::string::npos) { if (pos != std::string::npos) {
num_key_end = stoi(key_string.substr(pos, key.size() - pos)); auto key_substr = key_string.substr(pos, key.size() - pos);
#ifndef CYGWIN
num_key_end = std::stoi(key_substr);
#else
num_key_end = std::strtol(key_substr.c_str(), 0, 10);
#endif
} else { } else {
return false; // Keep keys not matching the format "key<NUMBER>" return false; // Keep keys not matching the format "key<NUMBER>"
} }

@ -12,6 +12,7 @@
#include <map> #include <map>
#include "db/column_family.h" #include "db/column_family.h"
#include "rocksdb/utilities/write_batch_with_index.h" #include "rocksdb/utilities/write_batch_with_index.h"
#include "util/string_util.h"
#include "util/testharness.h" #include "util/testharness.h"
#include "utilities/merge_operators.h" #include "utilities/merge_operators.h"
#include "utilities/merge_operators/string_append/stringappend.h" #include "utilities/merge_operators/string_append/stringappend.h"
@ -981,11 +982,11 @@ TEST_F(WriteBatchWithIndexTest, TestGetFromBatchMerge) {
std::string expected = "X"; std::string expected = "X";
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
batch.Merge("x", std::to_string(i)); batch.Merge("x", ToString(i));
expected = expected + "," + std::to_string(i); expected = expected + "," + ToString(i);
if (i % 2 == 0) { if (i % 2 == 0) {
batch.Put("y", std::to_string(i / 2)); batch.Put("y", ToString(i / 2));
} }
batch.Merge("z", "z"); batch.Merge("z", "z");
@ -996,7 +997,7 @@ TEST_F(WriteBatchWithIndexTest, TestGetFromBatchMerge) {
s = batch.GetFromBatch(column_family, options, "y", &value); s = batch.GetFromBatch(column_family, options, "y", &value);
ASSERT_OK(s); ASSERT_OK(s);
ASSERT_EQ(std::to_string(i / 2), value); ASSERT_EQ(ToString(i / 2), value);
s = batch.GetFromBatch(column_family, options, "z", &value); s = batch.GetFromBatch(column_family, options, "z", &value);
ASSERT_TRUE(s.IsMergeInProgress()); ASSERT_TRUE(s.IsMergeInProgress());

Loading…
Cancel
Save