Ensure shared handle be closed once on Linux

Related-To: NEO-5644

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2021-03-18 15:16:58 +00:00
committed by Compute-Runtime-Automation
parent d60225d995
commit 693f2ff384
8 changed files with 31 additions and 11 deletions

View File

@ -573,6 +573,25 @@ TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerCreate
EXPECT_NE(nullptr, drmMemoryManger.peekGemCloseWorker());
}
TEST_F(DrmMemoryManagerTest, GivenAllocationWhenClosingSharedHandleThenSucceeds) {
mock->ioctl_expected.primeFdToHandle = 1;
mock->ioctl_expected.gemWait = 1;
mock->ioctl_expected.gemClose = 1;
osHandle handle = 1u;
this->mock->outputHandle = 2u;
size_t size = 4096u;
AllocationProperties properties(rootDeviceIndex, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, {});
auto graphicsAllocation = memoryManager->createGraphicsAllocationFromSharedHandle(handle, properties, false);
EXPECT_EQ(handle, graphicsAllocation->peekSharedHandle());
memoryManager->closeSharedHandle(graphicsAllocation);
EXPECT_EQ(Sharing::nonSharedResource, graphicsAllocation->peekSharedHandle());
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
TEST_F(DrmMemoryManagerTest, GivenAllocationWhenFreeingThenSucceeds) {
mock->ioctl_expected.gemUserptr = 1;
mock->ioctl_expected.gemWait = 1;