refactor: Handle dlopen error

Related-To: NEO-13922

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk 2025-02-19 13:34:15 +00:00 committed by Compute-Runtime-Automation
parent 28c008e438
commit 42261526e4
2 changed files with 12 additions and 0 deletions

View File

@ -85,6 +85,9 @@ std::string OsLibrary::getFullPath() {
bool isLibraryLoaded(const std::string &libraryName) {
auto handle = SysCalls::dlopen(0, RTLD_LAZY);
if (!handle) {
return false;
}
struct link_map *map = nullptr;
int retVal = NEO::SysCalls::dlinfo(handle, RTLD_DI_LINKMAP, &map);
if (retVal == 0 && map != nullptr) {

View File

@ -143,11 +143,20 @@ TEST(OSContextLinux, givenPerContextVmsAndBindCompleteWhenGetFenceAddressAndValT
EXPECT_GT(fenceValToWait, 0u);
}
extern void *(*dlopenFunc)(const char *filename, int flags);
TEST(OSContextLinux, WhenCreateOsContextLinuxThenCheckIfOVLoaded) {
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.requirePerContextVM = true;
{
VariableBackup<decltype(dlopenFunc)> mockOpen(&dlopenFunc, [](const char *pathname, int flags) -> void * {
return nullptr;
});
MockOsContextLinux osContext(drm, 0, 0u, EngineDescriptorHelper::getDefaultDescriptor());
EXPECT_FALSE(osContext.ovLoaded);
}
{
VariableBackup<decltype(SysCalls::sysCallsDlinfo)> mockDlinfo(&SysCalls::sysCallsDlinfo, [](void *handle, int request, void *info) -> int {
return -2;