|
| 1 | +// Copyright (C) 2024 Intel Corporation |
| 2 | +// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | + |
| 5 | +#include "base.hpp" |
| 6 | +#include "pool_null.h" |
| 7 | +#include "provider_null.h" |
| 8 | + |
| 9 | +#include <umf/ipc.h> |
| 10 | +#include <umf/memory_pool.h> |
| 11 | +#include <umf/memory_provider.h> |
| 12 | + |
| 13 | +#include <array> |
| 14 | + |
| 15 | +struct IpcNotSupported : umf_test::test { |
| 16 | + protected: |
| 17 | + void SetUp() override { |
| 18 | + umf_memory_provider_ops_t provider_ops = UMF_NULL_PROVIDER_OPS; |
| 19 | + provider_ops.ipc.get_ipc_handle_size = nullptr; |
| 20 | + provider_ops.ipc.get_ipc_handle = nullptr; |
| 21 | + provider_ops.ipc.open_ipc_handle = nullptr; |
| 22 | + provider_ops.ipc.put_ipc_handle = nullptr; |
| 23 | + provider_ops.ipc.close_ipc_handle = nullptr; |
| 24 | + |
| 25 | + umf_result_t ret; |
| 26 | + ret = umfMemoryProviderCreate(&provider_ops, nullptr, &provider); |
| 27 | + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); |
| 28 | + |
| 29 | + ret = umfPoolCreate(&UMF_NULL_POOL_OPS, provider, nullptr, |
| 30 | + UMF_POOL_CREATE_FLAG_OWN_PROVIDER, &pool); |
| 31 | + ASSERT_EQ(ret, UMF_RESULT_SUCCESS); |
| 32 | + } |
| 33 | + |
| 34 | + void TearDown() override { umfPoolDestroy(pool); } |
| 35 | + |
| 36 | + umf_memory_provider_handle_t provider; |
| 37 | + umf_memory_pool_handle_t pool; |
| 38 | +}; |
| 39 | + |
| 40 | +TEST_F(IpcNotSupported, GetIPCHandleSizeNotSupported) { |
| 41 | + size_t size; |
| 42 | + auto ret = umfPoolGetIPCHandleSize(pool, &size); |
| 43 | + EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED); |
| 44 | +} |
| 45 | + |
| 46 | +TEST_F(IpcNotSupported, OpenIPCHandleNotSupported) { |
| 47 | + // This data doesn't matter, as the ipc call is no-op |
| 48 | + std::array<uint8_t, 128> ipc_data = {}; |
| 49 | + void *ptr; |
| 50 | + auto ret = umfOpenIPCHandle( |
| 51 | + pool, reinterpret_cast<umf_ipc_handle_t>(&ipc_data), &ptr); |
| 52 | + EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED); |
| 53 | +} |
0 commit comments