#include <gtest/gtest.h>
#include "include/unordered_map.h"
+#include "store_test_fixture.h"
+
typedef boost::mt11213b gen_type;
#if GTEST_HAS_PARAM_TEST
}
}
-class StoreTest : public ::testing::TestWithParam<const char*> {
-public:
- boost::scoped_ptr<ObjectStore> store;
-
- StoreTest() : store(0) {}
-
- void rm_r(string path) {
- string cmd = string("rm -r ") + path;
- cout << "==> " << cmd << std::endl;
- int r = ::system(cmd.c_str());
- if (r) {
- cerr << "failed with exit code " << r
- << ", continuing anyway" << std::endl;
- }
- }
-
- virtual void SetUp() {
- int r = ::mkdir("store_test_temp_dir", 0777);
- if (r < 0) {
- r = -errno;
- cerr << __func__ << ": unable to create store_test_temp_dir" << ": " << cpp_strerror(r) << std::endl;
- return;
- }
-
- ObjectStore *store_ = ObjectStore::create(g_ceph_context,
- string(GetParam()),
- string("store_test_temp_dir"),
- string("store_test_temp_journal"));
- if (!store_) {
- cerr << __func__ << ": objectstore type " << string(GetParam()) << " doesn't exist yet!" << std::endl;
- return;
- }
- EXPECT_EQ(store_->mkfs(), 0);
- EXPECT_EQ(store_->mount(), 0);
- store.reset(store_);
- }
-
- virtual void TearDown() {
- if (store) {
- int r = store->umount();
- EXPECT_EQ(r, 0);
- rm_r("store_test_temp_dir");
- }
- }
-};
bool sorted(const vector<ghobject_t> &in, bool bitwise) {
ghobject_t start;
return true;
}
+class StoreTest : public StoreTestFixture,
+ public ::testing::WithParamInterface<const char*> {
+public:
+ StoreTest()
+ : StoreTestFixture(GetParam())
+ {}
+};
+
TEST_P(StoreTest, collect_metadata) {
map<string,string> pm;
store->collect_metadata(&pm);
--- /dev/null
+#include <stdlib.h>
+#include <string>
+#include <iostream>
+#include <gtest/gtest.h>
+
+#include "common/errno.h"
+#include "os/ObjectStore.h"
+#include "store_test_fixture.h"
+
+static void rm_r(const string& path) {
+ string cmd = string("rm -r ") + path;
+ cout << "==> " << cmd << std::endl;
+ int r = ::system(cmd.c_str());
+ if (r) {
+ cerr << "failed with exit code " << r
+ << ", continuing anyway" << std::endl;
+ }
+}
+
+void StoreTestFixture::SetUp() {
+ int r = ::mkdir(data_dir.c_str(), 0777);
+ if (r < 0) {
+ r = -errno;
+ cerr << __func__ << ": unable to create " << data_dir << ": " << cpp_strerror(r) << std::endl;
+ return;
+ }
+
+ store.reset(ObjectStore::create(g_ceph_context,
+ type,
+ data_dir,
+ string("store_test_temp_journal")));
+ if (!store) {
+ cerr << __func__ << ": objectstore type " << type << " doesn't exist yet!" << std::endl;
+ return;
+ }
+ EXPECT_EQ(0, store->mkfs());
+ EXPECT_EQ(0, store->mount());
+}
+
+void StoreTestFixture::TearDown() {
+ if (store) {
+ int r = store->umount();
+ EXPECT_EQ(0, r);
+ rm_r(data_dir);
+ }
+}
--- /dev/null
+#include <string>
+#include <boost/scoped_ptr.hpp>
+#include <gtest/gtest.h>
+
+class ObjectStore;
+
+class StoreTestFixture : public ::testing::Test {
+ const std::string type;
+ const std::string data_dir;
+
+public:
+ boost::scoped_ptr<ObjectStore> store;
+
+ StoreTestFixture(const std::string& type)
+ : type(type), data_dir(type + ".test_temp_dir")
+ {}
+ void SetUp() override;
+ void TearDown() override;
+};