-
Notifications
You must be signed in to change notification settings - Fork 181
Add tests for rcl package #668
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
ecfc2b3
Add tests for node_options usage
Blast545 1084f0f
Add tests for copying options arguments
Blast545 71d6bde
Add bad argument tests for wait sets
Blast545 9d0955b
Add tests for wait_set_get_allocator function
Blast545 72bc2ef
Add test for rcl_take_response function
Blast545 1282e4b
Change take_request to match take_response without info
Blast545 0976bcd
Change specific test for sequence_number
Blast545 bfda844
Add tests for client take failed
Blast545 c372d41
Remove tests already done in nominal setup
Blast545 2a901bd
Add bad arguments tests
Blast545 3377c03
Add test for init returning BAD_ALLOC
Blast545 e1af38d
Add test for client get_options
Blast545 a77e9df
Add test for already init client
Blast545 947a2e0
Add bad argument tests
Blast545 ec170f2
Add basic test get_default_domain_id
Blast545 606dcaa
Add test for rmw to rcl return code function
Blast545 4257a65
Add test for get_localhost_only
Blast545 04808dd
Add tests for localhost expected usage
Blast545 c32346d
Address peer review comments
Blast545 9b91db6
Add test for env variable leading to ULONG_MAX
Blast545 526c8a6
Change return values to enum in test
Blast545 7225695
Fix rcl_get_localhost_only return value
Blast545 259525e
Address peer review comments
Blast545 4932935
Add unexpected value to get_localhost
Blast545 7715e96
Add reset_rcl_error after expected fails
Blast545 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright 2020 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "rcl/rcl.h" | ||
| #include "./common.h" | ||
|
|
||
| // This function is not part of the public API | ||
| TEST(TestCommonFunctionality, test_rmw_ret_to_rcl_ret) { | ||
| EXPECT_EQ(RCL_RET_OK, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_OK)); | ||
| EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_INVALID_ARGUMENT)); | ||
| EXPECT_EQ(RCL_RET_BAD_ALLOC, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_BAD_ALLOC)); | ||
| EXPECT_EQ(RCL_RET_UNSUPPORTED, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_UNSUPPORTED)); | ||
| EXPECT_EQ( | ||
| RCL_RET_NODE_NAME_NON_EXISTENT, | ||
| rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_NODE_NAME_NON_EXISTENT)); | ||
|
|
||
| // Default behavior | ||
| EXPECT_EQ(RCL_RET_ERROR, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_ERROR)); | ||
| EXPECT_EQ(RCL_RET_ERROR, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_TIMEOUT)); | ||
| EXPECT_EQ(RCL_RET_ERROR, rcl_convert_rmw_ret_to_rcl_ret(RMW_RET_INCORRECT_RMW_IMPLEMENTATION)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright 2020 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "rcl/rcl.h" | ||
|
|
||
| #include "rcl/domain_id.h" | ||
| #include "rcl/error_handling.h" | ||
| #include "rcutils/env.h" | ||
|
|
||
| TEST(TestGetDomainId, test_nominal) { | ||
| ASSERT_TRUE(rcutils_set_env("ROS_DOMAIN_ID", "42")); | ||
| size_t domain_id = 0u; | ||
| EXPECT_EQ(RCL_RET_OK, rcl_get_default_domain_id(&domain_id)); | ||
| EXPECT_EQ(42u, domain_id); | ||
|
|
||
| ASSERT_TRUE(rcutils_set_env("ROS_DOMAIN_ID", "998446744073709551615")); | ||
| domain_id = 0u; | ||
| EXPECT_EQ(RCL_RET_ERROR, rcl_get_default_domain_id(&domain_id)); | ||
| rcl_reset_error(); | ||
| EXPECT_EQ(0u, domain_id); | ||
|
|
||
| EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, rcl_get_default_domain_id(nullptr)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Copyright 2020 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "rcl/rcl.h" | ||
| #include "rcl/localhost.h" | ||
| #include "rmw/localhost.h" | ||
| #include "rcutils/env.h" | ||
|
|
||
| TEST(TestLocalhost, test_get_localhost_only) { | ||
| ASSERT_TRUE(rcutils_set_env("ROS_LOCALHOST_ONLY", "0")); | ||
| rmw_localhost_only_t localhost_var; | ||
Blast545 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| EXPECT_EQ(RCL_RET_OK, rcl_get_localhost_only(&localhost_var)); | ||
| EXPECT_EQ(RMW_LOCALHOST_ONLY_DISABLED, localhost_var); | ||
|
|
||
| ASSERT_TRUE(rcutils_set_env("ROS_LOCALHOST_ONLY", "1")); | ||
| EXPECT_EQ(RCL_RET_OK, rcl_get_localhost_only(&localhost_var)); | ||
| EXPECT_EQ(RMW_LOCALHOST_ONLY_ENABLED, localhost_var); | ||
|
|
||
| ASSERT_TRUE(rcutils_set_env("ROS_LOCALHOST_ONLY", "2")); | ||
| EXPECT_EQ(RCL_RET_OK, rcl_get_localhost_only(&localhost_var)); | ||
| EXPECT_EQ(RMW_LOCALHOST_ONLY_DISABLED, localhost_var); | ||
|
|
||
| EXPECT_EQ(RCL_RET_INVALID_ARGUMENT, rcl_get_localhost_only(nullptr)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.