]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/: use unique_ptr for some formatter whose pointers were not released. 38223/head
authorhaoyixing <haoyixing@kuaishou.com>
Sat, 21 Nov 2020 09:09:32 +0000 (17:09 +0800)
committerhaoyixing <haoyixing@kuaishou.com>
Sat, 21 Nov 2020 09:09:38 +0000 (17:09 +0800)
some code under test use formatter to output, but Formatter *f
was not freed like elsewere. So use unique_ptr to avoid this.

Signed-off-by: haoyixing <haoyixing@kuaishou.com>
src/test/cls_cas/test_cls_cas.cc
src/test/objectstore/store_test.cc

index 01db8a32be6ad3a821b1b23bd9cde6263b273f96..e730f0d128a55c0919471a855d0868ffefb0c2e0 100644 (file)
@@ -327,7 +327,7 @@ TEST(chunk_refs_t, size)
       bufferlist bl2;
       encode(a, bl2);
       if (!bl.contents_equal(bl2)) {
-       Formatter *f = Formatter::create("json-pretty");
+       std::unique_ptr<Formatter> f(Formatter::create("json-pretty"));
        cout << "original:\n";
        f->dump_object("refs", r);
        f->flush(cout);
index 9d372bbafc017790e5d83bbe8ee5f214a0db49fb..53b2accb1df1acd89334d97b5e543eff1974f556 100644 (file)
@@ -7716,7 +7716,7 @@ TEST_P(StoreTest, KVDBHistogramTest) {
     ASSERT_EQ(r, 0);
   }
 
-  Formatter *f = Formatter::create("store_test", "json-pretty", "json-pretty");
+  std::unique_ptr<Formatter> f(Formatter::create("store_test", "json-pretty", "json-pretty"));
   store->generate_db_histogram(f);
   f->flush(cout);
   cout << std::endl;
@@ -7760,7 +7760,7 @@ TEST_P(StoreTest, KVDBStatsTest) {
     ASSERT_EQ(r, 0);
   }
 
-  Formatter *f = Formatter::create("store_test", "json-pretty", "json-pretty");
+  std::unique_ptr<Formatter> f(Formatter::create("store_test", "json-pretty", "json-pretty"));
   store->get_db_statistics(f);
   f->flush(cout);
   cout << std::endl;
@@ -8305,7 +8305,7 @@ TEST_P(StoreTest, BluestoreStatistics) {
     ASSERT_EQ(static_cast<int>(bl.length()), r);
     ASSERT_TRUE(bl_eq(bl, readback));
   }
-  Formatter *f = Formatter::create("store_test", "json-pretty", "json-pretty");
+  std::unique_ptr<Formatter> f(Formatter::create("store_test", "json-pretty", "json-pretty"));
   EXPECT_NO_THROW(store->get_db_statistics(f));
   f->flush(cout);
   cout << std::endl;