| 1 |
/* |
| 2 |
* Copyright (C) 2020-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "shared/test/common/helpers/default_hw_info.h" |
| 11 |
|
| 12 |
#include "level_zero/sysman/source/driver/sysman_driver.h" |
| 13 |
#include "level_zero/sysman/source/driver/sysman_driver_handle_imp.h" |
| 14 |
#include "level_zero/sysman/source/shared/windows/zes_os_sysman_imp.h" |
| 15 |
#include "level_zero/sysman/test/unit_tests/sources/firmware_util/mock_fw_util_fixture.h" |
| 16 |
#include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_wddm.h" |
| 17 |
|
| 18 |
#include "gtest/gtest.h" |
| 19 |
|
| 20 |
using namespace NEO; |
| 21 |
|
| 22 |
namespace L0 { |
| 23 |
namespace Sysman { |
| 24 |
namespace ult { |
| 25 |
|
| 26 |
class PublicWddmSysmanImp : public L0::Sysman::WddmSysmanImp { |
| 27 |
public: |
| 28 |
using WddmSysmanImp::pFwUtilInterface; |
| 29 |
using WddmSysmanImp::pKmdSysManager; |
| 30 |
using WddmSysmanImp::pPmt; |
| 31 |
using WddmSysmanImp::pSysmanProductHelper; |
| 32 |
}; |
| 33 |
|
| 34 |
class SysmanDeviceFixture : public ::testing::Test { |
| 35 |
public: |
| 36 |
void SetUp() override { |
| 37 |
|
| 38 |
execEnv = new NEO::ExecutionEnvironment(); |
| 39 |
execEnv->prepareRootDeviceEnvironments(numRootDevices); |
| 40 |
for (auto i = 0u; i < execEnv->rootDeviceEnvironments.size(); i++) { |
| 41 |
execEnv->rootDeviceEnvironments[i]->setHwInfoAndInitHelpers(NEO::defaultHwInfo.get()); |
| 42 |
execEnv->rootDeviceEnvironments[i]->osInterface = std::make_unique<NEO::OSInterface>(); |
| 43 |
execEnv->rootDeviceEnvironments[i]->osInterface->setDriverModel(std::make_unique<SysmanMockWddm>(*execEnv->rootDeviceEnvironments[i])); |
| 44 |
} |
| 45 |
|
| 46 |
driverHandle = std::make_unique<L0::Sysman::SysmanDriverHandleImp>(); |
| 47 |
driverHandle->initialize(*execEnv); |
| 48 |
pSysmanDevice = driverHandle->sysmanDevices[0]; |
| 49 |
|
| 50 |
L0::Sysman::sysmanOnlyInit = true; |
| 51 |
|
| 52 |
pSysmanDeviceImp = static_cast<L0::Sysman::SysmanDeviceImp *>(pSysmanDevice); |
| 53 |
pOsSysman = pSysmanDeviceImp->pOsSysman; |
| 54 |
pWddmSysmanImp = static_cast<PublicWddmSysmanImp *>(pOsSysman); |
| 55 |
pWddmSysmanImp->pFwUtilInterface = new MockFwUtilInterface(); |
| 56 |
} |
| 57 |
|
| 58 |
void TearDown() override { |
| 59 |
L0::Sysman::sysmanOnlyInit = false; |
| 60 |
} |
| 61 |
|
| 62 |
L0::Sysman::SysmanDevice *pSysmanDevice = nullptr; |
| 63 |
L0::Sysman::SysmanDeviceImp *pSysmanDeviceImp = nullptr; |
| 64 |
L0::Sysman::OsSysman *pOsSysman = nullptr; |
| 65 |
PublicWddmSysmanImp *pWddmSysmanImp = nullptr; |
| 66 |
NEO::ExecutionEnvironment *execEnv = nullptr; |
| 67 |
std::unique_ptr<L0::Sysman::SysmanDriverHandleImp> driverHandle; |
| 68 |
const uint32_t numRootDevices = 1u; |
| 69 |
}; |
| 70 |
|
| 71 |
} // namespace ult |
| 72 |
} // namespace Sysman |
| 73 |
} // namespace L0 |