44#include " mon/ConfigMap.h"
55
66#include < iostream>
7+ #include < memory>
78#include < string>
89#include " crush/CrushWrapper.h"
910#include " common/ceph_context.h"
@@ -55,19 +56,19 @@ TEST(ConfigMap, parse_key)
5556TEST (ConfigMap, add_option)
5657{
5758 ConfigMap cm;
58- auto cct = new CephContext (CEPH_ENTITY_TYPE_MON) ;
59+ boost::intrusive_ptr<CephContext> cct{ new CephContext (CEPH_ENTITY_TYPE_CLIENT), false } ;
5960 int r;
6061
6162 r = cm.add_option (
62- cct, " foo" , " global" , " fooval" ,
63+ cct. get () , " foo" , " global" , " fooval" ,
6364 [&](const std::string& name) {
6465 return nullptr ;
6566 });
6667 ASSERT_EQ (0 , r);
6768 ASSERT_EQ (1 , cm.global .options .size ());
6869
6970 r = cm.add_option (
70- cct, " foo" , " mon" , " fooval" ,
71+ cct. get () , " foo" , " mon" , " fooval" ,
7172 [&](const std::string& name) {
7273 return nullptr ;
7374 });
@@ -76,7 +77,7 @@ TEST(ConfigMap, add_option)
7677 ASSERT_EQ (1 , cm.by_type [" mon" ].options .size ());
7778
7879 r = cm.add_option (
79- cct, " foo" , " mon.a" , " fooval" ,
80+ cct. get () , " foo" , " mon.a" , " fooval" ,
8081 [&](const std::string& name) {
8182 return nullptr ;
8283 });
@@ -89,22 +90,22 @@ TEST(ConfigMap, add_option)
8990TEST (ConfigMap, result_sections)
9091{
9192 ConfigMap cm;
92- auto cct = new CephContext (CEPH_ENTITY_TYPE_MON) ;
93- auto crush = new CrushWrapper;
93+ boost::intrusive_ptr<CephContext> cct{ new CephContext (CEPH_ENTITY_TYPE_CLIENT), false } ;
94+ auto crush = std::make_unique< CrushWrapper>() ;
9495 crush->finalize ();
9596
9697 int r;
9798
9899 r = cm.add_option (
99- cct, " foo" , " global" , " g" ,
100+ cct. get () , " foo" , " global" , " g" ,
100101 [&](const std::string& name) {
101102 return nullptr ;
102103 });
103104 ASSERT_EQ (0 , r);
104105 ASSERT_EQ (1 , cm.global .options .size ());
105106
106107 r = cm.add_option (
107- cct, " foo" , " mon" , " m" ,
108+ cct. get () , " foo" , " mon" , " m" ,
108109 [&](const std::string& name) {
109110 return nullptr ;
110111 });
@@ -113,7 +114,7 @@ TEST(ConfigMap, result_sections)
113114 ASSERT_EQ (1 , cm.by_type [" mon" ].options .size ());
114115
115116 r = cm.add_option (
116- cct, " foo" , " mon.a" , " a" ,
117+ cct. get () , " foo" , " mon.a" , " a" ,
117118 [&](const std::string& name) {
118119 return nullptr ;
119120 });
@@ -124,19 +125,19 @@ TEST(ConfigMap, result_sections)
124125 EntityName n;
125126 n.set (CEPH_ENTITY_TYPE_MON, " a" );
126127 auto c = cm.generate_entity_map (
127- n, {}, crush, " none" , nullptr );
128+ n, {}, crush. get () , " none" , nullptr );
128129 ASSERT_EQ (1 , c.size ());
129130 ASSERT_EQ (" a" , c[" foo" ]);
130131
131132 n.set (CEPH_ENTITY_TYPE_MON, " b" );
132133 c = cm.generate_entity_map (
133- n, {}, crush, " none" , nullptr );
134+ n, {}, crush. get () , " none" , nullptr );
134135 ASSERT_EQ (1 , c.size ());
135136 ASSERT_EQ (" m" , c[" foo" ]);
136137
137138 n.set (CEPH_ENTITY_TYPE_MDS, " c" );
138139 c = cm.generate_entity_map (
139- n, {}, crush, " none" , nullptr );
140+ n, {}, crush. get () , " none" , nullptr );
140141 ASSERT_EQ (1 , c.size ());
141142 ASSERT_EQ (" g" , c[" foo" ]);
142143}
0 commit comments