Debian Codegraph @

level_zero/tools/test/unit_tests/sources/sysman/ecc/linux/mock_ecc.h

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