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
This commit is contained in:
Dmitri Smirnov 2018-09-14 20:49:20 -07:00 committed by Facebook Github Bot
parent 82e8e9e26b
commit 879998b369
2 changed files with 24 additions and 5 deletions

View File

@ -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;
@ -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 = "";
@ -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) { \
@ -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);
@ -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);

View File

@ -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 {
@ -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 {