Skip to content

Commit d9d7e73

Browse files
committed
test/test_bluefs: Fixed memleak in shared allocator tests
Valgrind detected the leaks. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent eaed7c0 commit d9d7e73

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/objectstore/test_bluefs.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,7 +1706,7 @@ TEST(BlueFS, test_shared_alloc) {
17061706
size, shared_alloc_unit, "test shared allocator"),
17071707
shared_alloc_unit);
17081708
shared_alloc.a->init_add_free(0, size);
1709-
1709+
auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
17101710
BlueFS fs(g_ceph_context);
17111711
// DB device is fully utilized
17121712
ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_db.path, false));
@@ -1790,6 +1790,7 @@ TEST(BlueFS, test_shared_alloc_sparse) {
17901790
for(uint64_t i = 5 * bluefs_alloc_unit; i < size; i += 2 * main_unit) {
17911791
shared_alloc.a->init_add_free(i, main_unit);
17921792
}
1793+
auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
17931794

17941795
BlueFS fs(g_ceph_context);
17951796
ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_slow.path, false,
@@ -1866,6 +1867,7 @@ TEST(BlueFS, test_4k_shared_alloc) {
18661867
size, main_unit, "test shared allocator"),
18671868
main_unit);
18681869
shared_alloc.a->init_add_free(bluefs_alloc_unit, size - bluefs_alloc_unit);
1870+
auto sg = make_scope_guard([&shared_alloc] { delete shared_alloc.a; });
18691871

18701872
BlueFS fs(g_ceph_context);
18711873
ASSERT_EQ(0, fs.add_block_device(BlueFS::BDEV_DB, bdev_slow.path, false,

0 commit comments

Comments
 (0)