]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: replace std::tr1::shared_ptr with ceph::shared_ptr
authorYan, Zheng <zyan@redhat.com>
Thu, 30 Jul 2015 08:03:56 +0000 (16:03 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 31 Aug 2015 08:00:27 +0000 (16:00 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/test/common/test_shared_cache.cc
src/test/common/test_sharedptr_registry.cc

index f54a2a36a6b5090201c14c1be58567a5639ffb08..09f6fb1dc17a0dfb9ed2d4e6156cb14872d26e2a 100644 (file)
@@ -32,7 +32,7 @@ class SharedLRUTest : public SharedLRU<unsigned int, int> {
 public:
   Mutex &get_lock() { return lock; }
   Cond &get_cond() { return cond; }
-  map<unsigned int, pair< weak_ptr<int>, int* > > &get_weak_refs() {
+  map<unsigned int, pair< ceph::weak_ptr<int>, int* > > &get_weak_refs() {
     return weak_refs;
   }
 };
@@ -45,7 +45,7 @@ public:
     SharedLRUTest &cache;
     unsigned int key;
     int value;
-    shared_ptr<int> ptr;
+    ceph::shared_ptr<int> ptr;
     enum in_method_t { LOOKUP, LOWER_BOUND } in_method;
 
     Thread_wait(SharedLRUTest& _cache, unsigned int _key, 
@@ -61,7 +61,7 @@ public:
         ptr = cache.lower_bound(key);
         break;
       case LOOKUP:
-        ptr = shared_ptr<int>(new int);
+        ptr = ceph::shared_ptr<int>(new int);
         *ptr = value;
         ptr = cache.lookup(key);
         break;
@@ -105,13 +105,13 @@ TEST_F(SharedLRU_all, add) {
   int value1 = 2;
   bool existed = false;
   {
-    shared_ptr<int> ptr = cache.add(key, new int(value1), &existed);
+    ceph::shared_ptr<int> ptr = cache.add(key, new int(value1), &existed);
     ASSERT_EQ(value1, *ptr);
     ASSERT_FALSE(existed);
   }
   {
     int value2 = 3;
-    shared_ptr<int> ptr = cache.add(key, new int(value2), &existed);
+    ceph::shared_ptr<int> ptr = cache.add(key, new int(value2), &existed);
     ASSERT_EQ(value1, *ptr);
     ASSERT_TRUE(existed);
   }
@@ -124,7 +124,7 @@ TEST_F(SharedLRU_all, empty) {
   ASSERT_TRUE(cache.empty());
   {
     int value1 = 2;
-    shared_ptr<int> ptr = cache.add(key, new int(value1), &existed);
+    ceph::shared_ptr<int> ptr = cache.add(key, new int(value1), &existed);
     ASSERT_EQ(value1, *ptr);
     ASSERT_FALSE(existed);
   }
@@ -169,7 +169,7 @@ TEST_F(SharedLRU_all, wait_lookup) {
   int value = 2;
 
   {
-    shared_ptr<int> ptr(new int);
+    ceph::shared_ptr<int> ptr(new int);
     cache.get_weak_refs()[key] = make_pair(ptr, &*ptr);
   }
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
@@ -195,7 +195,7 @@ TEST_F(SharedLRU_all, wait_lookup_or_create) {
   int value = 2;
 
   {
-    shared_ptr<int> ptr(new int);
+    ceph::shared_ptr<int> ptr(new int);
     cache.get_weak_refs()[key] = make_pair(ptr, &*ptr);
   }
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
@@ -240,7 +240,7 @@ TEST_F(SharedLRU_all, wait_lower_bound) {
   ASSERT_TRUE(cache.add(other_key, new int(other_value)).get());
 
   {
-    shared_ptr<int> ptr(new int);
+    ceph::shared_ptr<int> ptr(new int);
     cache.get_weak_refs()[key] = make_pair(ptr, &*ptr);
   }
   EXPECT_FALSE(cache.get_weak_refs()[key].first.lock());
@@ -272,15 +272,15 @@ TEST_F(SharedLRU_all, get_next) {
     SharedLRUTest cache;
 
     const unsigned int key2 = 333;
-    shared_ptr<int> ptr2 = cache.lookup_or_create(key2);
+    ceph::shared_ptr<int> ptr2 = cache.lookup_or_create(key2);
     const int value2 = *ptr2 = 400;
 
     // entries with expired pointers are silently ignored
     const unsigned int key_gone = 222;
-    cache.get_weak_refs()[key_gone] = make_pair(shared_ptr<int>(), (int*)0);
+    cache.get_weak_refs()[key_gone] = make_pair(ceph::shared_ptr<int>(), (int*)0);
 
     const unsigned int key1 = 111;
-    shared_ptr<int> ptr1 = cache.lookup_or_create(key1);
+    ceph::shared_ptr<int> ptr1 = cache.lookup_or_create(key1);
     const int value1 = *ptr1 = 800;
 
     pair<unsigned int, int> i;
@@ -299,11 +299,11 @@ TEST_F(SharedLRU_all, get_next) {
   {
     SharedLRUTest cache;
     const unsigned int key1 = 111;
-    shared_ptr<int> *ptr1 = new shared_ptr<int>(cache.lookup_or_create(key1));
+    ceph::shared_ptr<int> *ptr1 = new shared_ptr<int>(cache.lookup_or_create(key1));
     const unsigned int key2 = 222;
-    shared_ptr<int> ptr2 = cache.lookup_or_create(key2);
+    ceph::shared_ptr<int> ptr2 = cache.lookup_or_create(key2);
 
-    pair<unsigned int, shared_ptr<int> > i;
+    pair<unsigned int, ceph::shared_ptr<int> > i;
     EXPECT_TRUE(cache.get_next(i.first, &i));
     EXPECT_EQ(key1, i.first);
     delete ptr1;
@@ -354,7 +354,7 @@ TEST(SharedCache_all, add) {
   SharedLRU<int, int> cache;
   unsigned int key = 1;
   int value = 2;
-  shared_ptr<int> ptr = cache.add(key, new int(value));
+  ceph::shared_ptr<int> ptr = cache.add(key, new int(value));
   ASSERT_EQ(ptr, cache.lookup(key));
   ASSERT_EQ(value, *cache.lookup(key));
 }
@@ -364,11 +364,11 @@ TEST(SharedCache_all, lru) {
   SharedLRU<int, int> cache(NULL, SIZE);
 
   bool existed = false;
-  shared_ptr<int> ptr = cache.add(0, new int(0), &existed);
+  ceph::shared_ptr<int> ptr = cache.add(0, new int(0), &existed);
   ASSERT_FALSE(existed);
   {
     int *tmpint = new int(0);
-    shared_ptr<int> ptr2 = cache.add(0, tmpint, &existed);
+    ceph::shared_ptr<int> ptr2 = cache.add(0, tmpint, &existed);
     ASSERT_TRUE(existed);
     delete tmpint;
   }
@@ -387,9 +387,9 @@ TEST(SharedCache_all, lru) {
 
   cache.purge(0);
   ASSERT_FALSE(cache.lookup(0));
-  shared_ptr<int> ptr2 = cache.add(0, new int(0), &existed);
+  ceph::shared_ptr<int> ptr2 = cache.add(0, new int(0), &existed);
   ASSERT_FALSE(ptr == ptr2);
-  ptr = shared_ptr<int>();
+  ptr = ceph::shared_ptr<int>();
   ASSERT_TRUE(cache.lookup(0).get());
 }
 
index 7b06b7e163f6dd33fd243510a8acbc919b550003..42bc8e607acac8ffadab46c8549a3957356acaf7 100644 (file)
@@ -30,7 +30,7 @@
 class SharedPtrRegistryTest : public SharedPtrRegistry<unsigned int, int> {
 public:
   Mutex &get_lock() { return lock; }
-  map<unsigned int, pair<weak_ptr<int>, int*> > &get_contents() {
+  map<unsigned int, pair<ceph::weak_ptr<int>, int*> > &get_contents() {
     return contents;
   }
 };
@@ -43,7 +43,7 @@ public:
     SharedPtrRegistryTest &registry;
     unsigned int key;
     int value;
-    shared_ptr<int> ptr;
+    ceph::shared_ptr<int> ptr;
     enum in_method_t { LOOKUP, LOOKUP_OR_CREATE } in_method;
 
     Thread_wait(SharedPtrRegistryTest& _registry, unsigned int _key, int _value, in_method_t _in_method) : 
@@ -63,7 +63,7 @@ public:
          ptr = registry.lookup_or_create(key);
        break;
       case LOOKUP:
-       ptr = shared_ptr<int>(new int);
+       ptr = ceph::shared_ptr<int>(new int);
        *ptr = value;
        ptr = registry.lookup(key);
        break;
@@ -103,7 +103,7 @@ TEST_F(SharedPtrRegistry_all, lookup_or_create) {
   SharedPtrRegistryTest registry;
   unsigned int key = 1;
   int value = 2;
-  shared_ptr<int> ptr = registry.lookup_or_create(key);
+  ceph::shared_ptr<int> ptr = registry.lookup_or_create(key);
   *ptr = value;
   ASSERT_EQ(value, *registry.lookup_or_create(key));
 }
@@ -124,7 +124,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
   {
     unsigned int key = 1;
     {
-      shared_ptr<int> ptr(new int);
+      ceph::shared_ptr<int> ptr(new int);
       registry.get_contents()[key] = make_pair(ptr, ptr.get());
     }
     EXPECT_FALSE(registry.get_contents()[key].first.lock());
@@ -144,7 +144,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
     unsigned int key = 2;
     int value = 3;
     {
-      shared_ptr<int> ptr(new int);
+      ceph::shared_ptr<int> ptr(new int);
       registry.get_contents()[key] = make_pair(ptr, ptr.get());
     }
     EXPECT_FALSE(registry.get_contents()[key].first.lock());
@@ -157,7 +157,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup_or_create) {
     {
       int other_value = value + 1;
       unsigned int other_key = key + 1;
-      shared_ptr<int> ptr = registry.lookup_or_create<int>(other_key, other_value);
+      ceph::shared_ptr<int> ptr = registry.lookup_or_create<int>(other_key, other_value);
       EXPECT_TRUE(ptr.get());
       EXPECT_EQ(other_value, *ptr);
     }
@@ -173,7 +173,7 @@ TEST_F(SharedPtrRegistry_all, lookup) {
   SharedPtrRegistryTest registry;
   unsigned int key = 1;
   {
-    shared_ptr<int> ptr = registry.lookup_or_create(key);
+    ceph::shared_ptr<int> ptr = registry.lookup_or_create(key);
     int value = 2;
     *ptr = value;
     ASSERT_EQ(value, *registry.lookup(key));
@@ -187,7 +187,7 @@ TEST_F(SharedPtrRegistry_all, wait_lookup) {
   unsigned int key = 1;
   int value = 2;
   {
-    shared_ptr<int> ptr(new int);
+    ceph::shared_ptr<int> ptr(new int);
     registry.get_contents()[key] = make_pair(ptr, ptr.get());
   }
   EXPECT_FALSE(registry.get_contents()[key].first.lock());
@@ -216,15 +216,15 @@ TEST_F(SharedPtrRegistry_all, get_next) {
     SharedPtrRegistryTest registry;
 
     const unsigned int key2 = 333;
-    shared_ptr<int> ptr2 = registry.lookup_or_create(key2);
+    ceph::shared_ptr<int> ptr2 = registry.lookup_or_create(key2);
     const int value2 = *ptr2 = 400;
 
     // entries with expired pointers are silentely ignored
     const unsigned int key_gone = 222;
-    registry.get_contents()[key_gone] = make_pair(shared_ptr<int>(), (int*)0);
+    registry.get_contents()[key_gone] = make_pair(ceph::shared_ptr<int>(), (int*)0);
 
     const unsigned int key1 = 111;
-    shared_ptr<int> ptr1 = registry.lookup_or_create(key1);
+    ceph::shared_ptr<int> ptr1 = registry.lookup_or_create(key1);
     const int value1 = *ptr1 = 800;
 
     pair<unsigned int, int> i;
@@ -245,11 +245,11 @@ TEST_F(SharedPtrRegistry_all, get_next) {
     //
     SharedPtrRegistryTest registry;
     const unsigned int key1 = 111;
-    shared_ptr<int> *ptr1 = new shared_ptr<int>(registry.lookup_or_create(key1));
+    ceph::shared_ptr<int> *ptr1 = new ceph::shared_ptr<int>(registry.lookup_or_create(key1));
     const unsigned int key2 = 222;
-    shared_ptr<int> ptr2 = registry.lookup_or_create(key2);
+    ceph::shared_ptr<int> ptr2 = registry.lookup_or_create(key2);
     
-    pair<unsigned int, shared_ptr<int> > i;
+    pair<unsigned int, ceph::shared_ptr<int> > i;
     EXPECT_TRUE(registry.get_next(i.first, &i));
     EXPECT_EQ(key1, i.first);
     delete ptr1;
@@ -262,15 +262,15 @@ TEST_F(SharedPtrRegistry_all, remove) {
   {
     SharedPtrRegistryTest registry;
     const unsigned int key1 = 1;
-    shared_ptr<int> ptr1 = registry.lookup_or_create(key1);
+    ceph::shared_ptr<int> ptr1 = registry.lookup_or_create(key1);
     *ptr1 = 400;
     registry.remove(key1);
 
-    shared_ptr<int> ptr2 = registry.lookup_or_create(key1);
+    ceph::shared_ptr<int> ptr2 = registry.lookup_or_create(key1);
     *ptr2 = 500;
 
-    ptr1 = shared_ptr<int>();
-    shared_ptr<int> res = registry.lookup(key1);
+    ptr1 = ceph::shared_ptr<int>();
+    ceph::shared_ptr<int> res = registry.lookup(key1);
     assert(res);
     assert(res == ptr2);
     assert(*res == 500);
@@ -278,13 +278,13 @@ TEST_F(SharedPtrRegistry_all, remove) {
   {
     SharedPtrRegistryTest registry;
     const unsigned int key1 = 1;
-    shared_ptr<int> ptr1 = registry.lookup_or_create(key1, 400);
+    ceph::shared_ptr<int> ptr1 = registry.lookup_or_create(key1, 400);
     registry.remove(key1);
 
-    shared_ptr<int> ptr2 = registry.lookup_or_create(key1, 500);
+    ceph::shared_ptr<int> ptr2 = registry.lookup_or_create(key1, 500);
 
-    ptr1 = shared_ptr<int>();
-    shared_ptr<int> res = registry.lookup(key1);
+    ptr1 = ceph::shared_ptr<int>();
+    ceph::shared_ptr<int> res = registry.lookup(key1);
     assert(res);
     assert(res == ptr2);
     assert(*res == 500);
@@ -316,7 +316,7 @@ TEST_F(SharedPtrRegistry_destructor, destructor) {
   EXPECT_EQ(UNDEFINED, died);
   int key = 101;
   {
-    shared_ptr<TellDie> a = registry.lookup_or_create(key);
+    ceph::shared_ptr<TellDie> a = registry.lookup_or_create(key);
     EXPECT_EQ(NO, died);
     EXPECT_TRUE(a.get());
   }