| 1 |
/* |
| 2 |
* Copyright (C) 2023-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "level_zero/sysman/source/shared/linux/kmd_interface/sysman_kmd_interface.h" |
| 11 |
#include "level_zero/sysman/source/shared/linux/pmu/sysman_pmu_imp.h" |
| 12 |
#include "level_zero/sysman/source/shared/linux/sysman_fs_access_interface.h" |
| 13 |
|
| 14 |
namespace L0 { |
| 15 |
namespace Sysman { |
| 16 |
namespace ult { |
| 17 |
|
| 18 |
class MockPmuInterfaceImp : public L0::Sysman::PmuInterfaceImp { |
| 19 |
public: |
| 20 |
int64_t mockPmuFd = -1; |
| 21 |
uint64_t mockTimestamp = 0; |
| 22 |
uint64_t mockActiveTime = 0; |
| 23 |
using PmuInterfaceImp::perfEventOpen; |
| 24 |
using PmuInterfaceImp::pSysmanKmdInterface; |
| 25 |
MockPmuInterfaceImp(L0::Sysman::LinuxSysmanImp *pLinuxSysmanImp) : PmuInterfaceImp(pLinuxSysmanImp) {} |
| 26 |
|
| 27 |
int64_t mockPerfEventFailureReturnValue = 0; |
| 28 |
int64_t perfEventOpen(perf_event_attr *attr, pid_t pid, int cpu, int groupFd, uint64_t flags) override { |
| 29 |
if (mockPerfEventFailureReturnValue == -1) { |
| 30 |
return mockPerfEventFailureReturnValue; |
| 31 |
} |
| 32 |
|
| 33 |
return mockPmuFd; |
| 34 |
} |
| 35 |
|
| 36 |
int mockPmuReadFailureReturnValue = 0; |
| 37 |
int pmuRead(int fd, uint64_t *data, ssize_t sizeOfdata) override { |
| 38 |
if (mockPmuReadFailureReturnValue == -1) { |
| 39 |
return mockPmuReadFailureReturnValue; |
| 40 |
} |
| 41 |
|
| 42 |
data[0] = mockActiveTime; |
| 43 |
data[1] = mockTimestamp; |
| 44 |
return 0; |
| 45 |
} |
| 46 |
}; |
| 47 |
|
| 48 |
} // namespace ult |
| 49 |
} // namespace Sysman |
| 50 |
} // namespace L0 |