1 /*
2 * Copyright (C) 2019-2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/execution_environment/execution_environment.h"
9 #include "shared/source/execution_environment/root_device_environment.h"
10 #include "shared/source/helpers/constants.h"
11 #include "shared/source/helpers/hw_info.h"
12 #include "shared/source/os_interface/device_factory.h"
13 #include "shared/source/os_interface/hw_info_config.h"
14 #include "shared/test/common/helpers/debug_manager_state_restore.h"
15 #include "shared/test/common/helpers/default_hw_info.h"
16 #include "shared/test/common/test_macros/test.h"
17 #include "shared/test/common/test_macros/test_checks_shared.h"
18
19 namespace NEO {
20 bool prepareDeviceEnvironments(ExecutionEnvironment &executionEnvironment);
21
22 using PrepareDeviceEnvironmentsTests = ::testing::Test;
23
HWTEST_F(PrepareDeviceEnvironmentsTests,WhenPrepareDeviceEnvironmentsIsCalledThenSuccessIsReturned)24 HWTEST_F(PrepareDeviceEnvironmentsTests, WhenPrepareDeviceEnvironmentsIsCalledThenSuccessIsReturned) {
25 ExecutionEnvironment executionEnvironment;
26
27 auto returnValue = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
28 EXPECT_EQ(true, returnValue);
29 }
30
HWTEST_F(PrepareDeviceEnvironmentsTests,whenPrepareDeviceEnvironmentsIsCalledThenGmmIsBeingInitializedAfterFillingHwInfo)31 HWTEST_F(PrepareDeviceEnvironmentsTests, whenPrepareDeviceEnvironmentsIsCalledThenGmmIsBeingInitializedAfterFillingHwInfo) {
32 ExecutionEnvironment executionEnvironment;
33 executionEnvironment.prepareRootDeviceEnvironments(1u);
34 auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getMutableHardwareInfo();
35 hwInfo->platform.eProductFamily = PRODUCT_FAMILY::IGFX_UNKNOWN;
36 hwInfo->platform.ePCHProductFamily = PCH_PRODUCT_FAMILY::PCH_UNKNOWN;
37 EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper());
38
39 auto returnValue = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
40 EXPECT_TRUE(returnValue);
41 EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper());
42 }
43
HWTEST_F(PrepareDeviceEnvironmentsTests,givenRcsAndCcsNotSupportedWhenInitializingThenReturnFalse)44 HWTEST_F(PrepareDeviceEnvironmentsTests, givenRcsAndCcsNotSupportedWhenInitializingThenReturnFalse) {
45 REQUIRE_64BIT_OR_SKIP();
46
47 NEO::ExecutionEnvironment executionEnviornment;
48 HardwareInfo hwInfo = *defaultHwInfo;
49
50 auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
51 hwInfoConfig->configureHardwareCustom(&hwInfo, nullptr);
52
53 bool expectedValue = false;
54 if (hwInfo.featureTable.flags.ftrRcsNode || hwInfo.featureTable.flags.ftrCCSNode) {
55 expectedValue = true;
56 }
57
58 EXPECT_EQ(expectedValue, NEO::prepareDeviceEnvironments(executionEnviornment));
59 }
60
HWTEST_F(PrepareDeviceEnvironmentsTests,Given32bitApplicationWhenDebugKeyIsSetThenSupportIsReported)61 HWTEST_F(PrepareDeviceEnvironmentsTests, Given32bitApplicationWhenDebugKeyIsSetThenSupportIsReported) {
62 NEO::ExecutionEnvironment executionEnviornment;
63 DebugManagerStateRestore restorer;
64 DebugManager.flags.Force32BitDriverSupport.set(true);
65 EXPECT_TRUE(NEO::prepareDeviceEnvironments(executionEnviornment));
66 }
67 } // namespace NEO