]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:45:41 +0000 (11:45 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:21:39 +0000 (12:21 +0800)
* add "std::" prefix in headers
* add "using" declarations in .cc files.

so we don't rely on "using namespace std" in one or more included
headers.

Signed-off-by: Kefu Chai <kchai@redhat.com>
14 files changed:
src/test/librbd/cache/pwl/test_WriteLogMap.cc
src/test/librbd/deep_copy/test_mock_ImageCopyRequest.cc
src/test/librbd/journal/test_Entries.cc
src/test/librbd/mirror/snapshot/test_mock_CreatePrimaryRequest.cc
src/test/librbd/mock/MockImageCtx.h
src/test/librbd/test_DeepCopy.cc
src/test/librbd/test_Groups.cc
src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_Migration.cc
src/test/librbd/test_ObjectMap.cc
src/test/librbd/test_internal.cc
src/test/librbd/test_mirroring.cc
src/test/librbd/test_mock_ManagedLock.cc
src/test/librbd/test_mock_Watcher.cc

index 7263d0831ac88f137c9a5006b9e48039fd5f0d47..1cafb00ffe6e32f34e482c2b94d5c05258cb1283 100644 (file)
@@ -13,6 +13,8 @@ namespace librbd {
 namespace cache {
 namespace pwl {
 
+using namespace std;
+
 struct TestLogEntry {
   uint64_t image_offset_bytes;
   uint64_t write_bytes;
index 4fac9ea41dc7408f1ffe31fe5cc04a14ae968ebc..4bcca201f7a93e154182b0fd01f2d27dfcc9bc95 100644 (file)
@@ -116,6 +116,8 @@ DiffRequest<MockTestImageCtx>* DiffRequest<MockTestImageCtx>::s_instance = nullp
 #include "librbd/deep_copy/ImageCopyRequest.cc"
 template class librbd::deep_copy::ImageCopyRequest<librbd::MockTestImageCtx>;
 
+using namespace std::chrono_literals;
+
 namespace librbd {
 namespace deep_copy {
 
index d89c4f8e423d225e2415382e396551fa92a2b3ee..c392fb9f88a88702fd8e0c8bbff2699fa447c751 100644 (file)
@@ -89,6 +89,7 @@ public:
   }
 
   bool wait_for_entries_available(librbd::ImageCtx *ictx) {
+    using namespace std::chrono_literals;
     std::unique_lock locker{m_replay_handler.lock};
     while (!m_replay_handler.entries_available) {
       if (m_replay_handler.cond.wait_for(locker, 10s) == std::cv_status::timeout) {
index 9826bf9b0a410215e77115a7a00cde78a542b185..95b25ffa12f0eba8680ff112dc89d1ed26d5543a 100644 (file)
@@ -347,7 +347,7 @@ TEST_F(TestMockMirrorSnapshotCreatePrimaryRequest, SuccessUnlinkNoPeer) {
   MockUnlinkPeerRequest mock_unlink_peer_request;
   auto it = mock_image_ctx.snap_info.rbegin();
   auto snap_id = it->first;
-  std::list<string> peer_uuids = {"uuid"};
+  std::list<std::string> peer_uuids = {"uuid"};
   expect_unlink_peer(mock_image_ctx, mock_unlink_peer_request, snap_id, "uuid",
                      false, 0);
 
index 525071fbe3ebaee636b5e84179999edd6c33836a..3e1483d2d02f93aac16039406c53492a4298c549 100644 (file)
@@ -170,7 +170,7 @@ struct MockImageCtx {
   MOCK_CONST_METHOD1(get_parent_info, const ParentImageInfo*(librados::snap_t));
   MOCK_CONST_METHOD2(get_parent_overlap, int(librados::snap_t in_snap_id,
                                              uint64_t *overlap));
-  MOCK_CONST_METHOD2(prune_parent_extents, uint64_t(vector<pair<uint64_t,uint64_t> >& ,
+  MOCK_CONST_METHOD2(prune_parent_extents, uint64_t(std::vector<std::pair<uint64_t,uint64_t> >& ,
                                                     uint64_t));
 
   MOCK_CONST_METHOD2(is_snap_protected, int(librados::snap_t in_snap_id,
index 1a512aa292c21eb3cead58529fe9c4a7399697cd..bb6d3f6bf0082323e4a25403efc6f5f5b64aee8b 100644 (file)
@@ -59,7 +59,7 @@ struct TestDeepCopy : public TestFixture {
   }
 
   void compare() {
-    vector<librbd::snap_info_t> src_snaps, dst_snaps;
+    std::vector<librbd::snap_info_t> src_snaps, dst_snaps;
 
     EXPECT_EQ(m_src_ictx->size, m_dst_ictx->size);
     EXPECT_EQ(0, librbd::api::Snapshot<>::list(m_src_ictx, src_snaps));
index 3182d2a2004e23ce7214671ca97ac3dd40daf6d6..29b29e478a55155a66f0f4c8dd925ad38033cb75 100644 (file)
@@ -52,7 +52,7 @@ TEST_F(TestGroup, group_createPP)
   librbd::RBD rbd;
   ASSERT_EQ(0, rbd.group_create(ioctx, "mygroup"));
 
-  vector<string> groups;
+  std::vector<std::string> groups;
   ASSERT_EQ(0, rbd.group_list(ioctx, &groups));
   ASSERT_EQ(1U, groups.size());
   ASSERT_EQ("mygroup", groups[0]);
@@ -172,7 +172,7 @@ TEST_F(TestGroup, add_imagePP)
   ASSERT_TRUE((op_features & RBD_OPERATION_FEATURE_GROUP) ==
                 RBD_OPERATION_FEATURE_GROUP);
 
-  vector<librbd::group_image_info_t> images;
+  std::vector<librbd::group_image_info_t> images;
   ASSERT_EQ(0, rbd.group_image_list(ioctx, group_name, &images,
                                     sizeof(librbd::group_image_info_t)));
   ASSERT_EQ(1U, images.size());
index f02c7b37b814621c4113b4877bb7375220522f20..c8d39645a44cbbb4ebef5796f7aa5158035cbbe1 100644 (file)
@@ -28,6 +28,7 @@
 #include <sstream>
 #include <vector>
 
+using namespace std::chrono_literals;
 using namespace ceph;
 using namespace boost::assign;
 using namespace librbd::watch_notify;
index 959eb0934754b647d98ffe24c97217f62251cafd..8c0f4b61b21914a81ed0ae0b295ce3b5c4cc7c21 100644 (file)
@@ -70,7 +70,7 @@ struct TestMigration : public TestFixture {
   }
 
   void compare(const std::string &description = "") {
-    vector<librbd::snap_info_t> src_snaps, dst_snaps;
+    std::vector<librbd::snap_info_t> src_snaps, dst_snaps;
 
     EXPECT_EQ(m_ref_ictx->size, m_ictx->size);
     EXPECT_EQ(0, librbd::api::Snapshot<>::list(m_ref_ictx, src_snaps));
@@ -489,7 +489,7 @@ struct TestMigration : public TestFixture {
     migration_prepare(m_ioctx, m_image_name);
     migration_status(RBD_IMAGE_MIGRATION_STATE_PREPARED);
 
-    thread user([this]() {
+    std::thread user([this]() {
         test_stress("user", 'a');
         for (int i = 0; i < 5; i++) {
           uint64_t off = (i + 1) * m_ictx->size / 10;
index 61497b2af85717b1d98319138558e2e4e82cd6f0..32d223a1d27378fdc66b67e13cce923e94c3cae6 100644 (file)
@@ -158,6 +158,8 @@ TEST_F(TestObjectMap, AcquireLockInvalidatesWhenTooSmall) {
   ASSERT_TRUE(flags_set);
 }
 
+namespace chrono = std::chrono;
+
 TEST_F(TestObjectMap, DISABLED_StressTest) {
   REQUIRE_FEATURE(RBD_FEATURE_OBJECT_MAP);
 
index 4a793a021b6024356951bb1cc3d50186af78ccce..06423d4f105a157827ed24102080c60d54e78ac6 100644 (file)
@@ -29,6 +29,8 @@
 #include <utility>
 #include <vector>
 
+using namespace std;
+
 void register_test_internal() {
 }
 
index 4fe1d97b9ed32955338a8b65921db18f33f4beb0..4d39ae27e077105c27efc3838d751516e0b11800 100644 (file)
@@ -36,6 +36,8 @@
 #include <utility>
 #include <vector>
 
+using namespace std;
+
 void register_test_mirroring() {
 }
 
index 3e6b15f6112f68afd22aa7dc0b31d901a45c215a..800a8ee7ccb8b326157dfb88d31addf8955378af 100644 (file)
@@ -13,6 +13,8 @@
 #include "gtest/gtest.h"
 #include <list>
 
+using namespace std;
+
 namespace librbd {
 
 struct MockManagedLockImageCtx : public MockImageCtx {
index 97f77574053863d3671239e0e7693023be993d58..54b395b1f0d9b7a15f203decf82432b8fc3f4822 100644 (file)
@@ -118,6 +118,7 @@ public:
   }
 
   bool wait_for_watch(MockImageCtx &mock_image_ctx, size_t count) {
+    using namespace std::chrono_literals;
     std::unique_lock locker{m_lock};
     while (m_watch_count < count) {
       if (m_cond.wait_for(locker, 10s) == std::cv_status::timeout) {