Set Context in program when using builtins

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-04-02 13:00:33 +00:00
committed by Compute-Runtime-Automation
parent 402082182c
commit 722f693e0f
11 changed files with 44 additions and 19 deletions

View File

@ -2172,30 +2172,43 @@ using BuiltInOwnershipWrapperTests = BuiltInTests;
TEST_F(BuiltInOwnershipWrapperTests, givenBuiltinWhenConstructedThenLockAndUnlockOnDestruction) {
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice);
MockContext context(pClDevice);
{
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp);
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp, &context);
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
EXPECT_EQ(&context, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
}
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
}
TEST_F(BuiltInOwnershipWrapperTests, givenLockWithoutParametersWhenConstructingThenLockOnlyWhenRequested) {
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice);
MockContext context(pClDevice);
{
BuiltInOwnershipWrapper lock;
lock.takeOwnership(mockAuxBuiltInOp);
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
lock.takeOwnership(mockAuxBuiltInOp, &context);
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
EXPECT_EQ(&context, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
}
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
}
TEST_F(BuiltInOwnershipWrapperTests, givenLockWithAcquiredOwnershipWhenTakeOwnershipCalledThenAbort) {
MockAuxBuilInOp mockAuxBuiltInOp1(*pBuiltIns, *pClDevice);
MockAuxBuilInOp mockAuxBuiltInOp2(*pBuiltIns, *pClDevice);
MockContext context(pClDevice);
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp1);
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp1), std::exception);
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp2), std::exception);
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp1, &context);
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp1, &context), std::exception);
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp2, &context), std::exception);
}
HWTEST_F(BuiltInOwnershipWrapperTests, givenBuiltInOwnershipWrapperWhenAskedForTypeTraitsThenDisableCopyConstructorAndOperator) {