2019-07-12 22:50:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-08-21 16:53:07 +08:00
|
|
|
#include "runtime/os_interface/windows/wddm_memory_operations_handler.h"
|
2019-07-12 22:50:14 +08:00
|
|
|
#include "test.h"
|
|
|
|
#include "unit_tests/mocks/mock_allocation_properties.h"
|
|
|
|
#include "unit_tests/mocks/mock_wddm.h"
|
|
|
|
#include "unit_tests/os_interface/windows/mock_wddm_allocation.h"
|
|
|
|
#include "unit_tests/os_interface/windows/wddm_fixture.h"
|
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
2019-08-21 16:53:07 +08:00
|
|
|
struct WddmMemoryOperationsHandlerTest : public WddmTest {
|
2019-07-12 22:50:14 +08:00
|
|
|
void SetUp() override {
|
|
|
|
WddmTest::SetUp();
|
2019-08-21 16:53:07 +08:00
|
|
|
wddmMemoryOperationsHandler = std::make_unique<WddmMemoryOperationsHandler>(wddm);
|
2019-07-12 22:50:14 +08:00
|
|
|
wddmAllocation.handle = 0x2;
|
|
|
|
}
|
|
|
|
|
2019-08-21 16:53:07 +08:00
|
|
|
std::unique_ptr<WddmMemoryOperationsHandler> wddmMemoryOperationsHandler;
|
2019-07-12 22:50:14 +08:00
|
|
|
MockWddmAllocation wddmAllocation;
|
|
|
|
};
|
|
|
|
|
2019-08-21 16:53:07 +08:00
|
|
|
TEST_F(WddmMemoryOperationsHandlerTest, whenMakingResidentAllocaionExpectMakeResidentCalled) {
|
|
|
|
EXPECT_TRUE(wddmMemoryOperationsHandler->makeResident(wddmAllocation));
|
|
|
|
EXPECT_TRUE(wddmMemoryOperationsHandler->isResident(wddmAllocation));
|
2019-07-12 22:50:14 +08:00
|
|
|
}
|
|
|
|
|
2019-08-21 16:53:07 +08:00
|
|
|
TEST_F(WddmMemoryOperationsHandlerTest, whenEvictingResidentAllocationExpectEvictCalled) {
|
|
|
|
EXPECT_TRUE(wddmMemoryOperationsHandler->makeResident(wddmAllocation));
|
|
|
|
EXPECT_TRUE(wddmMemoryOperationsHandler->evict(wddmAllocation));
|
|
|
|
EXPECT_FALSE(wddmMemoryOperationsHandler->isResident(wddmAllocation));
|
2019-07-12 22:50:14 +08:00
|
|
|
}
|