From abc90b067ccceee1f58580ee8ca578c97c14d452 Mon Sep 17 00:00:00 2001 From: Jim Paton Date: Mon, 29 Jul 2013 13:26:38 -0700 Subject: [PATCH] Use specific DB name in merge_test Summary: Currently, merge_test uses /tmp/testdb for the test database. It should really use something more specific to merge_test. Most of the other tests use test::TmpDir() + "/db". This patch implements such behavior for merge_test; it makes merge_test use test::TmpDir() + "/merge_testdb" Test Plan: make clean make -j32 merge_test ./merge_test Reviewers: dhruba, haobo Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D11877 --- Makefile | 4 ++-- db/merge_test.cc | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9b1d05fcf..765e52b52 100644 --- a/Makefile +++ b/Makefile @@ -240,8 +240,8 @@ reduce_levels_test: tools/reduce_levels_test.o $(LIBOBJECTS) $(TESTHARNESS) write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) $(CXX) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) -merge_test: db/merge_test.o $(LIBOBJECTS) - $(CXX) db/merge_test.o $(LIBOBJECTS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) +merge_test: db/merge_test.o $(LIBOBJECTS) $(TESTHARNESS) + $(CXX) db/merge_test.o $(LIBOBJECTS) $(TESTHARNESS) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(MEMENVLIBRARY) : $(MEMENVOBJECTS) rm -f $@ diff --git a/db/merge_test.cc b/db/merge_test.cc index 2d2f6514f..47fad025d 100644 --- a/db/merge_test.cc +++ b/db/merge_test.cc @@ -9,6 +9,7 @@ #include "leveldb/merge_operator.h" #include "db/dbformat.h" #include "utilities/merge_operators.h" +#include "util/testharness.h" using namespace std; using namespace leveldb; @@ -20,7 +21,7 @@ std::shared_ptr OpenDb() { Options options; options.create_if_missing = true; options.merge_operator = mergeOperator.get(); - Status s = DB::Open(options, "/tmp/testdb", &db); + Status s = DB::Open(options, test::TmpDir() + "/merge_testdb", &db); if (!s.ok()) { cerr << s.ToString() << endl; assert(false); @@ -45,7 +46,7 @@ class Counters { uint64_t default_; public: - Counters(std::shared_ptr db, uint64_t defaultCount = 0) + explicit Counters(std::shared_ptr db, uint64_t defaultCount = 0) : db_(db), put_option_(), get_option_(), @@ -143,7 +144,7 @@ class MergeBasedCounters : public Counters { WriteOptions merge_option_; // for merge public: - MergeBasedCounters(std::shared_ptr db, uint64_t defaultCount = 0) + explicit MergeBasedCounters(std::shared_ptr db, uint64_t defaultCount = 0) : Counters(db, defaultCount), merge_option_() { }