]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: kill unittest_? mempools
authorSage Weil <sage@redhat.com>
Fri, 5 May 2017 19:48:46 +0000 (15:48 -0400)
committerSage Weil <sage@redhat.com>
Wed, 31 May 2017 18:47:28 +0000 (14:47 -0400)
These were just annoying.  Use some real ones that will be empty
for the unit tests.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/mempool.h
src/test/test_mempool.cc

index b995905b545840f8cf0b8143cf0c2d85985556d5..016b76b9c66ef7ba10473dc3a7553599012cbff6 100644 (file)
@@ -62,15 +62,15 @@ automatically created (name is same as in DEFINE_MEMORY_POOLS_HELPER).
 That namespace contains a set of common STL containers that are predefined
 with the appropriate allocators.
 
-Thus for mempool "unittest_1" we have automatically available to us:
+Thus for mempool "osd" we have automatically available to us:
 
-   mempool::unittest_1::map
-   mempool::unittest_1::multimap
-   mempool::unittest_1::set
-   mempool::unittest_1::multiset
-   mempool::unittest_1::list
-   mempool::unittest_1::vector
-   mempool::unittest_1::unordered_map
+   mempool::osd::map
+   mempool::osd::multimap
+   mempool::osd::set
+   mempool::osd::multiset
+   mempool::osd::list
+   mempool::osd::vector
+   mempool::osd::unordered_map
 
 
 Putting objects in a mempool
@@ -88,7 +88,7 @@ For a class:
 
 Then, in an appropriate .cc file,
 
-  MEMPOOL_DEFINE_OBJECT_FACTORY(Foo, foo, unittest_1);
+  MEMPOOL_DEFINE_OBJECT_FACTORY(Foo, foo, osd);
 
 The second argument can generally be identical to the first, except
 when the type contains a nested scope.  For example, for
@@ -103,7 +103,7 @@ can't use :: in a variable name.)
 In order to use the STL containers, simply use the namespaced variant
 of the container type.  For example,
 
-  mempool::unittest_1::map<int> myvec;
+  mempool::osd::map<int> myvec;
 
 Introspection
 -------------
