mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-11 16:45:25 +08:00
refactor: Unify GTPin initialization logic between APIs
Add support for new GTPin loading logic in OCL path, similar to existing in L0 - invoking exposed, dedicated API call (OpenGTPinOCL). - Move logic to shared, including unit tests - Check whether instrumentation is required on context creation and if yes, make a call to OpenGTPinOCL function. Handle potential errors gracefully without exiting. Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c43b827702
commit
1afaf37f78
56
shared/test/unit_test/pin/test_pin.cpp
Normal file
56
shared/test/unit_test/pin/test_pin.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/pin/pin.h"
|
||||
#include "shared/test/common/mocks/mock_os_library.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace ULT {
|
||||
|
||||
TEST(PinInitializationTest, GivenValidLibraryPinContextInitSucceeds) {
|
||||
uint32_t (*openPinHandler)(void *) = [](void *arg) -> uint32_t { return 0; };
|
||||
MockOsLibrary mockLibraryObject(reinterpret_cast<void *>(openPinHandler), false);
|
||||
MockOsLibrary::loadLibraryNewObject = &mockLibraryObject;
|
||||
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
|
||||
std::string mockGTPinFunctionName{"aaa"};
|
||||
EXPECT_TRUE(NEO::PinContext::init(mockGTPinFunctionName));
|
||||
|
||||
MockOsLibrary::loadLibraryNewObject = nullptr;
|
||||
}
|
||||
|
||||
TEST(PinInitializationTest, GivenBadLibraryNamePinContextInitFAILS) {
|
||||
MockOsLibrary::loadLibraryNewObject = nullptr;
|
||||
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
|
||||
std::string mockGTPinFunctionName{"aaa"};
|
||||
EXPECT_FALSE(NEO::PinContext::init(mockGTPinFunctionName));
|
||||
|
||||
MockOsLibrary::loadLibraryNewObject = nullptr;
|
||||
}
|
||||
|
||||
TEST(PinInitializationTest, GivenBadProcAddressPinContextInitFAILS) {
|
||||
MockOsLibrary mockLibraryObject(nullptr, false);
|
||||
MockOsLibrary::loadLibraryNewObject = &mockLibraryObject;
|
||||
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
|
||||
std::string mockGTPinFunctionName{"aaa"};
|
||||
EXPECT_FALSE(NEO::PinContext::init(mockGTPinFunctionName));
|
||||
|
||||
MockOsLibrary::loadLibraryNewObject = nullptr;
|
||||
}
|
||||
|
||||
TEST(PinInitializationTest, GivenBadPinHandlerPinContextInitFAILS) {
|
||||
uint32_t (*openPinHandler)(void *) = [](void *arg) -> uint32_t { return 1; };
|
||||
MockOsLibrary mockLibraryObject(reinterpret_cast<void *>(openPinHandler), false);
|
||||
MockOsLibrary::loadLibraryNewObject = &mockLibraryObject;
|
||||
NEO::PinContext::osLibraryLoadFunction = MockOsLibrary::load;
|
||||
std::string mockGTPinFunctionName{"aaa"};
|
||||
EXPECT_FALSE(NEO::PinContext::init(mockGTPinFunctionName));
|
||||
|
||||
MockOsLibrary::loadLibraryNewObject = nullptr;
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
Reference in New Issue
Block a user