Skip to content

Commit

Permalink
Remove free_not_supp from the ipcTestParams tuple
Browse files Browse the repository at this point in the history
Remove free_not_supp from the ipcTestParams tuple.
It is not needed any more.

Signed-off-by: Lukasz Dorau <[email protected]>
  • Loading branch information
ldorau committed Nov 14, 2024
1 parent ef80099 commit 5842644
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 42 deletions.
2 changes: 1 addition & 1 deletion test/ipcAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ HostMemoryAccessor hostMemoryAccessor;
INSTANTIATE_TEST_SUITE_P(umfIpcTestSuite, umfIpcTest,
::testing::Values(ipcTestParams{
umfProxyPoolOps(), nullptr, &IPC_MOCK_PROVIDER_OPS,
nullptr, &hostMemoryAccessor, false}));
nullptr, &hostMemoryAccessor}));
44 changes: 12 additions & 32 deletions test/ipcFixtures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,23 @@ class HostMemoryAccessor : public MemoryAccessor {
};

// ipcTestParams:
// pool_ops, pool_params, provider_ops, provider_params, memoryAccessor, free_not_supp
// free_not_supp (bool) - provider does not support the free() op
// pool_ops, pool_params, provider_ops, provider_params, memoryAccessor
using ipcTestParams =
std::tuple<umf_memory_pool_ops_t *, void *, umf_memory_provider_ops_t *,
void *, MemoryAccessor *, bool>;
void *, MemoryAccessor *>;

struct umfIpcTest : umf_test::test,
::testing::WithParamInterface<ipcTestParams> {
umfIpcTest() {}
void SetUp() override {
test::SetUp();
auto [pool_ops, pool_params, provider_ops, provider_params, accessor,
free_not_supp] = this->GetParam();
auto [pool_ops, pool_params, provider_ops, provider_params, accessor] =
this->GetParam();
poolOps = pool_ops;
poolParams = pool_params;
providerOps = provider_ops;
providerParams = provider_params;
memAccessor = accessor;
freeNotSupported = free_not_supp;
}

void TearDown() override { test::TearDown(); }
Expand Down Expand Up @@ -124,18 +122,8 @@ struct umfIpcTest : umf_test::test,
void *poolParams = nullptr;
umf_memory_provider_ops_t *providerOps = nullptr;
void *providerParams = nullptr;
bool freeNotSupported = false;
};

