add test for clGetExtensionFunctionAddress
Change-Id: Ie6d0b4d7898f730b467f494a938c8fd10295ba25
This commit is contained in:
parent
bdcaf332ce
commit
f4a1b73fd9
|
@ -20,10 +20,11 @@
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "runtime/sharings/sharing_factory.h"
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
#include "runtime/helpers/string.h"
|
#include "runtime/helpers/string.h"
|
||||||
|
#include "runtime/sharings/sharing.h"
|
||||||
|
#include "runtime/sharings/sharing_factory.h"
|
||||||
|
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||||
|
|
||||||
using namespace OCLRT;
|
using namespace OCLRT;
|
||||||
|
|
||||||
|
@ -84,6 +85,20 @@ TestedSharingBuilderFactory *SharingFactoryStateRestore::getSharing() {
|
||||||
return reinterpret_cast<TestedSharingBuilderFactory *>(sharingContextBuilder[SharingType::CLGL_SHARING]);
|
return reinterpret_cast<TestedSharingBuilderFactory *>(sharingContextBuilder[SharingType::CLGL_SHARING]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dummyHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
class MockSharingBuilderFactory : public TestedSharingBuilderFactory {
|
||||||
|
public:
|
||||||
|
void *getExtensionFunctionAddress(const std::string &functionName) override {
|
||||||
|
if (functionName == "dummyHandler") {
|
||||||
|
return reinterpret_cast<void *>(dummyHandler);
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
TEST(SharingFactoryTests, givenFactoryWithEmptyTableWhenAskedForExtensionThenEmptyStringIsReturned) {
|
TEST(SharingFactoryTests, givenFactoryWithEmptyTableWhenAskedForExtensionThenEmptyStringIsReturned) {
|
||||||
SharingFactoryStateRestore stateRestore;
|
SharingFactoryStateRestore stateRestore;
|
||||||
|
|
||||||
|
@ -130,3 +145,16 @@ TEST(SharingFactoryTests, givenFactoryWithSharingWhenAskedThenAddressIsReturned)
|
||||||
|
|
||||||
EXPECT_EQ(1u, sharing->invocationCount);
|
EXPECT_EQ(1u, sharing->invocationCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SharingFactoryTests, givenMockFactoryWithSharingWhenAskedThenAddressIsReturned) {
|
||||||
|
SharingFactoryStateRestore stateRestore;
|
||||||
|
|
||||||
|
stateRestore.clearCurrentState();
|
||||||
|
stateRestore.registerSharing<MockSharingBuilderFactory>(SharingType::CLGL_SHARING);
|
||||||
|
auto ptr = stateRestore.getExtensionFunctionAddress("dummyHandler");
|
||||||
|
|
||||||
|
EXPECT_EQ(reinterpret_cast<void *>(dummyHandler), ptr);
|
||||||
|
|
||||||
|
ptr = clGetExtensionFunctionAddress("dummyHandler");
|
||||||
|
EXPECT_EQ(reinterpret_cast<void *>(dummyHandler), ptr);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue