]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: create unittest_librbd 3164/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 11 Dec 2014 17:53:59 +0000 (12:53 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 13 Jan 2015 09:49:33 +0000 (04:49 -0500)
The existing ceph_test_librbd integration tests are now used
within unittest_librbd as unit tests run during 'make check'.
The unit tests use librados_test_stub to simulate RADOS.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/Makefile.am
src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc
src/test/librbd/test_main.cc [new file with mode: 0644]

index 8e61a0e8bf988b5238195b5511248e762e27c405..430678ebe6590c36830b661191571c3b323bd0e2 100644 (file)
@@ -747,20 +747,37 @@ noinst_HEADERS += \
        test/librados_test_stub/TestIoCtxImpl.h
 noinst_LTLIBRARIES += librados_test_stub.la
 
-ceph_test_librbd_SOURCES = \
+librbd_test_la_SOURCES = \
        test/librbd/test_fixture.cc \
        test/librbd/test_librbd.cc \
        test/librbd/test_ImageWatcher.cc \
-       test/librbd/test_internal.cc
-ceph_test_librbd_LDADD = \
-       librbd_api.la librbd_internal.la \
+       test/librbd/test_internal.cc \
+       test/librbd/test_main.cc
+librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+noinst_LTLIBRARIES += librbd_test.la
+
+unittest_librbd_SOURCES =
+nodist_EXTRA_unittest_librbd_SOURCES = dummy.cc
+unittest_librbd_LDADD = \
+       librbd_test.la librbd_api.la librbd_internal.la \
        libcls_rbd_client.la libcls_lock_client.la \
+       librados_test_stub.la librados_internal.la \
+       $(LIBOSDC) $(UNITTEST_LDADD) \
+       $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
+check_PROGRAMS += unittest_librbd
+
+ceph_test_librbd_SOURCES =
+nodist_EXTRA_ceph_test_librbd_SOURCES = dummy.cc
+ceph_test_librbd_LDADD = \
+       librbd_test.la librbd_api.la librbd_internal.la \
+        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
 
 if WITH_LTTNG
+unittest_librbd_LDADD += $(LIBRBD_TP)
 ceph_test_librbd_LDADD += $(LIBRBD_TP)
 endif
 
index 2b8b945bdab732886eff26648a2ad7f229a9f807..7b87c55e64ede6eaa2d2e037f81f0a2fd320633d 100644 (file)
@@ -26,6 +26,9 @@
 
 using namespace ceph;
 
+void register_test_image_watcher() {
+}
+
 class TestImageWatcher : public TestFixture {
 public:
 
@@ -342,14 +345,17 @@ TEST_F(TestImageWatcher, UnlockNotifyReleaseLock) {
 
   ASSERT_EQ(0, register_image_watch(*ictx));
   m_notify_acks = boost::assign::list_of(
-    std::make_pair(NOTIFY_OP_ACQUIRED_LOCK, bufferlist()))(
-    std::make_pair(NOTIFY_OP_RELEASED_LOCK, bufferlist()));
+    std::make_pair(NOTIFY_OP_ACQUIRED_LOCK, bufferlist()));
 
   RWLock::WLocker l(ictx->owner_lock);
   ASSERT_EQ(0, ictx->image_watcher->try_lock());
-  ASSERT_EQ(0, ictx->image_watcher->unlock());
+  ASSERT_TRUE(wait_for_notifies(*ictx));
 
+  m_notify_acks = boost::assign::list_of(
+    std::make_pair(NOTIFY_OP_RELEASED_LOCK, bufferlist()));
+  ASSERT_EQ(0, ictx->image_watcher->unlock());
   ASSERT_TRUE(wait_for_notifies(*ictx));
+
   ASSERT_TRUE(m_notify_acks.empty());
   NotifyOpPayloads expected_notify_ops = boost::assign::list_of(
     std::make_pair(NOTIFY_OP_ACQUIRED_LOCK, bufferlist()))(
index 0bd747f443e36c088038d216fdd64f0df7b1a5fd..4c004b868f2edee0ec339f3f7e6c46f9da094361 100644 (file)
@@ -7,6 +7,9 @@
 #include <utility>
 #include <vector>
 
+void register_test_internal() {
+}
+
 class TestInternal : public TestFixture {
 public:
 
index afe4988f67f4976b755a0d493e88bd27391f0ed1..71648726bd5a6bc087fc13aa6358f6cda934110c 100644 (file)
@@ -54,6 +54,9 @@ using namespace std;
     ASSERT_TRUE(passed);          \
   } while(0)
 
+void register_test_librbd() {
+}
+
 static int get_features(bool *old_format, uint64_t *features)
 {
   const char *c = getenv("RBD_FEATURES");
@@ -2243,16 +2246,3 @@ TEST_F(TestLibRBD, TestPendingAio)
 
   rados_ioctx_destroy(ioctx);
 }
-
-int main(int argc, char **argv)
-{
-  ::testing::InitGoogleTest(&argc, argv);
-
-  vector<const char*> args;
-  argv_to_vec(argc, (const char **)argv, args);
-
-  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
-  common_init_finish(g_ceph_context);
-
-  return RUN_ALL_TESTS();
-}
diff --git a/src/test/librbd/test_main.cc b/src/test/librbd/test_main.cc
new file mode 100644 (file)
index 0000000..4b72eb4
--- /dev/null
@@ -0,0 +1,29 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "gtest/gtest.h"
+#include "common/ceph_argparse.h"
+#include "global/global_context.h"
+#include "global/global_init.h"
+#include <vector>
+
+extern void register_test_image_watcher();
+extern void register_test_internal();
+extern void register_test_librbd();
+
+int main(int argc, char **argv)
+{
+  register_test_image_watcher();
+  register_test_internal();
+  register_test_librbd();
+
+  ::testing::InitGoogleTest(&argc, argv);
+
+  vector<const char*> args;
+  argv_to_vec(argc, (const char **)argv, args);
+
+  global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
+  common_init_finish(g_ceph_context);
+
+  return RUN_ALL_TESTS();
+}