static inline umf_result_t
get_umf_result_of_free(bool freeNotSupported, umf_result_t expected_result) {
if (freeNotSupported) {
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

return expected_result;
}

TEST_P(umfIpcTest, GetIPCHandleSize) {
size_t size = 0;
umf::pool_unique_handle_t pool = makePool();
Expand Down Expand Up @@ -177,8 +165,7 @@ TEST_P(umfIpcTest, GetIPCHandleInvalidArgs) {
EXPECT_EQ(ret, UMF_RESULT_ERROR_INVALID_ARGUMENT);

ret = umfFree(ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
}

TEST_P(umfIpcTest, CloseIPCHandleInvalidPtr) {
Expand Down Expand Up @@ -239,8 +226,7 @@ TEST_P(umfIpcTest, BasicFlow) {
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

ret = umfPoolFree(pool.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

pool.reset(nullptr);
EXPECT_EQ(stat.getCount, 1);
Expand Down Expand Up @@ -303,8 +289,7 @@ TEST_P(umfIpcTest, GetPoolByOpenedHandle) {

for (size_t i = 0; i < NUM_ALLOCS; ++i) {
umf_result_t ret = umfFree(ptrs[i]);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
}
}

Expand All @@ -330,8 +315,7 @@ TEST_P(umfIpcTest, AllocFreeAllocTest) {
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

ret = umfPoolFree(pool.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

ptr = umfPoolMalloc(pool.get(), SIZE);
ASSERT_NE(ptr, nullptr);
Expand All @@ -353,8 +337,7 @@ TEST_P(umfIpcTest, AllocFreeAllocTest) {
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

ret = umfPoolFree(pool.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

pool.reset(nullptr);
EXPECT_EQ(stat.getCount, stat.putCount);
Expand Down Expand Up @@ -405,8 +388,7 @@ TEST_P(umfIpcTest, openInTwoPools) {
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

ret = umfPoolFree(pool1.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);

pool1.reset(nullptr);
pool2.reset(nullptr);
Expand Down Expand Up @@ -457,8 +439,7 @@ TEST_P(umfIpcTest, ConcurrentGetPutHandles) {

for (void *ptr : ptrs) {
umf_result_t ret = umfPoolFree(pool.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
}

pool.reset(nullptr);
Expand Down Expand Up @@ -520,8 +501,7 @@ TEST_P(umfIpcTest, ConcurrentOpenCloseHandles) {

for (void *ptr : ptrs) {
umf_result_t ret = umfPoolFree(pool.get(), ptr);
EXPECT_EQ(ret,
get_umf_result_of_free(freeNotSupported, UMF_RESULT_SUCCESS));
EXPECT_EQ(ret, UMF_RESULT_SUCCESS);
}

pool.reset(nullptr);
Expand Down
6 changes: 3 additions & 3 deletions test/provider_devdax_memory_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ static std::vector<ipcTestParams> getIpcProxyPoolTestParamsList(void) {

ipcProxyPoolTestParamsList = {
{umfProxyPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
&defaultDevDaxParams, &hostAccessor, false},
&defaultDevDaxParams, &hostAccessor},
#ifdef UMF_POOL_JEMALLOC_ENABLED
{umfJemallocPoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
&defaultDevDaxParams, &hostAccessor, false},
&defaultDevDaxParams, &hostAccessor},
#endif
#ifdef UMF_POOL_SCALABLE_ENABLED
{umfScalablePoolOps(), nullptr, umfDevDaxMemoryProviderOps(),
&defaultDevDaxParams, &hostAccessor, false},
&defaultDevDaxParams, &hostAccessor},
#endif
};

Expand Down
6 changes: 3 additions & 3 deletions test/provider_file_memory_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ HostMemoryAccessor hostAccessor;
static std::vector<ipcTestParams> ipcManyPoolsTestParamsList = {
// TODO: enable it when sizes of allocations in ipcFixtures.hpp are fixed
// {umfProxyPoolOps(), nullptr, umfFileMemoryProviderOps(),
// &file_params_shared, &hostAccessor, false},
// &file_params_shared, &hostAccessor},
#ifdef UMF_POOL_JEMALLOC_ENABLED
{umfJemallocPoolOps(), nullptr, umfFileMemoryProviderOps(),
&file_params_shared, &hostAccessor, false},
&file_params_shared, &hostAccessor},
#endif
#ifdef UMF_POOL_SCALABLE_ENABLED
{umfScalablePoolOps(), nullptr, umfFileMemoryProviderOps(),
&file_params_shared, &hostAccessor, false},
&file_params_shared, &hostAccessor},
#endif
};

Expand Down
4 changes: 2 additions & 2 deletions test/provider_os_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,11 @@ umf_disjoint_pool_params_t disjointParams = disjointPoolParams();
static std::vector<ipcTestParams> ipcTestParamsList = {
#if (defined UMF_POOL_DISJOINT_ENABLED)
{umfDisjointPoolOps(), &disjointParams, umfOsMemoryProviderOps(),
&os_params, &hostAccessor, false},
&os_params, &hostAccessor},
#endif
#ifdef UMF_POOL_JEMALLOC_ENABLED
{umfJemallocPoolOps(), nullptr, umfOsMemoryProviderOps(), &os_params,
&hostAccessor, false},
&hostAccessor},
#endif
};

Expand Down
2 changes: 1 addition & 1 deletion test/providers/provider_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,5 @@ INSTANTIATE_TEST_SUITE_P(umfLevelZeroProviderTestSuite, umfIpcTest,
::testing::Values(ipcTestParams{
umfProxyPoolOps(), nullptr,
umfLevelZeroMemoryProviderOps(),
&l0Params_device_memory, &l0Accessor, false}));
&l0Params_device_memory, &l0Accessor}));
#endif

0 comments on commit 5842644

Please sign in to comment.