Adjust c test and fix windows compilation issues

Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/4369

Differential Revision: D9844200

Pulled By: sagar0

fbshipit-source-id: 0d9f5f73b28234eaac55d3551ce4e2dc177af138
main
Dmitri Smirnov 6 years ago committed by Facebook Github Bot
parent 82e8e9e26b
commit 879998b369
  1. 19
      db/c_test.c
  2. 10
      tools/trace_analyzer_tool.h

@ -19,11 +19,8 @@
// Can not use port/port.h macros as this is a c file // Can not use port/port.h macros as this is a c file
#ifdef OS_WIN #ifdef OS_WIN
#include <windows.h> #include <windows.h>
#define snprintf _snprintf
// Ok for uniqueness // Ok for uniqueness
int geteuid() { int geteuid() {
int result = 0; int result = 0;
@ -34,6 +31,11 @@ int geteuid() {
return result; return result;
} }
// VS < 2015
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define snprintf _snprintf
#endif
#endif #endif
const char* phase = ""; const char* phase = "";
@ -47,12 +49,19 @@ static void StartPhase(const char* name) {
fprintf(stderr, "=== Test %s\n", name); fprintf(stderr, "=== Test %s\n", name);
phase = name; phase = name;
} }
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning (disable: 4996) // getenv security warning
#endif
static const char* GetTempDir(void) { static const char* GetTempDir(void) {
const char* ret = getenv("TEST_TMPDIR"); const char* ret = getenv("TEST_TMPDIR");
if (ret == NULL || ret[0] == '\0') if (ret == NULL || ret[0] == '\0')
ret = "/tmp"; ret = "/tmp";
return ret; return ret;
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#define CheckNoError(err) \ #define CheckNoError(err) \
if ((err) != NULL) { \ if ((err) != NULL) { \
@ -643,7 +652,7 @@ int main(int argc, char** argv) {
rocksdb_sstfilewriter_t* writer = rocksdb_sstfilewriter_t* writer =
rocksdb_sstfilewriter_create(env_opt, io_options); rocksdb_sstfilewriter_create(env_opt, io_options);
unlink(sstfilename); remove(sstfilename);
rocksdb_sstfilewriter_open(writer, sstfilename, &err); rocksdb_sstfilewriter_open(writer, sstfilename, &err);
CheckNoError(err); CheckNoError(err);
rocksdb_sstfilewriter_put(writer, "sstk1", 5, "v1", 2, &err); rocksdb_sstfilewriter_put(writer, "sstk1", 5, "v1", 2, &err);
@ -664,7 +673,7 @@ int main(int argc, char** argv) {
CheckGet(db, roptions, "sstk2", "v2"); CheckGet(db, roptions, "sstk2", "v2");
CheckGet(db, roptions, "sstk3", "v3"); CheckGet(db, roptions, "sstk3", "v3");
unlink(sstfilename); remove(sstfilename);
rocksdb_sstfilewriter_open(writer, sstfilename, &err); rocksdb_sstfilewriter_open(writer, sstfilename, &err);
CheckNoError(err); CheckNoError(err);
rocksdb_sstfilewriter_put(writer, "sstk2", 5, "v4", 2, &err); rocksdb_sstfilewriter_put(writer, "sstk2", 5, "v4", 2, &err);

@ -128,6 +128,10 @@ struct TraceStats {
TraceStats(); TraceStats();
~TraceStats(); ~TraceStats();
TraceStats(const TraceStats&) = delete;
TraceStats& operator=(const TraceStats&) = delete;
TraceStats(TraceStats&&) = default;
TraceStats& operator=(TraceStats&&) = default;
}; };
struct TypeUnit { struct TypeUnit {
@ -137,6 +141,12 @@ struct TypeUnit {
uint64_t total_access; uint64_t total_access;
uint64_t total_succ_access; uint64_t total_succ_access;
std::map<uint32_t, TraceStats> stats; 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 { struct CfUnit {

Loading…
Cancel
Save