-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TEST/PROTO: Reset request tests for offset = 0 #9553
Conversation
7991dca
to
20f3869
Compare
test/gtest/ucp/test_ucp_request.cc
Outdated
|
||
static void flushed_cb(ucp_request_t *request) | ||
{ | ||
test_proto_reset *self = (test_proto_reset*)request->user_data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: C++ static_cast instead of C-cast would be more idiomatic here
test/gtest/ucp/test_ucp_request.cc
Outdated
ucp_request_release(request); | ||
} | ||
|
||
void send_nb(std::vector<char> &sbuf, std::vector<char> *rbuf_p, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not to pass rbuf by reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changed (using mapped_buffer now)
test/gtest/ucp/test_ucp_request.cc
Outdated
ucp_request_param_t param = {0}; | ||
void *rreq = NULL; | ||
void *sreq = NULL; | ||
std::vector<char> &rbuf = *rbuf_p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable seems to be redundant
test/gtest/ucp/test_ucp_request.cc
Outdated
return UCS_OK; | ||
} | ||
|
||
void *send_am(std::vector<char> &sbuf, std::vector<char> *rbuf_p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better pass rbuf by reference here?
test/gtest/ucp/test_ucp_request.cc
Outdated
{ | ||
std::vector<char> *rbuf = (std::vector<char>*)arg; | ||
|
||
memcpy((*rbuf).data(), data, length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid this might not be always safe, what if vector size is smaller than length?
better alternative is to use std::vector::assign(data, data + length)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rbuf was changed to be a mapped_buffer object so instead I added an assertion on the size
test/gtest/ucp/test_ucp_request.cc
Outdated
continue; | ||
} | ||
|
||
memcpy(&rbuf[roffset], rdata, length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it's not safe to append elements to vector like that, it disrespects vector invariants.
Why not using std::vector::insert that accepts a range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use a different API now (ucp_stream_recv_nbx) so memcpy is not needed at all
test/gtest/ucp/test_ucp_request.cc
Outdated
void *rreq = NULL; | ||
void *sreq = NULL; | ||
std::vector<char> &rbuf = *rbuf_p; | ||
sbuf.resize(m_msg_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe here we can just reserve
, not resize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code was changed (now init the array inside a for loop).
3581fd8
to
bca427b
Compare
What
Reset request tests for offset = 0
Why ?
First phase for reset in the middle PR.