]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: fix valgrind errors with librbd unit test
authorJason Dillaman <dillaman@redhat.com>
Fri, 24 Apr 2015 03:10:23 +0000 (23:10 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 17 Jul 2015 18:17:04 +0000 (14:17 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit ed5472a10eb515e2a177a640c3f6ed929db9ee4f)

src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc

index 0721ed2dd7ecc2e04f66a1c3d2b5f2b701f99818..93daeadbdf477c54fb22ce80cc75e2fd7a5f07aa 100644 (file)
@@ -256,6 +256,9 @@ TEST_F(TestInternal, AioWriteRequestsLock) {
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
   ASSERT_FALSE(is_owner);
   ASSERT_FALSE(c->is_complete());
+
+  unlock_image();
+  ASSERT_EQ(0, c->wait_for_complete());
   c->put();
 }
 
@@ -276,6 +279,9 @@ TEST_F(TestInternal, AioDiscardRequestsLock) {
   ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner));
   ASSERT_FALSE(is_owner);
   ASSERT_FALSE(c->is_complete());
+
+  unlock_image();
+  ASSERT_EQ(0, c->wait_for_complete());
   c->put();
 }
 
index 3ae9112e76ef18a12c189ee23deca0949203538e..b4ad6ca851d2eaf4ee8c4f4a9420ade2ebb6430e 100644 (file)
@@ -137,10 +137,12 @@ public:
     _unique_pool_names.clear();
     _image_number = 0;
     ASSERT_EQ("", connect_cluster(&_cluster));
+    ASSERT_EQ("", connect_cluster_pp(_rados));
   }
 
   static void TearDownTestCase() {
     rados_shutdown(_cluster);
+    _rados.wait_for_latest_osdmap();
     _pool_names.insert(_pool_names.end(), _unique_pool_names.begin(),
                       _unique_pool_names.end());
     for (size_t i = 1; i < _pool_names.size(); ++i) {
@@ -173,16 +175,17 @@ public:
   }
 
   std::string create_pool(bool unique = false) {
+    librados::Rados rados;
     std::string pool_name;
     if (unique) {
       pool_name = get_temp_pool_name();
-      EXPECT_EQ("", create_one_pool_pp(pool_name, _rados));
+      EXPECT_EQ("", create_one_pool_pp(pool_name, rados));
       _unique_pool_names.push_back(pool_name);
     } else if (m_pool_number < _pool_names.size()) {
       pool_name = _pool_names[m_pool_number];
     } else {
       pool_name = get_temp_pool_name();
-      EXPECT_EQ("", create_one_pool_pp(pool_name, _rados));
+      EXPECT_EQ("", create_one_pool_pp(pool_name, rados));
       _pool_names.push_back(pool_name);
     }
     ++m_pool_number;
@@ -1122,6 +1125,7 @@ TEST_F(TestLibRBD, TestIOPPWithIOHint)
     ASSERT_EQ(0, rbd.open(ioctx, image, name.c_str(), NULL));
 
     char test_data[TEST_IO_SIZE + 1];
+    test_data[TEST_IO_SIZE] = '\0';
     int i;
 
     for (i = 0; i < TEST_IO_SIZE; ++i) {
@@ -1954,14 +1958,15 @@ TEST_F(TestLibRBD, FlushAioPP)
     for (i = 0; i < TEST_IO_SIZE; ++i) {
       test_data[i] = (char) (rand() % (126 - 33) + 33);
     }
+    test_data[TEST_IO_SIZE] = '\0';
 
     librbd::RBD::AioCompletion *write_comps[num_aios];
+    ceph::bufferlist bls[num_aios];
     for (i = 0; i < num_aios; ++i) {
-      ceph::bufferlist bl;
-      bl.append(test_data, strlen(test_data));
+      bls[i].append(test_data, strlen(test_data));
       write_comps[i] = new librbd::RBD::AioCompletion(NULL, NULL);
       uint64_t offset = rand() % (size - TEST_IO_SIZE);
-      ASSERT_EQ(0, image.aio_write(offset, TEST_IO_SIZE, bl,
+      ASSERT_EQ(0, image.aio_write(offset, TEST_IO_SIZE, bls[i],
                                   write_comps[i]));
     }