Skip to content

Commit

Permalink
Adjust c test and fix windows compilation issues
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#4369

Differential Revision: D9844200

Pulled By: sagar0

fbshipit-source-id: 0d9f5f73b28234eaac55d3551ce4e2dc177af138
  • Loading branch information
yuslepukhin authored and facebook-github-bot committed Sep 15, 2018
1 parent 82e8e9e commit 879998b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
19 changes: 14 additions & 5 deletions db/c_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

// Can not use port/port.h macros as this is a c file
#ifdef OS_WIN

#include <windows.h>

#define snprintf _snprintf

// Ok for uniqueness
int geteuid() {
int result = 0;
Expand All @@ -34,6 +31,11 @@ int geteuid() {
return result;
}

// VS < 2015
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define snprintf _snprintf
#endif

#endif

const char* phase = "";
Expand All @@ -47,12 +49,19 @@ static void StartPhase(const char* name) {
fprintf(stderr, "=== Test %s\n", name);
phase = name;
}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning (disable: 4996) // getenv security warning
#endif
static const char* GetTempDir(void) {
const char* ret = getenv("TEST_TMPDIR");
if (ret == NULL || ret[0] == '\0')
ret = "/tmp";
return ret;
}
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#define CheckNoError(err) \
if ((err) != NULL) { \
Expand Down Expand Up @@ -643,7 +652,7 @@ int main(int argc, char** argv) {
rocksdb_sstfilewriter_t* writer =
rocksdb_sstfilewriter_create(env_opt, io_options);

unlink(sstfilename);
remove(sstfilename);
rocksdb_sstfilewriter_open(writer, sstfilename, &err);
CheckNoError(err);
rocksdb_sstfilewriter_put(writer, "sstk1", 5, "v1", 2, &err);
Expand All @@ -664,7 +673,7 @@ int main(int argc, char** argv) {
CheckGet(db, roptions, "sstk2", "v2");
CheckGet(db, roptions, "sstk3", "v3");

unlink(sstfilename);
remove(sstfilename);
rocksdb_sstfilewriter_open(writer, sstfilename, &err);
CheckNoError(err);
rocksdb_sstfilewriter_put(writer, "sstk2", 5, "v4", 2, &err);
Expand Down
10 changes: 10 additions & 0 deletions tools/trace_analyzer_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ struct TraceStats {

TraceStats();
~TraceStats();
TraceStats(const TraceStats&) = delete;
TraceStats& operator=(const TraceStats&) = delete;
TraceStats(TraceStats&&) = default;
TraceStats& operator=(TraceStats&&) = default;
};

struct TypeUnit {
Expand All @@ -137,6 +141,12 @@ struct TypeUnit {
uint64_t total_access;
uint64_t total_succ_access;
std::map<uint32_t, TraceStats> stats;
TypeUnit() = default;
~TypeUnit() = default;
TypeUnit(const TypeUnit&) = delete;
TypeUnit& operator=(const TypeUnit&) = delete;
TypeUnit(TypeUnit&&) = default;
TypeUnit& operator=(TypeUnit&&) = default;
};

struct CfUnit {
Expand Down

0 comments on commit 879998b

Please sign in to comment.