@@ -146,9 +146,7 @@ namespace mempool {
   f(buffer_data)                     \
   f(osd)                             \
   f(osdmap)                          \
-  f(osdmap_mapping)                  \
-  f(unittest_1)                              \
-  f(unittest_2)
+  f(osdmap_mapping)
 
 
 // give them integer ids
index e2a8895c3b6afbf72b7f94a9bb1189bb8ec29b92..3be6f02d171eab1f38ed7ea8df1306c6c9f31162 100644 (file)
@@ -86,32 +86,32 @@ void do_insert_key(A& a, B& b, int count, int base)
   for (int i = 0; i < count; ++i) {
     a.insert(make_pair(base+i,base+i));
     b.insert(make_pair(base+i,base+i));
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
   }
 }
 
 TEST(mempool, vector_context)
 {
-  check_usage(mempool::unittest_1::id);
-  EXPECT_EQ(mempool::unittest_1::allocated_bytes(), 0u);
-  EXPECT_EQ(mempool::unittest_1::allocated_items(), 0u);
+  check_usage(mempool::osd::id);
+  EXPECT_EQ(mempool::osd::allocated_bytes(), 0u);
+  EXPECT_EQ(mempool::osd::allocated_items(), 0u);
   for (unsigned i = 0; i < 10; ++i) {
     vector<int> a;
-    mempool::unittest_1::vector<int> b,c;
+    mempool::osd::vector<int> b,c;
     eq_elements(a,b);
     do_push_back(a,b,i,i);
     eq_elements(a,b);
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
 
     mempool::stats_t total;
     map<std::string,mempool::stats_t> by_type;
-    mempool::get_pool(mempool::unittest_1::id).get_stats(&total, &by_type);
-    EXPECT_GE(mempool::unittest_1::allocated_bytes(), i * 4u);
-    EXPECT_GE(mempool::unittest_1::allocated_items(), i);
+    mempool::get_pool(mempool::osd::id).get_stats(&total, &by_type);
+    EXPECT_GE(mempool::osd::allocated_bytes(), i * 4u);
+    EXPECT_GE(mempool::osd::allocated_items(), i);
 
     c.swap(b);
     eq_elements(a,c);
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
     a.clear();
     b.clear();
     c.clear();
@@ -122,7 +122,7 @@ TEST(mempool, list_context)
 {
   for (unsigned i = 1; i < 10; ++i) {
     list<int> a;
-    mempool::unittest_1::list<int> b,c;
+    mempool::osd::list<int> b,c;
     eq_elements(a,b);
     do_push_back(a,b,i,i);
     eq_elements(a,b);
@@ -139,12 +139,12 @@ TEST(mempool, list_context)
 
     mempool::stats_t total;
     map<std::string,mempool::stats_t> by_type;
-    mempool::get_pool(mempool::unittest_1::id).get_stats(&total, &by_type);
-    EXPECT_GE(mempool::unittest_1::allocated_bytes(), i * 4u);
-    EXPECT_EQ(mempool::unittest_1::allocated_items(), i);
+    mempool::get_pool(mempool::osd::id).get_stats(&total, &by_type);
+    EXPECT_GE(mempool::osd::allocated_bytes(), i * 4u);
+    EXPECT_EQ(mempool::osd::allocated_items(), i);
 
     eq_elements(a,c);
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
   }
 }
 
@@ -152,22 +152,22 @@ TEST(mempool, set_context)
 {
   for (int i = 0; i < 10; ++i) {
     set<int> a;
-    mempool::unittest_1::set<int> b;
+    mempool::osd::set<int> b;
     do_insert(a,b,i,i);
     eq_elements(a,b);
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
   }
 
   for (int i = 1; i < 10; ++i) {
     set<int> a;
-    mempool::unittest_1::set<int> b;
+    mempool::osd::set<int> b;
     do_insert(a,b,i,0);
     EXPECT_NE(a.find(i/2),a.end());
     EXPECT_NE(b.find(i/2),b.end());
     a.erase(a.find(i/2));
     b.erase(b.find(i/2));
     eq_elements(a,b);
-    check_usage(mempool::unittest_1::id);
+    check_usage(mempool::osd::id);
   }
 }
 
@@ -182,14 +182,14 @@ struct obj {
     return l.a < r.a;
   }
 };
-MEMPOOL_DEFINE_OBJECT_FACTORY(obj, obj, unittest_2);
+MEMPOOL_DEFINE_OBJECT_FACTORY(obj, obj, osdmap);
 
 TEST(mempool, test_factory)
 {
    obj *o1 = new obj();
    obj *o2 = new obj(10);
    obj *o3 = new obj(20,30);
-   check_usage(mempool::unittest_2::id);
+   check_usage(mempool::osdmap::id);
    EXPECT_NE(o1,nullptr);
    EXPECT_EQ(o1->a,1);
    EXPECT_EQ(o1->b,1);
@@ -201,18 +201,18 @@ TEST(mempool, test_factory)
    delete o1;
    delete o2;
    delete o3;
-   check_usage(mempool::unittest_2::id);
+   check_usage(mempool::osdmap::id);
 }
 
 TEST(mempool, vector)
 {
   {
-    mempool::unittest_1::vector<int> v;
+    mempool::osd::vector<int> v;
     v.push_back(1);
     v.push_back(2);
   }
   {
-    mempool::unittest_2::vector<obj> v;
+    mempool::osdmap::vector<obj> v;
     v.push_back(obj());
     v.push_back(obj(1));
   }
@@ -220,10 +220,10 @@ TEST(mempool, vector)
 
 TEST(mempool, set)
 {
-  mempool::unittest_1::set<int> set_int;
+  mempool::osd::set<int> set_int;
   set_int.insert(1);
   set_int.insert(2);
-  mempool::unittest_2::set<obj> set_obj;
+  mempool::osdmap::set<obj> set_obj;
   set_obj.insert(obj());
   set_obj.insert(obj(1));
   set_obj.insert(obj(1, 2));
@@ -232,12 +232,12 @@ TEST(mempool, set)
 TEST(mempool, map)
 {
   {
-    mempool::unittest_1::map<int,int> v;
+    mempool::osd::map<int,int> v;
     v[1] = 2;
     v[3] = 4;
   }
   {
-    mempool::unittest_2::map<int,obj> v;
+    mempool::osdmap::map<int,obj> v;
     v[1] = obj();
     v[2] = obj(2);
     v[3] = obj(2, 3);
@@ -247,12 +247,12 @@ TEST(mempool, map)
 TEST(mempool, list)
 {
   {
-    mempool::unittest_1::list<int> v;
+    mempool::osd::list<int> v;
     v.push_back(1);
     v.push_back(2);
   }
   {
-    mempool::unittest_2::list<obj> v;
+    mempool::osdmap::list<obj> v;
     v.push_back(obj());
     v.push_back(obj(1));
   }
@@ -260,7 +260,7 @@ TEST(mempool, list)
 
 TEST(mempool, unordered_map)
 {
-  mempool::unittest_2::unordered_map<int,obj> h;
+  mempool::osdmap::unordered_map<int,obj> h;
   h[1] = obj();
   h[2] = obj(1);
 }
@@ -279,13 +279,13 @@ TEST(mempool, bufferlist)
 
 TEST(mempool, string_test)
 {
-  mempool::unittest_2::string s;
+  mempool::osdmap::string s;
   s.reserve(100);
-  EXPECT_GE(mempool::unittest_2::allocated_items(), s.capacity() + 1u); // +1 for zero-byte termination :
+  EXPECT_GE(mempool::osdmap::allocated_items(), s.capacity() + 1u); // +1 for zero-byte termination :
   for (size_t i = 0; i < 10; ++i) {
     s += '1';
     s.append(s);
-    EXPECT_GE(mempool::unittest_2::allocated_items(), s.capacity() + 1u);
+    EXPECT_GE(mempool::osdmap::allocated_items(), s.capacity() + 1u);
   }
 }