Skip to content

Commit

Permalink
Merge pull request #9602 from tchaikov/wip-ceph_test_cls_hello
Browse files Browse the repository at this point in the history
test: fix ceph_test_cls_hello test

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
tchaikov committed Jun 14, 2016
2 parents 40547be + 64271f0 commit 281e74d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/librados_test_stub/LibradosTestStub.cc
Expand Up @@ -1216,3 +1216,12 @@ int cls_register_cxx_method(cls_handle_t hclass, const char *method,
librados::TestClassHandler *cls = get_class_handler();
return cls->create_method(hclass, method, class_call, handle);
}

int cls_register_cxx_filter(cls_handle_t hclass,
const std::string &filter_name,
cls_cxx_filter_factory_t fn,
cls_filter_handle_t *)
{
librados::TestClassHandler *cls = get_class_handler();
return cls->create_filter(hclass, filter_name, fn);
}
12 changes: 12 additions & 0 deletions src/test/librados_test_stub/TestClassHandler.cc
Expand Up @@ -120,6 +120,18 @@ TestClassHandler::SharedMethodContext TestClassHandler::get_method_context(
return ctx;
}

int TestClassHandler::create_filter(cls_handle_t hclass,
const std::string& name,
cls_cxx_filter_factory_t fn)
{
Class *cls = reinterpret_cast<Class*>(hclass);
if (cls->filters.find(name) != cls->filters.end()) {
return -EEXIST;
}
cls->filters[name] = fn;
return 0;
}

TestClassHandler::MethodContext::~MethodContext() {
io_ctx_impl->put();
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/librados_test_stub/TestClassHandler.h
Expand Up @@ -36,9 +36,11 @@ class TestClassHandler {
};
typedef boost::shared_ptr<Method> SharedMethod;
typedef std::map<std::string, SharedMethod> Methods;
typedef std::map<std::string, cls_cxx_filter_factory_t> Filters;

struct Class {
Methods methods;
Filters filters;
};
typedef boost::shared_ptr<Class> SharedClass;

Expand All @@ -54,13 +56,17 @@ class TestClassHandler {
const std::string &oid,
const SnapContext &snapc);

int create_filter(cls_handle_t hclass, const std::string& filter_name,
cls_cxx_filter_factory_t fn);

private:

typedef std::map<std::string, SharedClass> Classes;
typedef std::list<void*> ClassHandles;

Classes m_classes;
ClassHandles m_class_handles;
Filters m_filters;

void open_class(const std::string& name, const std::string& path);

Expand Down

0 comments on commit 281e74d

Please sign in to comment.