Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ endif()

add_umf_test(NAME ipc SRCS ipcAPI.cpp)

add_umf_test(NAME ipc_negative SRCS ipc_negative.cpp)

function(add_umf_ipc_test)
# Parameters: * TEST - a name of the test * SRC_DIR - source files directory
# path
Expand Down
6 changes: 6 additions & 0 deletions test/ipcFixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ TEST_P(umfIpcTest, GetIPCHandleInvalidArgs) {
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
}

TEST_P(umfIpcTest, CloseIPCHandleInvalidPtr) {
int local_var;
auto ret = umfCloseIPCHandle(&local_var);
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
}

TEST_P(umfIpcTest, BasicFlow) {
constexpr size_t SIZE = 100;
std::vector<int> expected_data(SIZE);
Expand Down
53 changes: 53 additions & 0 deletions test/ipc_negative.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (C) 2024 Intel Corporation
// Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "base.hpp"
#include "pool_null.h"
#include "provider_null.h"

#include <umf/ipc.h>
#include <umf/memory_pool.h>
#include <umf/memory_provider.h>

#include <array>

struct IpcNotSupported : umf_test::test {
protected:
void SetUp() override {
umf_memory_provider_ops_t provider_ops = UMF_NULL_PROVIDER_OPS;
provider_ops.ipc.get_ipc_handle_size = nullptr;
provider_ops.ipc.get_ipc_handle = nullptr;
provider_ops.ipc.open_ipc_handle = nullptr;
provider_ops.ipc.put_ipc_handle = nullptr;
provider_ops.ipc.close_ipc_handle = nullptr;

umf_result_t ret;
ret = umfMemoryProviderCreate(&provider_ops, nullptr, &provider);
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);

ret = umfPoolCreate(&UMF_NULL_POOL_OPS, provider, nullptr,
UMF_POOL_CREATE_FLAG_OWN_PROVIDER, &pool);
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
}

void TearDown() override { umfPoolDestroy(pool); }

umf_memory_provider_handle_t provider;
umf_memory_pool_handle_t pool;
};

TEST_F(IpcNotSupported, GetIPCHandleSizeNotSupported) {
size_t size;
auto ret = umfPoolGetIPCHandleSize(pool, &size);
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
}

TEST_F(IpcNotSupported, OpenIPCHandleNotSupported) {
// This data doesn't matter, as the ipc call is no-op
std::array<uint8_t, 128> ipc_data = {};
void *ptr;
auto ret = umfOpenIPCHandle(
pool, reinterpret_cast<umf_ipc_handle_t>(&ipc_data), &ptr);
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
}
Loading