Debian Codegraph @

level_zero/tools/test/unit_tests/sources/metrics/test_metric_oa_initialization.cpp

raw
1 /*
2 * Copyright (C) 2022-2025 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "shared/source/os_interface/os_library.h"
9
10 #include "level_zero/core/test/unit_tests/mocks/mock_driver.h"
11 #include "level_zero/tools/source/metrics/metric_oa_source.h"
12 #include "level_zero/tools/test/unit_tests/sources/metrics/mock_metric_oa.h"
13
14 #include "gtest/gtest.h"
15
16 namespace L0 {
17
18 namespace ult {
19
20 class MockOsLibrary : public NEO::OsLibrary {
21 public:
22 MockOsLibrary() {
23 }
24
25 void *getProcAddress(const std::string &procName) override {
26 return nullptr;
27 }
28
29 bool isLoaded() override {
30 return false;
31 }
32
33 std::string getFullPath() override {
34 return std::string();
35 }
36
37 static OsLibrary *load(const OsLibraryCreateProperties &properties) {
38 auto ptr = new (std::nothrow) MockOsLibrary();
39 if (ptr == nullptr) {
40 return nullptr;
41 }
42 return ptr;
43 }
44 };
45
46 using MetricInitializationTest = Test<MetricContextFixture>;
47
48 TEST_F(MetricInitializationTest, GivenOaDependenciesAreAvailableThenMetricInitializationIsSuccess) {
49
50 globalDriverHandles->push_back(driverHandle.get());
51 VariableBackup<decltype(NEO::OsLibrary::loadFunc)> funcBackup{&NEO::OsLibrary::loadFunc, MockOsLibrary::load};
52 EXPECT_EQ(device->getMetricDeviceContext().enableMetricApi(), ZE_RESULT_SUCCESS);
53 globalDriverHandles->clear();
54 }
55
56 } // namespace ult
57 } // namespace L0