From 23cdcb1b47e91e0868574b19fafbf4bc96914a05 Mon Sep 17 00:00:00 2001 From: jhonxue Date: Thu, 19 Nov 2020 12:38:02 +0800 Subject: [PATCH] test/objectstore: handle -ENOSPC returned by allocate() Fixes: https://tracker.ceph.com/issues/48288 Signed-off-by: Xue Yantao --- src/test/objectstore/Allocator_test.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/objectstore/Allocator_test.cc b/src/test/objectstore/Allocator_test.cc index 78e018b7a57e1..21e7318889a6e 100644 --- a/src/test/objectstore/Allocator_test.cc +++ b/src/test/objectstore/Allocator_test.cc @@ -341,12 +341,14 @@ TEST_P(AllocTest, test_dump_fragmentation_score) //allocate want_size = ( rng() % one_alloc_max ) / alloc_unit * alloc_unit + alloc_unit; tmp.clear(); - uint64_t r = alloc->allocate(want_size, alloc_unit, 0, 0, &tmp); - for (auto& t: tmp) { - if (t.length > 0) - allocated.push_back(t); - } - allocated_cnt += r; + int64_t r = alloc->allocate(want_size, alloc_unit, 0, 0, &tmp); + if (r > 0) { + for (auto& t: tmp) { + if (t.length > 0) + allocated.push_back(t); + } + allocated_cnt += r; + } } else { //free ceph_assert(allocated.size() > 0); -- 2.39.5