| 1 |
/* |
| 2 |
* Copyright (C) 2022-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
#include "shared/test/common/test_macros/mock_method_macros.h" |
| 10 |
|
| 11 |
#include "level_zero/core/test/unit_tests/mock.h" |
| 12 |
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h" |
| 13 |
#include "level_zero/tools/source/sysman/firmware_util/firmware_util.h" |
| 14 |
#include "level_zero/tools/test/unit_tests/sources/sysman/windows/mock_sysman_fixture.h" |
| 15 |
|
| 16 |
namespace L0 { |
| 17 |
namespace ult { |
| 18 |
|
| 19 |
class EccFwInterface : public FirmwareUtil {}; |
| 20 |
template <> |
| 21 |
struct Mock<EccFwInterface> : public EccFwInterface { |
| 22 |
ze_result_t mockFwGetEccConfigResult = ZE_RESULT_SUCCESS; |
| 23 |
ze_result_t mockFwSetEccConfigResult = ZE_RESULT_SUCCESS; |
| 24 |
ze_result_t mockFwDeviceInit = ZE_RESULT_SUCCESS; |
| 25 |
|
| 26 |
ze_bool_t mockSetConfig = true; |
| 27 |
uint8_t mockCurrentState = 0; |
| 28 |
uint8_t mockPendingState = 0; |
| 29 |
|
| 30 |
ze_result_t fwDeviceInit() override { |
| 31 |
return mockFwDeviceInit; |
| 32 |
} |
| 33 |
|
| 34 |
ze_result_t fwGetEccConfig(uint8_t *currentState, uint8_t *pendingState) override { |
| 35 |
if (mockFwGetEccConfigResult != ZE_RESULT_SUCCESS) { |
| 36 |
return mockFwGetEccConfigResult; |
| 37 |
} |
| 38 |
|
| 39 |
*currentState = mockCurrentState; |
| 40 |
*pendingState = mockPendingState; |
| 41 |
|
| 42 |
return ZE_RESULT_SUCCESS; |
| 43 |
} |
| 44 |
|
| 45 |
ze_result_t fwSetEccConfig(uint8_t newState, uint8_t *currentState, uint8_t *pendingState) override { |
| 46 |
if (mockFwSetEccConfigResult != ZE_RESULT_SUCCESS) { |
| 47 |
return mockFwSetEccConfigResult; |
| 48 |
} |
| 49 |
|
| 50 |
if (mockSetConfig == static_cast<ze_bool_t>(true)) { |
| 51 |
mockPendingState = newState; |
| 52 |
} |
| 53 |
*currentState = mockCurrentState; |
| 54 |
*pendingState = mockPendingState; |
| 55 |
|
| 56 |
return ZE_RESULT_SUCCESS; |
| 57 |
} |
| 58 |
|
| 59 |
ADDMETHOD_NOBASE(getFirstDevice, ze_result_t, ZE_RESULT_SUCCESS, (IgscDeviceInfo * info)); |
| 60 |
ADDMETHOD_NOBASE(getFwVersion, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, std::string &firmwareVersion)); |
| 61 |
ADDMETHOD_NOBASE(flashFirmware, ze_result_t, ZE_RESULT_SUCCESS, (std::string fwType, void *pImage, uint32_t size)); |
| 62 |
ADDMETHOD_NOBASE(fwIfrApplied, ze_result_t, ZE_RESULT_SUCCESS, (bool &ifrStatus)); |
| 63 |
ADDMETHOD_NOBASE(fwSupportedDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::vector<std::string> & supportedDiagTests)); |
| 64 |
ADDMETHOD_NOBASE(fwRunDiagTests, ze_result_t, ZE_RESULT_SUCCESS, (std::string & osDiagType, zes_diag_result_t *pResult)); |
| 65 |
ADDMETHOD_NOBASE(fwGetMemoryErrorCount, ze_result_t, ZE_RESULT_SUCCESS, (zes_ras_error_type_t category, uint32_t subDeviceCount, uint32_t subDeviceId, uint64_t &count)); |
| 66 |
ADDMETHOD_NOBASE_VOIDRETURN(getDeviceSupportedFwTypes, (std::vector<std::string> & fwTypes)); |
| 67 |
ADDMETHOD_NOBASE_VOIDRETURN(fwGetMemoryHealthIndicator, (zes_mem_health_t * health)); |
| 68 |
|
| 69 |
Mock<EccFwInterface>() = default; |
| 70 |
~Mock<EccFwInterface>() override = default; |
| 71 |
}; |
| 72 |
|
| 73 |
} // namespace ult |
| 74 |
} // namespace L0 |