2018-11-30 17:25:47 +08:00
|
|
|
/*
|
2023-01-23 22:55:52 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-11-30 17:25:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-01-23 22:55:52 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm_lib.h"
|
2020-04-02 17:28:38 +08:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2021-05-21 07:17:57 +08:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2021-07-06 21:44:16 +08:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
|
|
|
#include "shared/test/common/mocks/mock_wddm.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2018-11-30 17:25:47 +08:00
|
|
|
|
2020-03-16 23:58:04 +08:00
|
|
|
using namespace NEO;
|
|
|
|
|
2021-01-04 17:47:00 +08:00
|
|
|
TEST(osInterfaceTests, GivenDefaultOsInterfaceThenLocalMemoryEnabled) {
|
2020-03-16 23:58:04 +08:00
|
|
|
EXPECT_TRUE(OSInterface::osEnableLocalMemory);
|
|
|
|
}
|
|
|
|
|
2020-07-22 18:51:48 +08:00
|
|
|
TEST(osInterfaceTests, whenOsInterfaceSetupGmmInputArgsThenArgsAreSet) {
|
2020-03-16 23:58:04 +08:00
|
|
|
MockExecutionEnvironment executionEnvironment;
|
|
|
|
RootDeviceEnvironment rootDeviceEnvironment(executionEnvironment);
|
|
|
|
auto wddm = new WddmMock(rootDeviceEnvironment);
|
2020-04-08 17:45:54 +08:00
|
|
|
EXPECT_EQ(nullptr, rootDeviceEnvironment.osInterface.get());
|
2020-03-16 23:58:04 +08:00
|
|
|
wddm->init();
|
2020-04-08 17:45:54 +08:00
|
|
|
EXPECT_NE(nullptr, rootDeviceEnvironment.osInterface.get());
|
2020-03-16 23:58:04 +08:00
|
|
|
|
2021-02-01 23:50:27 +08:00
|
|
|
wddm->deviceRegistryPath = "registryPath";
|
2020-08-05 19:58:44 +08:00
|
|
|
auto expectedRegistryPath = wddm->deviceRegistryPath.c_str();
|
2020-03-16 23:58:04 +08:00
|
|
|
auto &adapterBDF = wddm->adapterBDF;
|
2021-07-11 08:12:15 +08:00
|
|
|
uint32_t bus = 0x12;
|
|
|
|
adapterBDF.Bus = bus;
|
|
|
|
uint32_t device = 0x34;
|
|
|
|
adapterBDF.Device = device;
|
|
|
|
uint32_t function = 0x56;
|
|
|
|
adapterBDF.Function = function;
|
|
|
|
|
|
|
|
auto adapterBDFretrieved = wddm->getAdapterBDF();
|
|
|
|
EXPECT_EQ(bus, adapterBDFretrieved.Bus);
|
|
|
|
EXPECT_EQ(device, adapterBDFretrieved.Device);
|
|
|
|
EXPECT_EQ(function, adapterBDFretrieved.Function);
|
2020-03-16 23:58:04 +08:00
|
|
|
|
|
|
|
GMM_INIT_IN_ARGS gmmInputArgs = {};
|
2021-07-11 08:12:15 +08:00
|
|
|
EXPECT_NE(0, memcmp(&wddm->getAdapterBDF(), &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
|
2020-08-05 19:58:44 +08:00
|
|
|
EXPECT_STRNE(expectedRegistryPath, gmmInputArgs.DeviceRegistryPath);
|
2020-07-22 18:51:48 +08:00
|
|
|
|
2021-05-21 07:17:57 +08:00
|
|
|
rootDeviceEnvironment.osInterface->getDriverModel()->setGmmInputArgs(&gmmInputArgs);
|
2020-07-22 18:51:48 +08:00
|
|
|
|
2021-07-11 08:12:15 +08:00
|
|
|
EXPECT_EQ(0, memcmp(&wddm->getAdapterBDF(), &gmmInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
|
2020-07-22 18:51:48 +08:00
|
|
|
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, gmmInputArgs.ClientType);
|
2020-08-05 19:58:44 +08:00
|
|
|
EXPECT_STREQ(expectedRegistryPath, gmmInputArgs.DeviceRegistryPath);
|
2018-11-30 17:25:47 +08:00
|
|
|
}
|