-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests for node_options usage * Add tests for copying options arguments * Add bad argument tests for wait sets * Add tests for wait_set_get_allocator function * Add test for rcl_take_response function * Change take_request to match take_response without info * Change specific test for sequence_number * Add tests for client take failed * Remove tests already done in nominal setup * Add bad arguments tests * Add test for init returning BAD_ALLOC * Add test for client get_options * Add test for already init client * Add bad argument tests * Add basic test get_default_domain_id * Add test for rmw to rcl return code function * Add test for get_localhost_only * Add tests for localhost expected usage * Address peer review comments * Add test for env variable leading to ULONG_MAX * Change return values to enum in test * Fix rcl_get_localhost_only return value * Address peer review comments * Add unexpected value to get_localhost * Add reset_rcl_error after expected fails Signed-off-by: Jorge Perez <[email protected]>
- Loading branch information
Showing
8 changed files
with
502 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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 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,41 @@ | ||
// 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; | ||
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); | ||
|
||
ASSERT_TRUE(rcutils_set_env("ROS_LOCALHOST_ONLY", "Unexpected")); | ||
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 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.