Move linux device factory tests to shared

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-02-17 17:55:33 +00:00
committed by Compute-Runtime-Automation
parent be7c45bab0
commit 6799ea6119
4 changed files with 4 additions and 8 deletions

View File

@ -9,8 +9,6 @@ set(IGDRCL_SRCS_tests_os_interface_linux
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/device_os_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_buffer_object_tests.cpp

View File

@ -1,75 +0,0 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "opencl/test/unit_test/os_interface/linux/device_factory_tests.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/test/common/helpers/default_hw_info.h"
TEST_F(DeviceFactoryLinuxTest, WhenPreparingDeviceEnvironmentsThenInitializedCorrectly) {
const HardwareInfo *refHwinfo = defaultHwInfo.get();
pDrm->storedEUVal = 16;
pDrm->storedSSVal = 8;
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
EXPECT_TRUE(success);
EXPECT_NE(hwInfo, nullptr);
EXPECT_EQ(refHwinfo->platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily);
EXPECT_EQ((int)hwInfo->gtSystemInfo.EUCount, 16);
EXPECT_EQ((int)hwInfo->gtSystemInfo.SubSliceCount, 8);
EXPECT_EQ((int)hwInfo->gtSystemInfo.DualSubSliceCount, 8);
}
TEST_F(DeviceFactoryLinuxTest, givenSomeDisabledSSAndEUWhenPrepareDeviceEnvironmentsThenCorrectObtainEUCntSSCnt) {
const HardwareInfo *refHwinfo = defaultHwInfo.get();
pDrm->storedEUVal = 144;
pDrm->storedSSVal = 12;
pDrm->storedSVal = 2;
pDrm->disableSomeTopology = true;
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
EXPECT_TRUE(success);
EXPECT_NE(hwInfo, nullptr);
EXPECT_EQ(refHwinfo->platform.eDisplayCoreFamily, hwInfo->platform.eDisplayCoreFamily);
EXPECT_EQ((int)hwInfo->gtSystemInfo.SliceCount, 1);
EXPECT_EQ((int)hwInfo->gtSystemInfo.SubSliceCount, 2);
EXPECT_EQ((int)hwInfo->gtSystemInfo.DualSubSliceCount, 2);
EXPECT_EQ((int)hwInfo->gtSystemInfo.EUCount, 12);
}
TEST_F(DeviceFactoryLinuxTest, GivenInvalidHwInfoWhenPreparingDeviceEnvironmentsThenFailIsReturned) {
pDrm->storedRetValForDeviceID = -1;
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
EXPECT_FALSE(success);
pDrm->storedRetValForDeviceID = 0;
}
TEST_F(DeviceFactoryLinuxTest, givenGetDeviceCallWhenItIsDoneThenOsInterfaceIsAllocatedAndItContainDrm) {
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
EXPECT_TRUE(success);
EXPECT_NE(nullptr, executionEnvironment.rootDeviceEnvironments[0]->osInterface);
EXPECT_NE(nullptr, pDrm);
EXPECT_EQ(pDrm, executionEnvironment.rootDeviceEnvironments[0]->osInterface->getDriverModel()->as<Drm>());
}
TEST_F(DeviceFactoryLinuxTest, whenDrmIsNotCretedThenPrepareDeviceEnvironmentsFails) {
delete pDrm;
pDrm = nullptr;
bool success = DeviceFactory::prepareDeviceEnvironments(executionEnvironment);
EXPECT_FALSE(success);
}

View File

@ -1,37 +0,0 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/os_interface/device_factory.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/test_macros/test.h"
#include "gtest/gtest.h"
namespace NEO {
extern Drm **pDrmToReturnFromCreateFunc;
}; // namespace NEO
using namespace NEO;
struct DeviceFactoryLinuxTest : public ::testing::Test {
void SetUp() override {
pDrm = new DrmMock(*executionEnvironment.rootDeviceEnvironments[0]);
pDrmToReturnFromCreateFunc = reinterpret_cast<Drm **>(&pDrm);
}
void TearDown() override {
}
VariableBackup<Drm **> drmBackup{&pDrmToReturnFromCreateFunc};
DrmMock *pDrm;
MockExecutionEnvironment executionEnvironment;
};