]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/objectstore/store_test_fixture.h
40e62778cdb5c665ad27939b53128c0a5b458cd4
[ceph.git] / ceph / src / test / objectstore / store_test_fixture.h
1 #include <string>
2 #include <stack>
3 #include <boost/scoped_ptr.hpp>
4 #include <gtest/gtest.h>
5 #include "common/config_fwd.h"
6
7 class ObjectStore;
8
9 class StoreTestFixture : virtual public ::testing::Test {
10 const std::string type;
11 const std::string data_dir;
12
13 std::stack<std::pair<std::string, std::string>> saved_settings;
14 ConfigProxy* conf = nullptr;
15
16 std::string orig_death_test_style;
17
18 public:
19 boost::scoped_ptr<ObjectStore> store;
20 ObjectStore::CollectionHandle ch;
21
22 explicit StoreTestFixture(const std::string& type)
23 : type(type), data_dir(type + ".test_temp_dir")
24 {}
25
26 void SetUp() override;
27 void TearDown() override;
28 void SetDeathTestStyle(const char* new_style) {
29 if (orig_death_test_style.empty()) {
30 orig_death_test_style = ::testing::FLAGS_gtest_death_test_style;
31 }
32 ::testing::FLAGS_gtest_death_test_style = new_style;
33 }
34
35 void SetVal(ConfigProxy& conf, const char* key, const char* val);
36 struct SettingsBookmark {
37 StoreTestFixture& s;
38 size_t pos;
39
40 SettingsBookmark(StoreTestFixture& _s, size_t p) : s(_s), pos(p)
41 {}
42
43 ~SettingsBookmark() {
44 s.PopSettings(pos);
45 }
46 };
47 SettingsBookmark BookmarkSettings() {
48 return SettingsBookmark(*this, saved_settings.size());
49 }
50 void PopSettings(size_t);
51 };