mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
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>
57 lines
2.0 KiB
C++
57 lines
2.0 KiB
C++
/*
|
|
* 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
|