Skip to content

Commit

Permalink
clang format files under test_util/ (facebook#10855)
Browse files Browse the repository at this point in the history
Summary:
Ran `find . -iname '*.h' -o -iname '*.cc' | xargs clang-format -i` under test_util/.

Pull Request resolved: facebook#10855

Test Plan: existing CI.

Reviewed By: siying

Differential Revision: D40652583

Pulled By: cbi42

fbshipit-source-id: ed0fbcfe17b6f9ec217a64b80d6d43dfbf1cc34e
  • Loading branch information
cbi42 authored and facebook-github-bot committed Oct 25, 2022
1 parent 671753c commit aca0000
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 55 deletions.
26 changes: 8 additions & 18 deletions test_util/sync_point.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,34 @@ SyncPoint* SyncPoint::GetInstance() {

SyncPoint::SyncPoint() : impl_(new Data) {}

SyncPoint:: ~SyncPoint() {
delete impl_;
}
SyncPoint::~SyncPoint() { delete impl_; }

void SyncPoint::LoadDependency(const std::vector<SyncPointPair>& dependencies) {
impl_->LoadDependency(dependencies);
}

void SyncPoint::LoadDependencyAndMarkers(
const std::vector<SyncPointPair>& dependencies,
const std::vector<SyncPointPair>& markers) {
const std::vector<SyncPointPair>& dependencies,
const std::vector<SyncPointPair>& markers) {
impl_->LoadDependencyAndMarkers(dependencies, markers);
}

void SyncPoint::SetCallBack(const std::string& point,
const std::function<void(void*)>& callback) {
const std::function<void(void*)>& callback) {
impl_->SetCallBack(point, callback);
}

void SyncPoint::ClearCallBack(const std::string& point) {
impl_->ClearCallBack(point);
}

void SyncPoint::ClearAllCallBacks() {
impl_->ClearAllCallBacks();
}
void SyncPoint::ClearAllCallBacks() { impl_->ClearAllCallBacks(); }

void SyncPoint::EnableProcessing() {
impl_->EnableProcessing();
}
void SyncPoint::EnableProcessing() { impl_->EnableProcessing(); }

void SyncPoint::DisableProcessing() {
impl_->DisableProcessing();
}
void SyncPoint::DisableProcessing() { impl_->DisableProcessing(); }

void SyncPoint::ClearTrace() {
impl_->ClearTrace();
}
void SyncPoint::ClearTrace() { impl_->ClearTrace(); }

void SyncPoint::Process(const Slice& point, void* cb_arg) {
impl_->Process(point, cb_arg);
Expand Down
4 changes: 2 additions & 2 deletions test_util/sync_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ class SyncPoint {
struct Data;

private:
// Singleton
// Singleton
SyncPoint();
Data* impl_;
Data* impl_;
};

// Sets up sync points to mock direct IO instead of actually issuing direct IO
Expand Down
7 changes: 4 additions & 3 deletions test_util/sync_point_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void KillPoint::TestKillRandom(std::string kill_point, int odds_weight,
}
}

void SyncPoint::Data::LoadDependency(const std::vector<SyncPointPair>& dependencies) {
void SyncPoint::Data::LoadDependency(
const std::vector<SyncPointPair>& dependencies) {
std::lock_guard<std::mutex> lock(mutex_);
successors_.clear();
predecessors_.clear();
Expand All @@ -52,8 +53,8 @@ void SyncPoint::Data::LoadDependency(const std::vector<SyncPointPair>& dependenc
}

void SyncPoint::Data::LoadDependencyAndMarkers(
const std::vector<SyncPointPair>& dependencies,
const std::vector<SyncPointPair>& markers) {
const std::vector<SyncPointPair>& dependencies,
const std::vector<SyncPointPair>& markers) {
std::lock_guard<std::mutex> lock(mutex_);
successors_.clear();
predecessors_.clear();
Expand Down
31 changes: 13 additions & 18 deletions test_util/sync_point_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ struct SyncPoint::Data {
// successor/predecessor map loaded from LoadDependency
std::unordered_map<std::string, std::vector<std::string>> successors_;
std::unordered_map<std::string, std::vector<std::string>> predecessors_;
std::unordered_map<std::string, std::function<void(void*)> > callbacks_;
std::unordered_map<std::string, std::vector<std::string> > markers_;
std::unordered_map<std::string, std::function<void(void*)>> callbacks_;
std::unordered_map<std::string, std::vector<std::string>> markers_;
std::unordered_map<std::string, std::thread::id> marked_thread_id_;

std::mutex mutex_;
std::mutex mutex_;
std::condition_variable cv_;
// sync points that have been passed through
std::unordered_set<std::string> cleared_points_;
Expand All @@ -68,34 +68,29 @@ struct SyncPoint::Data {

void LoadDependency(const std::vector<SyncPointPair>& dependencies);
void LoadDependencyAndMarkers(const std::vector<SyncPointPair>& dependencies,
const std::vector<SyncPointPair>& markers);
const std::vector<SyncPointPair>& markers);
bool PredecessorsAllCleared(const std::string& point);
void SetCallBack(const std::string& point,
const std::function<void(void*)>& callback) {
std::lock_guard<std::mutex> lock(mutex_);
callbacks_[point] = callback;
point_filter_.Add(point);
}
const std::function<void(void*)>& callback) {
std::lock_guard<std::mutex> lock(mutex_);
callbacks_[point] = callback;
point_filter_.Add(point);
}

void ClearCallBack(const std::string& point);
void ClearAllCallBacks();
void EnableProcessing() {
enabled_ = true;
}
void DisableProcessing() {
enabled_ = false;
}
void EnableProcessing() { enabled_ = true; }
void DisableProcessing() { enabled_ = false; }
void ClearTrace() {
std::lock_guard<std::mutex> lock(mutex_);
cleared_points_.clear();
}
bool DisabledByMarker(const std::string& point,
std::thread::id thread_id) {
bool DisabledByMarker(const std::string& point, std::thread::id thread_id) {
auto marked_point_iter = marked_thread_id_.find(point);
return marked_point_iter != marked_thread_id_.end() &&
thread_id != marked_point_iter->second;
}
void Process(const Slice& point, void* cb_arg);
};
} // namespace ROCKSDB_NAMESPACE
#endif // NDEBUG
#endif // NDEBUG
3 changes: 1 addition & 2 deletions test_util/testharness.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ ::testing::AssertionResult AssertStatus(const char* s_expr, const Status& s) {
if (s.ok()) {
return ::testing::AssertionSuccess();
} else {
return ::testing::AssertionFailure() << s_expr << std::endl
<< s.ToString();
return ::testing::AssertionFailure() << s_expr << std::endl << s.ToString();
}
}

Expand Down
13 changes: 6 additions & 7 deletions test_util/testutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ class StringSink : public FSWritableFile {
if (reader_contents_ != nullptr) {
assert(reader_contents_->size() <= last_flush_);
size_t offset = last_flush_ - reader_contents_->size();
*reader_contents_ = Slice(
contents_.data() + offset,
contents_.size() - offset);
*reader_contents_ =
Slice(contents_.data() + offset, contents_.size() - offset);
last_flush_ = contents_.size();
}

Expand All @@ -165,8 +164,8 @@ class StringSink : public FSWritableFile {
void Drop(size_t bytes) {
if (reader_contents_ != nullptr) {
contents_.resize(contents_.size() - bytes);
*reader_contents_ = Slice(
reader_contents_->data(), reader_contents_->size() - bytes);
*reader_contents_ =
Slice(reader_contents_->data(), reader_contents_->size() - bytes);
last_flush_ = contents_.size();
}
}
Expand Down Expand Up @@ -282,7 +281,7 @@ class StringSource : public FSRandomAccessFile {
mmap_(mmap),
total_reads_(0) {}

virtual ~StringSource() { }
virtual ~StringSource() {}

uint64_t Size() const { return contents_.size(); }

Expand Down Expand Up @@ -324,7 +323,7 @@ class StringSource : public FSRandomAccessFile {
char* rid = id;
rid = EncodeVarint64(rid, uniq_id_);
rid = EncodeVarint64(rid, 0);
return static_cast<size_t>(rid-id);
return static_cast<size_t>(rid - id);
}

int total_reads() const { return total_reads_; }
Expand Down
7 changes: 3 additions & 4 deletions test_util/transaction_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#include <string>
#include <thread>

#include "db/dbformat.h"
#include "db/snapshot_impl.h"
#include "logging/logging.h"
#include "rocksdb/db.h"
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/transaction_db.h"

#include "db/dbformat.h"
#include "db/snapshot_impl.h"
#include "logging/logging.h"
#include "util/random.h"
#include "util/string_util.h"

Expand Down
2 changes: 1 addition & 1 deletion test_util/transaction_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#ifndef ROCKSDB_LITE

#include "rocksdb/options.h"
#include "port/port.h"
#include "rocksdb/options.h"
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksdb/utilities/transaction_db.h"

Expand Down

0 comments on commit aca0000

Please sign in to comment.