| 1 | /* |
| 2 | * Copyright (C) 2020 Intel Corporation |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include "opencl/source/sharings/va/enable_va.h" |
| 9 | |
| 10 | #include "gtest/gtest.h" |
| 11 | |
| 12 | using namespace NEO; |
| 13 | |
| 14 | class TestVaSharingBuilderFactory : public VaSharingBuilderFactory { |
| 15 | public: |
| 16 | void *getExtensionFunctionAddressExtra(const std::string &functionName) override { |
| 17 | if (functionName == "someFunction") { |
| 18 | invocationCount++; |
| 19 | return reinterpret_cast<void *>(0x1234); |
| 20 | } |
| 21 | return nullptr; |
| 22 | } |
| 23 | uint32_t invocationCount = 0u; |
| 24 | }; |
| 25 | |
| 26 | TEST(SharingFactoryTests, givenVaFactoryWithSharingExtraWhenAskedThenAddressIsReturned) { |
| 27 | TestVaSharingBuilderFactory sharing; |
| 28 | |
| 29 | ASSERT_EQ(0u, sharing.invocationCount); |
| 30 | |
| 31 | auto ptr = sharing.getExtensionFunctionAddress("someFunction"); |
| 32 | EXPECT_NE(nullptr, ptr); |
| 33 | |
| 34 | EXPECT_EQ(1u, sharing.invocationCount); |
| 35 | } |