mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
mock dlopen in tests to block unwanted interactions
- explicitly specify files allowed to dlopen() - use underscore to prefix fake library name that we want dlopen to return nullptr Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
2e68f0abbd
commit
7eb5b6aa42
@ -34,7 +34,7 @@ TEST(OsLibraryTest, GivenDisableDeepBindFlagWhenOpeningLibraryThenRtldDeepBindFl
|
||||
VariableBackup<bool> dlOpenCalledBackup{&NEO::SysCalls::dlOpenCalled, false};
|
||||
|
||||
DebugManager.flags.DisableDeepBind.set(1);
|
||||
auto lib = std::make_unique<Linux::OsLibrary>("abc", nullptr);
|
||||
auto lib = std::make_unique<Linux::OsLibrary>("_abc.so", nullptr);
|
||||
EXPECT_TRUE(NEO::SysCalls::dlOpenCalled);
|
||||
EXPECT_EQ(0, NEO::SysCalls::dlOpenFlags & RTLD_DEEPBIND);
|
||||
}
|
||||
@ -43,7 +43,7 @@ TEST(OsLibraryTest, GivenInvalidLibraryWhenOpeningLibraryThenDlopenErrorIsReturn
|
||||
VariableBackup<bool> dlOpenCalledBackup{&NEO::SysCalls::dlOpenCalled, false};
|
||||
|
||||
std::string errorValue;
|
||||
auto lib = std::make_unique<Linux::OsLibrary>("abc", &errorValue);
|
||||
auto lib = std::make_unique<Linux::OsLibrary>("_abc.so", &errorValue);
|
||||
EXPECT_FALSE(errorValue.empty());
|
||||
EXPECT_TRUE(NEO::SysCalls::dlOpenCalled);
|
||||
}
|
||||
|
@ -20,8 +20,6 @@
|
||||
#include <memory>
|
||||
|
||||
namespace Os {
|
||||
extern const char *frontEndDllName;
|
||||
extern const char *igcDllName;
|
||||
extern const char *testDllName;
|
||||
} // namespace Os
|
||||
const std::string fakeLibName = "_fake_library_name_";
|
||||
|
Reference in New Issue
Block a user