]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
2 | // This source code is licensed under both the GPLv2 (found in the |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
7c673cae | 5 | |
f67539c2 | 6 | #include "test_util/sync_point.h" |
20effc67 TL |
7 | |
8 | #include <fcntl.h> | |
9 | ||
f67539c2 | 10 | #include "test_util/sync_point_impl.h" |
7c673cae | 11 | |
20effc67 | 12 | std::vector<std::string> rocksdb_kill_exclude_prefixes; |
7c673cae FG |
13 | |
14 | #ifndef NDEBUG | |
f67539c2 | 15 | namespace ROCKSDB_NAMESPACE { |
7c673cae | 16 | |
7c673cae FG |
17 | SyncPoint* SyncPoint::GetInstance() { |
18 | static SyncPoint sync_point; | |
19 | return &sync_point; | |
20 | } | |
21 | ||
494da23a | 22 | SyncPoint::SyncPoint() : impl_(new Data) {} |
11fdf7f2 | 23 | |
1e59de90 | 24 | SyncPoint::~SyncPoint() { delete impl_; } |
11fdf7f2 | 25 | |
7c673cae | 26 | void SyncPoint::LoadDependency(const std::vector<SyncPointPair>& dependencies) { |
11fdf7f2 | 27 | impl_->LoadDependency(dependencies); |
7c673cae FG |
28 | } |
29 | ||
30 | void SyncPoint::LoadDependencyAndMarkers( | |
1e59de90 TL |
31 | const std::vector<SyncPointPair>& dependencies, |
32 | const std::vector<SyncPointPair>& markers) { | |
11fdf7f2 | 33 | impl_->LoadDependencyAndMarkers(dependencies, markers); |
7c673cae FG |
34 | } |
35 | ||
11fdf7f2 | 36 | void SyncPoint::SetCallBack(const std::string& point, |
1e59de90 | 37 | const std::function<void(void*)>& callback) { |
11fdf7f2 | 38 | impl_->SetCallBack(point, callback); |
7c673cae FG |
39 | } |
40 | ||
11fdf7f2 TL |
41 | void SyncPoint::ClearCallBack(const std::string& point) { |
42 | impl_->ClearCallBack(point); | |
7c673cae FG |
43 | } |
44 | ||
1e59de90 | 45 | void SyncPoint::ClearAllCallBacks() { impl_->ClearAllCallBacks(); } |
7c673cae | 46 | |
1e59de90 | 47 | void SyncPoint::EnableProcessing() { impl_->EnableProcessing(); } |
7c673cae | 48 | |
1e59de90 | 49 | void SyncPoint::DisableProcessing() { impl_->DisableProcessing(); } |
7c673cae | 50 | |
1e59de90 | 51 | void SyncPoint::ClearTrace() { impl_->ClearTrace(); } |
7c673cae | 52 | |
1e59de90 | 53 | void SyncPoint::Process(const Slice& point, void* cb_arg) { |
11fdf7f2 | 54 | impl_->Process(point, cb_arg); |
7c673cae | 55 | } |
11fdf7f2 | 56 | |
f67539c2 | 57 | } // namespace ROCKSDB_NAMESPACE |
7c673cae | 58 | #endif // NDEBUG |
20effc67 TL |
59 | |
60 | namespace ROCKSDB_NAMESPACE { | |
61 | void SetupSyncPointsToMockDirectIO() { | |
62 | #if !defined(NDEBUG) && !defined(OS_MACOSX) && !defined(OS_WIN) && \ | |
63 | !defined(OS_SOLARIS) && !defined(OS_AIX) && !defined(OS_OPENBSD) | |
64 | ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( | |
65 | "NewWritableFile:O_DIRECT", [&](void* arg) { | |
66 | int* val = static_cast<int*>(arg); | |
67 | *val &= ~O_DIRECT; | |
68 | }); | |
69 | ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( | |
70 | "NewRandomAccessFile:O_DIRECT", [&](void* arg) { | |
71 | int* val = static_cast<int*>(arg); | |
72 | *val &= ~O_DIRECT; | |
73 | }); | |
74 | ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( | |
75 | "NewSequentialFile:O_DIRECT", [&](void* arg) { | |
76 | int* val = static_cast<int*>(arg); | |
77 | *val &= ~O_DIRECT; | |
78 | }); | |
79 | ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); | |
80 | #endif | |
81 | } | |
82 | } // namespace ROCKSDB_NAMESPACE |