Skip to content

Commit eeb37fd

Browse files
committed
TEST/GTEST/UCT: PR fixes
1 parent 83021b3 commit eeb37fd

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

test/gtest/uct/test_atomic_key_reg_rdma_mem_type.cc

+15-20
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,28 @@ UCS_TEST_SKIP_COND_P(uct_atomic_key_reg_rdma_mem_type, fadd64,
3030
!check_atomics(UCS_BIT(UCT_ATOMIC_OP_ADD), FOP64) ||
3131
!check_rdma_memory())
3232
{
33-
mapped_buffer *recvbuf = nullptr;
34-
const size_t buffer_size = sizeof(uint64_t);
35-
const size_t buffer_offset = 0;
36-
const bool may_fail = true;
37-
const int num_retries = 5;
38-
const int sleep_usec = 10000;
33+
size_t buffer_size = sizeof(uint64_t);
34+
size_t buffer_offset = 0;
35+
bool may_fail = true;
36+
int num_retries = 5;
37+
int sleep_usec = 10000;
38+
std::unique_ptr<mapped_buffer> recvbuf;
3939

40-
for (int i = 0; i < num_retries; ++i) {
40+
for (int i = 0; (i < num_retries) && (nullptr == recvbuf.get()); ++i) {
4141
try {
42-
{
43-
scoped_log_handler slh(hide_errors_logger);
44-
recvbuf = new mapped_buffer(buffer_size, receiver(),
45-
buffer_offset, UCS_MEMORY_TYPE_RDMA,
46-
UCT_MD_MEM_ACCESS_ALL, may_fail);
47-
}
48-
break;
49-
} catch (ucs::test_abort_exception& e) {
42+
scoped_log_handler slh(hide_errors_logger);
43+
recvbuf.reset(new mapped_buffer(
44+
buffer_size, receiver(), buffer_offset,
45+
UCS_MEMORY_TYPE_RDMA, UCT_MD_MEM_ACCESS_ALL, may_fail));
46+
} catch (const ucs::test_abort_exception& e) {
5047
UCS_TEST_MESSAGE << "Retry " << i + 1 << "/" << num_retries
5148
<< ": Buffer allocation failed - " << e.what();
5249
usleep(sleep_usec);
5350
}
51+
}
5452

55-
if (i == (num_retries - 1)) {
56-
ADD_FAILURE() << "Failed to allocate buffer";
57-
}
53+
if (nullptr == recvbuf.get()) {
54+
ADD_FAILURE() << "Failed to allocate buffer";
5855
}
5956

6057
uint64_t add = rand64();
@@ -63,8 +60,6 @@ UCS_TEST_SKIP_COND_P(uct_atomic_key_reg_rdma_mem_type, fadd64,
6360
&uct_amo_test::atomic_fop<uint64_t, UCT_ATOMIC_OP_ADD>),
6461
*recvbuf, std::vector<uint64_t>(num_senders(), add), false);
6562
wait_for_remote();
66-
67-
delete recvbuf;
6863
}
6964

7065
UCT_INSTANTIATE_RC_DC_TEST_CASE(uct_atomic_key_reg_rdma_mem_type);

test/gtest/uct/uct_test.cc

+2
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,8 @@ void uct_test::entity::mem_alloc(size_t length, unsigned mem_flags,
964964
}
965965

966966
if (may_fail && (status != UCS_OK)) {
967+
UCS_TEST_MESSAGE << "Failed to allocate memory: "
968+
<< ucs_status_string(status);
967969
throw ucs::test_abort_exception();
968970
} else {
969971
ASSERT_UCS_OK(status);

0 commit comments

Comments
 (0)