]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/mempool: Add test for mempool in btree_map
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 2 Mar 2020 08:08:45 +0000 (09:08 +0100)
committerNathan Cutler <ncutler@suse.com>
Thu, 25 Feb 2021 19:20:01 +0000 (20:20 +0100)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit b426e52d0425f3ececf48c7936d3d6d0eeb69ebf)

Conflicts:
src/test/test_mempool.cc
- tests went into nautilus in a different order

src/test/test_mempool.cc

index 39ebc0248bec546d1093189e8544a2d42801d464..b32b70609440f66ccba3ef9913f04ad607facc88 100644 (file)
@@ -20,6 +20,7 @@
 #include "common/ceph_argparse.h"
 #include "global/global_context.h"
 #include "gtest/gtest.h"
+#include "include/btree_map.h"
 #include "include/mempool.h"
 
 void check_usage(mempool::pool_index_t ix)
@@ -408,6 +409,28 @@ TEST(mempool, check_shard_select)
   EXPECT_LT(VarX, 200);
 }
 
+TEST(mempool, btree_map_test)
+{
+  typedef mempool::pool_allocator<mempool::mempool_osd,
+    pair<const uint64_t,uint64_t>> allocator_t;
+  typedef btree::btree_map<uint64_t,uint64_t,std::less<uint64_t>,allocator_t> btree_t;
+
+  {
+    btree_t btree;
+    ASSERT_EQ(0, mempool::osd::allocated_items());
+    ASSERT_EQ(0, mempool::osd::allocated_bytes());
+    for (size_t i = 0; i < 1000; ++i) {
+      btree[rand()] = rand();
+    }
+    ASSERT_LT(0, mempool::osd::allocated_items());
+    ASSERT_LT(0, mempool::osd::allocated_bytes());
+  }
+
+  ASSERT_EQ(0, mempool::osd::allocated_items());
+  ASSERT_EQ(0, mempool::osd::allocated_bytes());
+}
+
+
 
 int main(int argc, char **argv)
 {