librbd_test_la_SOURCES = \
test/librbd/test_fixture.cc \
+ test/librbd/test_support.cc \
test/librbd/test_librbd.cc \
test/librbd/test_ImageWatcher.cc \
- test/librbd/test_internal.cc \
- test/librbd/test_main.cc
+ test/librbd/test_internal.cc
librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
noinst_LTLIBRARIES += librbd_test.la
-unittest_librbd_SOURCES =
-nodist_EXTRA_unittest_librbd_SOURCES = dummy.cc
+unittest_librbd_SOURCES = \
+ test/librbd/test_main.cc
+unittest_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
unittest_librbd_LDADD = \
librbd_test.la librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
libcls_rbd_client.la libcls_lock_client.la \
check_SCRIPTS += test/run-rbd-valgrind-unit-tests.sh
endif
-ceph_test_librbd_SOURCES =
-nodist_EXTRA_ceph_test_librbd_SOURCES = dummy.cc
+ceph_test_librbd_SOURCES = \
+ test/librbd/test_main.cc
+ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
ceph_test_librbd_LDADD = \
librbd_test.la librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
libcls_rbd_client.la libcls_lock_client.la \
librados_api.la $(LIBRADOS_DEPS) $(UNITTEST_LDADD) \
$(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
-ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS)
bin_DEBUGPROGRAMS += ceph_test_librbd
+ceph_test_librbd_api_SOURCES = \
+ test/librbd/test_support.cc \
+ test/librbd/test_librbd.cc \
+ test/librbd/test_main.cc
+ceph_test_librbd_api_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ceph_test_librbd_api_LDADD = \
+ $(LIBRBD) $(LIBRADOS) $(UNITTEST_LDADD) \
+ $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
+bin_DEBUGPROGRAMS += ceph_test_librbd_api
+
if WITH_LTTNG
unittest_librbd_LDADD += $(LIBRBD_TP)
ceph_test_librbd_LDADD += $(LIBRBD_TP)
+ceph_test_librbd_api_LDADD += $(LIBRBD_TP)
endif
if LINUX
test/librados/TestCase.h \
test/libradosstriper/TestCase.h \
test/librbd/test_fixture.h \
+ test/librbd/test_support.h \
test/ObjectMap/KeyValueDBMemory.h \
test/omap_bench.h \
test/osdc/FakeWriteback.h \
// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
#include "include/int_types.h"
#include "include/stringify.h"
#include "include/rados/librados.h"
// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
#include "include/stringify.h"
#include "cls/lock/cls_lock_client.h"
#include "cls/lock/cls_lock_types.h"
#include <sstream>
#include <stdlib.h>
-bool get_features(uint64_t *features) {
- const char *c = getenv("RBD_FEATURES");
- if (c == NULL) {
- return false;
- }
-
- std::stringstream ss(c);
- if (!(ss >> *features)) {
- return false;
- }
- return true;
-}
-
-bool is_feature_enabled(uint64_t feature) {
- uint64_t features;
- return (get_features(&features) && (features & feature) == feature);
-}
-
-int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
- const std::string &name, uint64_t size) {
- uint64_t features = 0;
- get_features(&features);
- int order = 0;
- return rbd.create2(ioctx, name.c_str(), size, features, &order);
-}
-
std::string TestFixture::_pool_name;
librados::Rados TestFixture::_rados;
uint64_t TestFixture::_image_number = 0;
using namespace ceph;
-bool get_features(uint64_t *features);
-bool is_feature_enabled(uint64_t feature);
-int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
- const std::string &name, uint64_t size);
-
-#define REQUIRE_FEATURE(feature) { \
- if (!is_feature_enabled(feature)) { \
- std::cout << "SKIPPING" << std::endl; \
- return SUCCEED(); \
- } \
-}
-
class TestFixture : public ::testing::Test {
public:
// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
#include "librbd/AioCompletion.h"
#include "librbd/ImageWatcher.h"
#include "librbd/internal.h"
#include "global/global_init.h"
#include "common/ceph_argparse.h"
#include "common/config.h"
+#include "common/Thread.h"
#include "gtest/gtest.h"
#include <vector>
#include "test/librados/test.h"
-#include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
#include "common/errno.h"
#include "include/interval_set.h"
#include "include/stringify.h"
#include "global/global_init.h"
#include <vector>
+extern void register_test_librbd();
+#ifdef TEST_LIBRBD_INTERNALS
extern void register_test_image_watcher();
extern void register_test_internal();
-extern void register_test_librbd();
+#endif // TEST_LIBRBD_INTERNALS
int main(int argc, char **argv)
{
+ register_test_librbd();
+#ifdef TEST_LIBRBD_INTERNALS
register_test_image_watcher();
register_test_internal();
- register_test_librbd();
+#endif // TEST_LIBRBD_INTERNALS
::testing::InitGoogleTest(&argc, argv);
--- /dev/null
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#include "test/librbd/test_support.h"
+#include <sstream>
+
+bool get_features(uint64_t *features) {
+ const char *c = getenv("RBD_FEATURES");
+ if (c == NULL) {
+ return false;
+ }
+
+ std::stringstream ss(c);
+ if (!(ss >> *features)) {
+ return false;
+ }
+ return true;
+}
+
+bool is_feature_enabled(uint64_t feature) {
+ uint64_t features;
+ return (get_features(&features) && (features & feature) == feature);
+}
+
+int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
+ const std::string &name, uint64_t size) {
+ uint64_t features = 0;
+ get_features(&features);
+ int order = 0;
+ return rbd.create2(ioctx, name.c_str(), size, features, &order);
+}
--- /dev/null
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#include "include/int_types.h"
+#include "include/rados/librados.h"
+#include "include/rbd/librbd.hpp"
+#include <string>
+
+bool get_features(uint64_t *features);
+bool is_feature_enabled(uint64_t feature);
+int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
+ const std::string &name, uint64_t size);
+
+#define REQUIRE_FEATURE(feature) { \
+ if (!is_feature_enabled(feature)) { \
+ std::cout << "SKIPPING" << std::endl; \
+ return SUCCEED(); \
+ } \
+}
+