|
40 | 40 | #include "opencl/test/unit_test/mocks/mock_gmm.h" |
41 | 41 | #include "opencl/test/unit_test/mocks/mock_platform.h" |
42 | 42 | #include "opencl/test/unit_test/os_interface/linux/drm_mock.h" |
| 43 | +#include "opencl/test/unit_test/os_interface/linux/drm_mock_cache_info.h" |
43 | 44 | #include "test.h" |
44 | 45 |
|
45 | 46 | #include "drm/i915_drm.h" |
@@ -4183,4 +4184,48 @@ TEST(DrmAllocationTest, givenResourceRegistrationEnabledWhenIsaIsRegisteredThenC |
4183 | 4184 | allocation.freeRegisteredBOBindExtHandles(&drm); |
4184 | 4185 | EXPECT_EQ(2u, drm.unregisterCalledCount); |
4185 | 4186 | } |
| 4187 | + |
| 4188 | +TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFalse) { |
| 4189 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 4190 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 4191 | + |
| 4192 | + DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]); |
| 4193 | + drm.cacheInfo.reset(new MockCacheInfo()); |
| 4194 | + |
| 4195 | + MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory); |
| 4196 | + |
| 4197 | + EXPECT_FALSE(allocation.setCacheRegion(&drm, 1024, CacheRegion::None)); |
| 4198 | +} |
| 4199 | + |
| 4200 | +TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenReturnTrue) { |
| 4201 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 4202 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 4203 | + |
| 4204 | + DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]); |
| 4205 | + drm.cacheInfo.reset(new MockCacheInfo()); |
| 4206 | + |
| 4207 | + MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory); |
| 4208 | + |
| 4209 | + EXPECT_TRUE(allocation.setCacheRegion(&drm, 1024, CacheRegion::Region1)); |
| 4210 | +} |
| 4211 | + |
| 4212 | +TEST(DrmAllocationTest, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSetRegionInBufferObject) { |
| 4213 | + auto executionEnvironment = std::make_unique<ExecutionEnvironment>(); |
| 4214 | + executionEnvironment->prepareRootDeviceEnvironments(1); |
| 4215 | + |
| 4216 | + DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]); |
| 4217 | + drm.cacheInfo.reset(new MockCacheInfo()); |
| 4218 | + |
| 4219 | + MockBufferObject bo(&drm, 0, 0, 1); |
| 4220 | + MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::LocalMemory); |
| 4221 | + allocation.bufferObjects[0] = &bo; |
| 4222 | + |
| 4223 | + EXPECT_TRUE(allocation.setCacheRegion(&drm, 1024, CacheRegion::Region1)); |
| 4224 | + |
| 4225 | + for (auto bo : allocation.bufferObjects) { |
| 4226 | + if (bo != nullptr) { |
| 4227 | + EXPECT_EQ(CacheRegion::Region1, bo->peekCacheRegion()); |
| 4228 | + } |
| 4229 | + } |
| 4230 | +} |
4186 | 4231 | } // namespace NEO |
0 commit comments