[arena] Add a test for FinalizeArena being called (#36772)

Built on #36758 which should be merged first

Closes #36772

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36772 from ctiller:arena-test 3cded84c73
PiperOrigin-RevId: 638781890
pull/36784/head
Craig Tiller 8 months ago committed by Copybara-Service
parent 53c42e9dae
commit 766813f164
  1. 20
      test/core/resource_quota/arena_test.cc

@ -29,6 +29,7 @@
#include <vector>
#include "absl/strings/str_join.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <grpc/support/sync.h>
@ -40,6 +41,8 @@
#include "src/core/lib/resource_quota/resource_quota.h"
#include "test/core/test_util/test_config.h"
using testing::StrictMock;
namespace grpc_core {
struct AllocShape {
@ -271,6 +274,23 @@ TEST(ArenaTest, ConcurrentMakePooled) {
}
}
class MockArenaFactory : public ArenaFactory {
public:
MockArenaFactory()
: ArenaFactory(
ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator(
"test")) {}
MOCK_METHOD(RefCountedPtr<Arena>, MakeArena, (), (override));
MOCK_METHOD(void, FinalizeArena, (Arena * arena), (override));
};
TEST(ArenaTest, FinalizeArenaIsCalled) {
auto factory = MakeRefCounted<StrictMock<MockArenaFactory>>();
auto arena = Arena::Create(1, factory);
EXPECT_CALL(*factory, FinalizeArena(arena.get()));
arena.reset();
}
} // namespace grpc_core
int main(int argc, char* argv[]) {

Loading…
Cancel
Save