]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/test_bluefs: Fixed memleak in shared allocator tests 63761/head
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 5 Jun 2025 19:37:05 +0000 (19:37 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 5 Jun 2025 19:37:05 +0000 (19:37 +0000)
Valgrind detected the leaks.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/test/objectstore/test_bluefs.cc

index 3abca215e7fb791adf17559af79058baad6d5504..e732867a635704c8c57a68522e4e8fbb372cb130 100644 (file)
@@ -1706,7 +1706,7 @@ TEST(BlueFS, test_shared_alloc) {
                       size, shared_alloc_unit, "test shared allocator"),
     shared_alloc_unit);
   shared_alloc.a->init_add_free(0, size);
-
+  auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
   BlueFS fs(g_ceph_context);
   // DB device is fully utilized
   ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_db.path, false));
@@ -1790,6 +1790,7 @@ TEST(BlueFS, test_shared_alloc_sparse) {
   for(uint64_t i = 5 * bluefs_alloc_unit; i < size; i += 2 * main_unit) {
     shared_alloc.a->init_add_free(i, main_unit);
   }
+  auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
 
   BlueFS fs(g_ceph_context);
   ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_slow.path, false,
@@ -1866,6 +1867,7 @@ TEST(BlueFS, test_4k_shared_alloc) {
                       size, main_unit, "test shared allocator"),
     main_unit);
   shared_alloc.a->init_add_free(bluefs_alloc_unit, size - bluefs_alloc_unit);
+  auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
 
   BlueFS fs(g_ceph_context);
   ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_slow.path, false,