Skip to content

Commit 13e302e

Browse files
committed
Simple IPC not supported tests
1 parent 80e55db commit 13e302e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ endif()
379379

380380
add_umf_test(NAME ipc SRCS ipcAPI.cpp)
381381

382+
add_umf_test(NAME ipc_negative SRCS ipc_negative.cpp)
383+
382384
function(add_umf_ipc_test)
383385
# Parameters: * TEST - a name of the test * SRC_DIR - source files directory
384386
# path

test/ipcFixtures.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ TEST_P(umfIpcTest, GetIPCHandleInvalidArgs) {
166166
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
167167
}
168168

169+
TEST_P(umfIpcTest, CloseIPCHandleInvalidPtr) {
170+
int local_var;
171+
auto ret = umfCloseIPCHandle(&local_var);
172+
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
173+
}
174+
169175
TEST_P(umfIpcTest, BasicFlow) {
170176
constexpr size_t SIZE = 100;
171177
std::vector<int> expected_data(SIZE);

test/ipc_negative.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
struct IpcNotSupported : umf_test::test {
14+
protected:
15+
void SetUp() override {
16+
umf_memory_provider_ops_t provider_ops = UMF_NULL_PROVIDER_OPS;
17+
provider_ops.ipc.get_ipc_handle_size = nullptr;
18+
provider_ops.ipc.get_ipc_handle = nullptr;
19+
provider_ops.ipc.open_ipc_handle = nullptr;
20+
provider_ops.ipc.put_ipc_handle = nullptr;
21+
provider_ops.ipc.close_ipc_handle = nullptr;
22+
23+
umf_result_t ret;
24+
ret = umfMemoryProviderCreate(&provider_ops, nullptr, &provider);
25+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
26+
27+
ret = umfPoolCreate(&UMF_NULL_POOL_OPS, provider, nullptr,
28+
UMF_POOL_CREATE_FLAG_OWN_PROVIDER, &pool);
29+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
30+
}
31+
32+
umf_memory_provider_handle_t provider;
33+
umf_memory_pool_handle_t pool;
34+
};
35+
36+
TEST_F(IpcNotSupported, GetIPCHandleSizeNotSupported) {
37+
size_t size;
38+
auto ret = umfPoolGetIPCHandleSize(pool, &size);
39+
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
40+
}
41+
42+
TEST_F(IpcNotSupported, OpenIPCHandleNotSupported) {
43+
umf_ipc_handle_t ipc_handle = {};
44+
void *ptr;
45+
auto ret = umfOpenIPCHandle(pool, ipc_handle, &ptr);
46+
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
47+
}

0 commit comments

Comments
 (0)