-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement subscription API functions #46
Conversation
std::array<std::uint8_t, 1024> mono{}; | ||
|
||
// Copy full size payload. | ||
std::generate(mono.begin(), mono.end(), [] { return std::rand() % 256; }); |
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.
To generate random test bits use std::independent_bits_engine
and be sure to provide a stable seed so the tests are reproducible. I tend to use googletest, value-parameterized for this where I run the test using a few seeds to really get the psedo-random mojo going but I'm fine with just using unity here and a single seed value.
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.
Indeed, I overlooked the seeding part. However, I think it would be unwise to use the C++ RNG utilities here because this is a C library and most of the test code is written in C, so in the interest of consistency and compatibility with future tests written in C, it is desirable to use rand()
. The quality of the random numbers matters little in this case.
I implemented seeding in the last commit.
UDPARD_ASSERT(frag->view.data != NULL); | ||
const size_t frag_size = smaller(frag->view.size, destination_size - offset); | ||
// NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) | ||
(void) memmove(((byte_t*) destination) + offset, frag->view.data, frag_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.
Do we define byte_t as unsigned char? I forgot if this was a local typedef or not.
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.
… C RNG utilities because this is a C library and most of the test code is written in C.
Kudos, SonarCloud Quality Gate passed! 0 Bugs 96.6% Coverage The version of Java (11.0.17) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17. |
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.
Sorry for the very late review, looks good! Excited to see the final API implemented and glad we added the udpardGather
function. Can't approve anymore, can only give you two thumbs up: 👍 👍
It is now possible to subscribe to subjects and receive data from them. The only missing bit is the RPC services API, all other functionality of the library is already implemented and can be used.
This changeset also brings
udpardGather
that, well, gathers a fragmented payload buffer into one contiguous chunk of memory that can be passed into Nunavut. Later we should amend Nunavut to support fragmented buffers directly to eliminate extra data copying and memory utilization.After the RPC services API is done, I am going to add comprehensive end-to-end tests, for which there is a stub already. Aside from that we also have this (the e2e test mentioned there is different though): #35
This changeset also fixes an internal documentation error that provided an incorrect estimation of the worst-case recursion depth.