Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Adding tests to arguments.c #752
Adding tests to arguments.c #752
Changes from 9 commits
e1b3b79
95c07a6
27ce30c
d672046
80850b6
7ba3c2f
af3adb5
2d43cd8
2ac0015
cf35778
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Where is
get_time_bombed_allocator
coming from? It's not spelled correctly, but secondly I don't see an appropriate include.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 added that allocator with #743. As it also tested
arguments.c
it's already included in `test_arguments.cpp'.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.
Oh, I didn't look at allocator_testing_utils.h close enough. Thanks for the info! But it should be
get_time_bomb_allocator
, "time_bombed" doesn't make a ton of sense. Feel free to fix in a follow-up PR.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.
@Blast545 nit: missing error state check/reset?
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.
All the allocator tests added return that error without actually setting the error state. However, other bad allocators through the arguments file do set them. I was wondering that this should be standardized based on the open conversations of error check/handling.
Should I add a
rcl_reset_error()
to be "safe" even when the error is not expected in the meantime?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.
Yeah, it should be standardized. Let's defer it to follow-up PRs.
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.
Bad alloc check, pending standarization
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.
@Blast545 nit: missing error state check/reset?
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.
Bad alloc check, pending standarization
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.
@Blast545 nit: missing error state/reset?
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.
Added only a reset to match the rest of the old tests in the group, see cf35778
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.
@Blast545 nit: here and below, missing error state check/reset?
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.
Added a check + reset cf35778
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.
@Blast545 nit: missing error state check/reset?
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.
As this is intended to be robust, I added a
reset_error
here. cf35778There 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.
@Blast545 meta: hmm, I wonder if this isn't better suited for fault injection. That magic
9
is a bit fragile.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 am working on a followup PR to rcutils that will include a fault_injection_allocator that accomplishes similar functionality to the time_bomb_allocator. If you think that would be useful to this PR, I can prioritize that.
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.
@hidmic I agree it's somewhat fragile. In fact I was considering some sort of macro for testing functions that received allocators to iterate until the test passed. Although probably the fault injection approach will be better in the long run, and that's why I left the fixed number for this PR.
@brawner I'm not fully familiarized yet with the fault_injection tools you are working at the moment. Although I imagined the injection tools to be included in the
default_allocator
used through the ROS 2 code to be able of testing bad allocator fails like this one.We can always merge this PR and updated it with injection tools once these are ready, WDYT @brawner @hidmic ?
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.
That is probably a better approach. While most C code requires passing in an allocator, I think some c++ code just uses the default allocator blindly.
To make the test a little less fragile, you can do something like:
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.
Err, edited to change the 9 in for loop to something large, like 100.
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.
With the missing break, right?
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.
Oooh, good idea. I like it
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.
Done 2ac0015