fix: clear AllocationsList tail on free all

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek 2023-11-02 15:42:01 +00:00 committed by Compute-Runtime-Automation
parent a8c79e0ba1
commit 43841fd2ef
2 changed files with 20 additions and 0 deletions

View File

@ -93,5 +93,6 @@ void AllocationsList::freeAllGraphicsAllocations(Device *neoDevice) {
curr = currNext;
}
head = nullptr;
tail = nullptr;
}
} // namespace NEO

View File

@ -3089,3 +3089,22 @@ TEST(MemoryManagerTest, givenDuplicateRootDeviceIndicesWhenCreatingMultiGraphics
memoryManager.freeGraphicsMemory(allocation);
}
TEST(AllocationListTest, givenAllocationInListWhenFreeAllGraphicsAllocationsCalledThenHeadAndTailIsNullptr) {
AllocationsList allocList;
EXPECT_EQ(nullptr, allocList.peekHead());
EXPECT_EQ(nullptr, allocList.peekTail());
EXPECT_TRUE(allocList.peekIsEmpty());
auto mockGfxAllocation = std::make_unique<MockGraphicsAllocation>();
allocList.pushFrontOne(*mockGfxAllocation.release());
EXPECT_NE(nullptr, allocList.peekHead());
EXPECT_NE(nullptr, allocList.peekTail());
EXPECT_FALSE(allocList.peekIsEmpty());
MockDevice mockDevice;
allocList.freeAllGraphicsAllocations(&mockDevice);
EXPECT_EQ(nullptr, allocList.peekHead());
EXPECT_EQ(nullptr, allocList.peekTail());
EXPECT_TRUE(allocList.peekIsEmpty());
}