Initialize SIP kernel from file only once

Related-To: NEO-5802

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2021-04-29 10:09:22 +02:00
committed by Compute-Runtime-Automation
parent 2f4f5a22ae
commit 492d715846
2 changed files with 53 additions and 4 deletions

View File

@@ -181,3 +181,47 @@ TEST_F(RawBinarySipTest, givenRawBinaryFileWhenAllocationCreationFailsThenSipIsN
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
EXPECT_EQ(nullptr, sipKernel);
}
TEST_F(RawBinarySipTest, givenRawBinaryFileWhenInitSipKernelTwiceThenSipIsLoadedFromFileAndCreatedOnce) {
bool ret = SipKernel::initSipKernel(SipKernelType::Csr, *pDevice);
EXPECT_TRUE(ret);
EXPECT_EQ(1u, IoFunctions::mockFopenCalled);
EXPECT_EQ(1u, IoFunctions::mockFseekCalled);
EXPECT_EQ(1u, IoFunctions::mockFtellCalled);
EXPECT_EQ(1u, IoFunctions::mockRewindCalled);
EXPECT_EQ(1u, IoFunctions::mockFreadCalled);
EXPECT_EQ(1u, IoFunctions::mockFcloseCalled);
EXPECT_EQ(SipKernelType::Csr, SipKernel::getSipKernelType(*pDevice));
uint32_t sipIndex = static_cast<uint32_t>(SipKernelType::Csr);
auto sipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, sipKernel);
auto storedAllocation = sipKernel->getSipAllocation();
auto &refSipKernel = SipKernel::getSipKernel(*pDevice);
EXPECT_EQ(sipKernel, &refSipKernel);
auto sipAllocation = refSipKernel.getSipAllocation();
EXPECT_NE(nullptr, storedAllocation);
EXPECT_EQ(storedAllocation, sipAllocation);
ret = SipKernel::initSipKernel(SipKernelType::Csr, *pDevice);
EXPECT_TRUE(ret);
EXPECT_EQ(1u, IoFunctions::mockFopenCalled);
EXPECT_EQ(1u, IoFunctions::mockFseekCalled);
EXPECT_EQ(1u, IoFunctions::mockFtellCalled);
EXPECT_EQ(1u, IoFunctions::mockRewindCalled);
EXPECT_EQ(1u, IoFunctions::mockFreadCalled);
EXPECT_EQ(1u, IoFunctions::mockFcloseCalled);
auto secondSipKernel = pDevice->getRootDeviceEnvironment().sipKernels[sipIndex].get();
ASSERT_NE(nullptr, secondSipKernel);
auto secondStoredAllocation = sipKernel->getSipAllocation();
EXPECT_NE(nullptr, secondStoredAllocation);
EXPECT_EQ(sipKernel, secondSipKernel);
EXPECT_EQ(storedAllocation, secondStoredAllocation);
}