mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
Include files are now grouped and sorted in following order: 1. Header file of the class the current file implements 2. Project files 3. Third party files 4. Standard library Change-Id: If31af05652184169f7fee1d7ad08f1b2ed602cf0 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
75 lines
2.5 KiB
C++
75 lines
2.5 KiB
C++
/*
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/helpers/options.h"
|
|
#include "runtime/os_interface/performance_counters.h"
|
|
#include "test.h"
|
|
#include "unit_tests/helpers/variable_backup.h"
|
|
#include "unit_tests/mocks/mock_ostime.h"
|
|
#include "unit_tests/os_interface/mock_performance_counters.h"
|
|
|
|
using namespace OCLRT;
|
|
|
|
struct PerformanceCountersGenTest : public ::testing::Test {
|
|
};
|
|
|
|
namespace OCLRT {
|
|
extern decltype(&instrGetPerfCountersQueryData) getPerfCountersQueryDataFactory[IGFX_MAX_CORE];
|
|
extern size_t perfCountersQuerySize[IGFX_MAX_CORE];
|
|
} // namespace OCLRT
|
|
|
|
class MockPerformanceCountersGen : public PerformanceCounters {
|
|
public:
|
|
MockPerformanceCountersGen(OSTime *osTime) : PerformanceCounters(osTime) {
|
|
}
|
|
|
|
decltype(&instrGetPerfCountersQueryData) getFn() const {
|
|
return getPerfCountersQueryDataFunc;
|
|
}
|
|
};
|
|
|
|
HWTEST_F(PerformanceCountersGenTest, givenPerfCountersWhenInitializedWithoutGenSpecificThenDefaultFunctionIsUsed) {
|
|
auto gfxCore = platformDevices[0]->pPlatform->eRenderCoreFamily;
|
|
|
|
VariableBackup<decltype(&instrGetPerfCountersQueryData)> bkp(&getPerfCountersQueryDataFactory[gfxCore], nullptr);
|
|
|
|
MockOSTime osTime;
|
|
std::unique_ptr<MockPerformanceCountersGen> counters(new MockPerformanceCountersGen(&osTime));
|
|
ASSERT_NE(nullptr, counters.get());
|
|
|
|
counters->initialize(platformDevices[0]);
|
|
EXPECT_EQ(counters->getFn(), &instrGetPerfCountersQueryData);
|
|
|
|
size_t expected = sizeof(GTDI_QUERY);
|
|
EXPECT_EQ(expected, perfCountersQuerySize[gfxCore]);
|
|
}
|
|
|
|
HWTEST_F(PerformanceCountersGenTest, givenPerfCountersWhenInitializedWithGenSpecificThenGenFunctionIsUsed) {
|
|
VariableBackup<decltype(&instrGetPerfCountersQueryData)> bkp(&getPerfCountersQueryDataFactory[platformDevices[0]->pPlatform->eRenderCoreFamily]);
|
|
|
|
auto mockFn = [](
|
|
InstrEscCbData cbData,
|
|
GTDI_QUERY *pData,
|
|
HwPerfCounters *pLayout,
|
|
uint64_t cpuRawTimestamp,
|
|
void *pASInterface,
|
|
InstrPmRegsCfg *pPmRegsCfg,
|
|
bool useMiRPC,
|
|
bool resetASData = false,
|
|
const InstrAllowedContexts *pAllowedContexts = nullptr) -> void {
|
|
};
|
|
|
|
bkp = mockFn;
|
|
|
|
MockOSTime osTime;
|
|
std::unique_ptr<MockPerformanceCountersGen> counters(new MockPerformanceCountersGen(&osTime));
|
|
ASSERT_NE(nullptr, counters.get());
|
|
|
|
counters->initialize(platformDevices[0]);
|
|
EXPECT_EQ(counters->getFn(), mockFn);
|
|
}
|