Skip to content

Commit 1c42f2a

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

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-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/ipc_negative.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include "base.hpp"
2+
#include "pool_null.h"
3+
#include "provider_null.h"
4+
5+
#include <umf/ipc.h>
6+
#include <umf/memory_pool.h>
7+
#include <umf/memory_provider.h>
8+
9+
struct IpcNotSupported : umf_test::test {
10+
protected:
11+
void SetUp() override {
12+
umf_memory_provider_ops_t provider_ops = UMF_NULL_PROVIDER_OPS;
13+
provider_ops.ipc.get_ipc_handle_size = nullptr;
14+
provider_ops.ipc.get_ipc_handle = nullptr;
15+
provider_ops.ipc.open_ipc_handle = nullptr;
16+
provider_ops.ipc.put_ipc_handle = nullptr;
17+
provider_ops.ipc.close_ipc_handle = nullptr;
18+
19+
umf_result_t ret;
20+
ret = umfMemoryProviderCreate(&provider_ops, nullptr, &provider);
21+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
22+
23+
ret = umfPoolCreate(&UMF_NULL_POOL_OPS, provider, nullptr,
24+
UMF_POOL_CREATE_FLAG_OWN_PROVIDER, &pool);
25+
ASSERT_EQ(ret, UMF_RESULT_SUCCESS);
26+
}
27+
28+
umf_memory_provider_handle_t provider;
29+
umf_memory_pool_handle_t pool;
30+
};
31+
32+
TEST_F(IpcNotSupported, GetIPCHandleSizeNotSupported) {
33+
size_t size;
34+
auto ret = umfPoolGetIPCHandleSize(pool, &size);
35+
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
36+
}
37+
38+
TEST_F(IpcNotSupported, OpenIPCHandleNotSupported) {
39+
umf_ipc_handle_t ipc_handle = {};
40+
void *ptr;
41+
auto ret = umfOpenIPCHandle(pool, ipc_handle, &ptr);
42+
EXPECT_EQ(ret, UMF_RESULT_ERROR_NOT_SUPPORTED);
43+
}
44+
45+
TEST_F(IpcNotSupported, CloseIPCHandleInvalid) {
46+
int local_var;
47+
auto ret = umfCloseIPCHandle(&local_var);
48+
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);
49+
}

0 commit comments

Comments
 (0)