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.
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.
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.
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.
… C RNG utilities because this is a C library and most of the test code is written in C.
|
Kudos, SonarCloud Quality Gate passed!
|
lydia-at-amazon
left a comment
There was a problem hiding this comment.
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
udpardGatherthat, 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.