| 33 | |
| 34 | |
| 35 | TEST_P(TAllocatorParamFixture, StackAllocationAndRelease) { |
| 36 | size_t stackSize = PageSize * 12; |
| 37 | auto stack = Allocator_->AllocStack(stackSize, "test_stack"); |
| 38 | #if defined(_san_enabled_) || !defined(NDEBUG) |
| 39 | stackSize *= DebugOrSanStackMultiplier; |
| 40 | #endif |
| 41 | |
| 42 | // Correct stack should have |
| 43 | EXPECT_EQ(stack.GetSize(), stackSize); // predefined size |
| 44 | EXPECT_FALSE((size_t)stack.GetAlignedMemory() & PageSizeMask); // aligned pointer |
| 45 | // Writable workspace |
| 46 | auto workspace = Allocator_->GetStackWorkspace(stack.GetAlignedMemory(), stack.GetSize()); |
| 47 | for (size_t i = 0; i < workspace.size(); i += 512) { |
| 48 | workspace[i] = 42; |
| 49 | } |
| 50 | EXPECT_TRUE(Allocator_->CheckStackOverflow(stack.GetAlignedMemory())); |
| 51 | EXPECT_TRUE(Allocator_->CheckStackOverride(stack.GetAlignedMemory(), stack.GetSize())); |
| 52 | |
| 53 | Allocator_->FreeStack(stack); |
| 54 | EXPECT_FALSE(stack.GetRawMemory()); |
| 55 | } |
| 56 | |
| 57 | INSTANTIATE_TEST_SUITE_P(AllocatorTestParams, TAllocatorParamFixture, |
| 58 | Combine(Values(EGuard::Canary, EGuard::Page), Values(EAllocator::Pool, EAllocator::Simple))); |
nothing calls this directly
no test coverage detected