test_rados_api_snapshots_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
bin_DEBUGPROGRAMS += test_rados_api_snapshots
+test_rados_api_cls_SOURCES = test/rados-api/cls.cc test/rados-api/test.cc
+test_rados_api_cls_LDFLAGS = ${AM_LDFLAGS}
+test_rados_api_cls_LDADD = librados.la ${UNITTEST_STATIC_LDADD}
+test_rados_api_cls_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+bin_DEBUGPROGRAMS += test_rados_api_cls
+
test_rados_api_misc_SOURCES = test/rados-api/misc.cc test/rados-api/test.cc
test_rados_api_misc_LDFLAGS = ${AM_LDFLAGS}
test_rados_api_misc_LDADD = librados.la ${UNITTEST_STATIC_LDADD}
cls->name.c_str());
dout(10) << "_load_class " << cls->name << " from " << fname << dendl;
+ struct stat st;
+ int r = ::stat(fname, &st);
+ if (r < 0)
+ return -errno;
+
cls->handle = dlopen(fname, RTLD_NOW);
if (!cls->handle) {
dout(0) << "_load_class could not open class " << fname
ClassHandler::ClassData *cls;
int r = class_handler->open_class(cname, &cls);
- if (r)
+ if (r) {
+ dout(10) << "class " << cname << " open got " << cpp_strerror(r) << dendl;
+ if (r == -ENOENT)
+ r = -EOPNOTSUPP;
+ else
+ r = -EIO;
return r;
+ }
int flags = cls->get_method_flags(mname.c_str());
is_read = flags & CLS_METHOD_RD;
is_write = flags & CLS_METHOD_WR;
--- /dev/null
+#include "include/rados/librados.h"
+#include "include/rados/librados.hpp"
+#include "test/rados-api/test.h"
+
+#include "gtest/gtest.h"
+#include <errno.h>
+#include <map>
+#include <sstream>
+#include <string>
+
+using namespace librados;
+using ceph::buffer;
+using std::map;
+using std::ostringstream;
+using std::string;
+
+TEST(LibRadosCls, DNE) {
+ Rados cluster;
+ std::string pool_name = get_temp_pool_name();
+ ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+ IoCtx ioctx;
+ cluster.ioctx_create(pool_name.c_str(), ioctx);
+
+ // create an object
+ string oid = "foo";
+ bufferlist bl;
+ ASSERT_EQ(0, ioctx.write(oid, bl, bl.length(), 0));
+
+ // call a bogus class
+ ASSERT_EQ(-EOPNOTSUPP, ioctx.exec(oid, "doesnotexistasdfasdf", "method", bl, bl));
+
+ // call a bogus method on existent class
+ ASSERT_EQ(-EOPNOTSUPP, ioctx.exec(oid, "lock", "doesnotexistasdfasdfasdf", bl, bl));
+
+ ioctx.close();
+ ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}