1#include "../CtxInstrProfiling.h"
2#include "gtest/gtest.h"
3
4using namespace __ctx_profile;
5
6TEST(ArenaTest, Basic) {
7 Arena *A = Arena::allocateNewArena(Size: 1024);
8 EXPECT_EQ(A->size(), 1024U);
9 EXPECT_EQ(A->next(), nullptr);
10
11 auto *M1 = A->tryBumpAllocate(S: 1020);
12 EXPECT_NE(M1, nullptr);
13 auto *M2 = A->tryBumpAllocate(S: 4);
14 EXPECT_NE(M2, nullptr);
15 EXPECT_EQ(M1 + 1020, M2);
16 EXPECT_EQ(A->tryBumpAllocate(S: 1), nullptr);
17 Arena *A2 = Arena::allocateNewArena(Size: 2024, Prev: A);
18 EXPECT_EQ(A->next(), A2);
19 EXPECT_EQ(A2->next(), nullptr);
20 Arena::freeArenaList(A);
21 EXPECT_EQ(A, nullptr);
22}
23

source code of compiler-rt/lib/ctx_profile/tests/CtxInstrProfilingTest.cpp