Skip to content
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

Complete init/shutdown API test coverage. #107

Merged
merged 4 commits into from
Jul 1, 2020

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Jun 22, 2020

Precisely what the title says. Follow-up after #106.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic requested review from brawner and Blast545 June 22, 2020 15:18
@hidmic
Copy link
Contributor Author

hidmic commented Jun 22, 2020

These tests need ros2/rmw#242 and connected PRs to pass.

rmw_context_t context = rmw_get_zero_initialized_context();
rmw_init_options_t options = rmw_get_zero_initialized_init_options();
rmw_ret_t ret = rmw_init_options_init(&options, rcutils_get_default_allocator());
EXPECT_NE(RMW_RET_OK, rmw_shutdown(&context));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific error you are expecting? RMW_RET_ERROR?

Copy link
Contributor Author

@hidmic hidmic Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on rmw_shutdown() API contract, an RMW implementation could equally return RMW_RET_INVALID_ARGUMENT or RMW_RET_INCORRECT_IMPLEMENTATION. That's why I don't check for a specific return code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already test the incorrect_implementation error below, wouldn't it make more sense to test the invalid_argument error here? Set context.implementation_identifier to a known valid identifier, then check that it returns invalid argument?

Copy link
Contributor Author

@hidmic hidmic Jun 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, problem is that we get into bad initialization territory. Here I deal with the four (4) known context states: zero-initialized, initialized and not shutdown, initialized and shutdown, finalized. Anything outside that is UB. So if we want to be specific about the assertion we have to further clarify API contracts i.e. what it means for a context to be invalid for all rmw implementations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want to monkey around with the identifier field to force the invalid argument, then I recommend to at least narrow down the expect statement to only two errors you expect. Something like:

EXPECT_TRUE((ret == RMW_RET_INVALID_ARGUMENT || 
             ret == RMW_RET_INCORRECT_IMPLEMENTATION))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can do that. See 9bff7f2

@hidmic
Copy link
Contributor Author

hidmic commented Jun 22, 2020

CI up to test_rmw_implementation against all RMW implementations:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@hidmic
Copy link
Contributor Author

hidmic commented Jun 23, 2020

Hold on, as tests may change with ros2/rmw#243.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic requested a review from brawner June 24, 2020 22:55
@hidmic
Copy link
Contributor Author

hidmic commented Jun 24, 2020

Ready for re-review !

Copy link
Contributor

@Blast545 Blast545 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brawner
Copy link
Contributor

brawner commented Jun 25, 2020

Does this need to be retested on CI?

@hidmic
Copy link
Contributor Author

hidmic commented Jun 25, 2020

Does this need to be retested on CI?

More than that. RMW implementations have to be released into rolling after connected PRs are merged to get that PR job passing.

@hidmic
Copy link
Contributor Author

hidmic commented Jun 29, 2020

CI up to test_rmw_implementation against all RMW implementations:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic
Copy link
Contributor Author

hidmic commented Jun 29, 2020

Same as in #108, I'll hold off merging this until I've re-released RMWs so that rolling PR jobs pass.

@hidmic
Copy link
Contributor Author

hidmic commented Jul 1, 2020

@ros-pull-request-builder retest this please

@hidmic
Copy link
Contributor Author

hidmic commented Jul 1, 2020

Alright, all's green! Going in.

@hidmic hidmic merged commit 96ca972 into master Jul 1, 2020
@delete-merged-branch delete-merged-branch bot deleted the hidmic/rmw-init-shutdown-tests branch July 1, 2020 17:05
ahcorde pushed a commit that referenced this pull request Oct 9, 2020
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
ahcorde pushed a commit that referenced this pull request Oct 21, 2020
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants