mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Refactor of glcl sharing
new pattern to load gl and wgl functions from dll Change-Id: I71d7510a210462c09d50e03ce8a444770c017b8d
This commit is contained in:
committed by
sys_ocldev
parent
d1a80db2f2
commit
f18532c8c4
@@ -91,3 +91,40 @@ TEST_F(OSLibraryTest, testFailNew) {
|
||||
};
|
||||
injectFailures(method);
|
||||
}
|
||||
|
||||
TEST(OsLibrary, whenCallingIndexOperatorThenObjectConvertibleToFunctionOrVoidPointerIsReturned) {
|
||||
struct MockOsLibrary : OsLibrary {
|
||||
void *getProcAddress(const std::string &procName) override {
|
||||
lastRequestedProcName = procName;
|
||||
return ptrToReturn;
|
||||
}
|
||||
bool isLoaded() override { return true; }
|
||||
|
||||
void *ptrToReturn = nullptr;
|
||||
std::string lastRequestedProcName;
|
||||
};
|
||||
|
||||
MockOsLibrary lib;
|
||||
|
||||
int varA;
|
||||
int varB;
|
||||
int varC;
|
||||
|
||||
using FunctionTypeA = void (*)(int *, float);
|
||||
using FunctionTypeB = int (*)();
|
||||
|
||||
lib.ptrToReturn = &varA;
|
||||
FunctionTypeA functionA = lib["funcA"];
|
||||
EXPECT_STREQ("funcA", lib.lastRequestedProcName.c_str());
|
||||
EXPECT_EQ(&varA, reinterpret_cast<void *>(functionA));
|
||||
|
||||
lib.ptrToReturn = &varB;
|
||||
FunctionTypeB functionB = lib["funcB"];
|
||||
EXPECT_STREQ("funcB", lib.lastRequestedProcName.c_str());
|
||||
EXPECT_EQ(&varB, reinterpret_cast<void *>(functionB));
|
||||
|
||||
lib.ptrToReturn = &varC;
|
||||
void *rawPtr = lib["funcC"];
|
||||
EXPECT_STREQ("funcC", lib.lastRequestedProcName.c_str());
|
||||
EXPECT_EQ(&varC, rawPtr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user