refactor: rename OsLibrary::load function to distinguish functionality

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-08-14 16:22:40 +00:00
committed by Compute-Runtime-Automation
parent 55cf1cffc2
commit efb8240a00
6 changed files with 14 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -90,7 +90,7 @@ template <template <CIF::Version_t> class EntryPointT>
inline bool loadCompiler(const char *libName, std::unique_ptr<OsLibrary> &outLib,
CIF::RAII::UPtr_t<CIF::CIFMain> &outLibMain) {
std::string loadLibraryError;
auto lib = std::unique_ptr<OsLibrary>(OsLibrary::load(libName, &loadLibraryError));
auto lib = std::unique_ptr<OsLibrary>(OsLibrary::loadAndCaptureError(libName, &loadLibraryError));
if (lib == nullptr) {
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Compiler Library %s could not be loaded with error: %s\n", libName, loadLibraryError.c_str());
DEBUG_BREAK_IF(true); // could not load library

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Intel Corporation
* Copyright (C) 2022-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -20,7 +20,7 @@ inline const std::string getGdiName() {
}
NEO::OsLibrary *Gdi::createGdiDLL() {
return NEO::OsLibrary::load(getGdiName(), nullptr);
return NEO::OsLibrary::load(getGdiName());
}
} // namespace NEO

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -14,11 +14,8 @@
#include <link.h>
namespace NEO {
OsLibrary *OsLibrary::load(const std::string &name) {
return load(name, nullptr);
}
OsLibrary *OsLibrary::load(const std::string &name, std::string *errorValue) {
OsLibrary *OsLibrary::loadAndCaptureError(const std::string &name, std::string *errorValue) {
auto ptr = new (std::nothrow) Linux::OsLibrary(name, errorValue);
if (ptr == nullptr)
return nullptr;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -30,8 +30,8 @@ class OsLibrary {
public:
virtual ~OsLibrary() = default;
static OsLibrary *load(const std::string &name);
static OsLibrary *load(const std::string &name, std::string *errorValue);
static OsLibrary *load(const std::string &name) { return loadAndCaptureError(name, nullptr); }
static OsLibrary *loadAndCaptureError(const std::string &name, std::string *errorValue);
static const std::string createFullSystemPath(const std::string &name);
ConvertibleProcAddr operator[](const std::string &name) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,11 +9,7 @@
namespace NEO {
OsLibrary *OsLibrary::load(const std::string &name) {
return load(name, nullptr);
}
OsLibrary *OsLibrary::load(const std::string &name, std::string *errorValue) {
OsLibrary *OsLibrary::loadAndCaptureError(const std::string &name, std::string *errorValue) {
Windows::OsLibrary *ptr = new Windows::OsLibrary(name, errorValue);
if (!ptr->isLoaded()) {

View File

@@ -1,15 +1,10 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#if defined(_WIN32)
#include "shared/source/os_interface/windows/os_library_win.h"
#elif defined(__linux__)
#include "shared/source/os_interface/linux/os_library_linux.h"
#endif
#include "shared/source/os_interface/os_library.h"
#include "shared/test/common/fixtures/memory_management_fixture.h"
#include "shared/test/common/test_macros/test.h"
@@ -40,7 +35,7 @@ TEST(OSLibraryTest, GivenFakeLibNameWhenLoadingLibraryThenNullIsReturned) {
TEST(OSLibraryTest, GivenFakeLibNameWhenLoadingLibraryThenNullIsReturnedAndErrorString) {
std::string errorValue;
OsLibrary *library = OsLibrary::load(fakeLibName, &errorValue);
OsLibrary *library = OsLibrary::loadAndCaptureError(fakeLibName, &errorValue);
EXPECT_FALSE(errorValue.empty());
EXPECT_EQ(nullptr, library);
}
@@ -52,7 +47,7 @@ TEST(OSLibraryTest, GivenValidLibNameWhenLoadingLibraryThenLibraryIsLoaded) {
TEST(OSLibraryTest, GivenValidLibNameWhenLoadingLibraryThenLibraryIsLoadedWithNoErrorString) {
std::string errorValue;
std::unique_ptr<OsLibrary> library(OsLibrary::load(Os::testDllName, &errorValue));
std::unique_ptr<OsLibrary> library(OsLibrary::loadAndCaptureError(Os::testDllName, &errorValue));
EXPECT_TRUE(errorValue.empty());
EXPECT_NE(nullptr, library);
}