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

[foxy backport] Backport all unit tests and bug fixes, feature branch #1383

Merged
merged 61 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a94f6b3
Throw exception if rcl_timer_init fails (#1179)
brawner Jun 22, 2020
d932076
Check period duration in create_wall_timer (#1178)
brawner Jun 18, 2020
0ee47ef
Fix rclcpp::NodeOptions::operator= (#1211)
hidmic Jul 2, 2020
7cb96ed
Add unit tests for logging functionality (#1184)
brawner Jun 19, 2020
ba38c4f
Unit tests for some header-only functions/classes (#1181)
brawner Jun 22, 2020
0580a3a
Unit tests for node interfaces (#1202)
brawner Jul 1, 2020
81641b6
Unit tests for allocator_memory_strategy.hpp (#1197)
brawner Jul 14, 2020
b1c4166
Unit tests for allocator_memory_strategy.cpp part 2 (#1198)
brawner Jul 15, 2020
9cf088b
Add unit test for static_executor_entities_collector (#1221)
brawner Jul 15, 2020
621d3bd
[foxy backport] Derive and throw exception in spin_some spin_all for …
brawner Oct 7, 2020
6660139
[foxy backport] Parameterize test executors for all executor types (#…
brawner Oct 7, 2020
dbf9a19
EXPECT_THROW_EQ and ASSERT_THROW_EQ macros for unittests (#1232)
brawner Jul 17, 2020
d5720da
Unittests for memory strategy files, except allocator_memory_strategy…
brawner Jul 20, 2020
9c43879
fix node graph test with Connext and CycloneDDS returning actual data…
dirk-thomas Jul 28, 2020
fea538f
fix failing test with Connext since it doesn't wait for discovery (#1…
dirk-thomas Jul 30, 2020
a5ffa3a
Adjust test_static_executor_entities_collector for rmw_connext_cpp (#…
brawner Jul 31, 2020
12aeba2
Increase timeouts for connext for long tests (#1253)
brawner Aug 3, 2020
93839e1
Simplify and fix allocator memory strategy unit test for connext (#1252)
brawner Aug 4, 2020
8272a8c
Ability to configure domain_id via InitOptions. (#1165)
fujitatomoya Aug 5, 2020
ae4bb5c
initialize_logging_ should be copied. (#1272)
fujitatomoya Aug 11, 2020
33575ed
Fixes for unit tests that fail under cyclonedds (#1270)
brawner Aug 11, 2020
a1ceffb
fix topic stats test, wait for more messages, only check the ones wit…
dirk-thomas Aug 13, 2020
dca9f6c
Refactor Subscription Topic Statistics Tests (#1281)
dabonnie Aug 20, 2020
31c4273
Adding tests basic getters (#1291)
Blast545 Sep 9, 2020
c82c70d
Replace std_msgs with test_msgs in executors test (#1310)
jacobperron Sep 11, 2020
0dc7b27
Add tests type_support module (#1308)
Blast545 Sep 15, 2020
db37a32
Add coverage for wait_set_policies (#1316)
brawner Sep 18, 2020
fce59a2
Increase coverage of node_interfaces, including with mocking rcl erro…
brawner Sep 22, 2020
53b0aa9
Add coverage tests context functions (#1321)
Blast545 Sep 22, 2020
6959698
Add coverage for missing API (except executors) (#1326)
brawner Sep 23, 2020
bad0460
Increase coverage of publisher/subscription API (#1325)
brawner Sep 24, 2020
9aed2ec
[foxy backport] Add ostream test for FutureReturnCode (#1327) (#1393)
brawner Oct 9, 2020
a350fd0
Increase service coverage (#1332)
brawner Sep 28, 2020
9e59de0
Add coverage for client API (#1329)
brawner Sep 28, 2020
44b8bf4
[foxy backport] Add executor unit tests #1336 (#1395)
brawner Oct 9, 2020
436f2ce
Add coverage tests graph_listener (#1330)
Blast545 Sep 28, 2020
af16b38
Add in more coverage for expand_topic_or_service_name. (#1346)
clalancette Sep 29, 2020
5619a4b
Add tests for node_options API (#1343)
brawner Sep 29, 2020
739db14
Add in two more tests for expand_topic_or_service_name. (#1350)
clalancette Sep 29, 2020
ad9dd39
Add in more tests for the utilities. (#1349)
clalancette Sep 29, 2020
d006452
Complete coverage of Parameter and ParameterValue API (#1344)
brawner Sep 29, 2020
1cba93b
Test the remaining node public API (#1342)
brawner Sep 29, 2020
a339d73
Add in more tests for init_options coverage. (#1353)
clalancette Sep 30, 2020
65b907f
Improved test_subscription_options (#1358)
ahcorde Sep 30, 2020
39a9d1d
Covered resolve_use_intra_process (#1359)
ahcorde Sep 30, 2020
e283630
Improved test publisher - zero qos history depth value exception (#1360)
ahcorde Sep 30, 2020
5cdff01
Minor fixes to the parameter_service.cpp file.
clalancette Sep 30, 2020
3aeedf6
Add in additional tests for parameter_client.cpp coverage.
clalancette Sep 30, 2020
e1b86e4
Add timer coverage tests (#1363)
Blast545 Sep 30, 2020
580d36b
Add time API coverage tests (#1347)
Blast545 Sep 30, 2020
1d67840
Add test for ParameterService (#1355)
brawner Sep 30, 2020
0164217
Only exchange intra_process waitable if nonnull (#1317)
brawner Sep 17, 2020
c71f8b6
Finish API coverage on executors. (#1364)
clalancette Sep 30, 2020
85d809c
Finish coverage of publisher API (#1365)
brawner Sep 30, 2020
5706243
Add unit tests for qos and qos_event files (#1352)
brawner Sep 30, 2020
01d4d5b
Tests for LoanedMessage with mocked loaned message publisher (#1366)
brawner Oct 1, 2020
90f0a5e
Increase coverage of guard_condition.cpp to 100% (#1369)
brawner Oct 1, 2020
7b7c491
Increase coverage of WaitSetTemplate (#1368)
brawner Oct 1, 2020
a4b0442
Make sure to clean the external client/service handle. (#1296)
Oct 5, 2020
7060b8b
Increase test timeouts of slow running tests with rmw_connext_cpp (#1…
brawner Oct 14, 2020
6bd52ae
Clear members for StaticExecutorEntitiesCollector to avoid shared_ptr…
Oct 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions rclcpp/include/rclcpp/create_timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ create_timer(
* \tparam DurationRepT
* \tparam DurationT
* \tparam CallbackT
* \param period period to exectute callback
* \param period period to execute callback. This duration must be 0 <= period < nanoseconds::max()
* \param callback callback to execute via the timer period
* \param group
* \param node_base
* \param node_timers
* \return
* \throws std::invalid argument if either node_base or node_timers
* are null
* are null, or period is negative or too large
*/
template<typename DurationRepT, typename DurationT, typename CallbackT>
typename rclcpp::WallTimer<CallbackT>::SharedPtr
Expand All @@ -102,10 +102,38 @@ create_wall_timer(
throw std::invalid_argument{"input node_timers cannot be null"};
}

if (period < std::chrono::duration<DurationRepT, DurationT>::zero()) {
throw std::invalid_argument{"timer period cannot be negative"};
}

// Casting to a double representation might lose precision and allow the check below to succeed
// but the actual cast to nanoseconds fail. Using 1 DurationT worth of nanoseconds less than max.
constexpr auto maximum_safe_cast_ns =
std::chrono::nanoseconds::max() - std::chrono::duration<DurationRepT, DurationT>(1);

// If period is greater than nanoseconds::max(), the duration_cast to nanoseconds will overflow
// a signed integer, which is undefined behavior. Checking whether any std::chrono::duration is
// greater than nanoseconds::max() is a difficult general problem. This is a more conservative
// version of Howard Hinnant's (the <chrono> guy>) response here:
// https://stackoverflow.com/a/44637334/2089061
// However, this doesn't solve the issue for all possible duration types of period.
// Follow-up issue: https://github.com/ros2/rclcpp/issues/1177
constexpr auto ns_max_as_double =
std::chrono::duration_cast<std::chrono::duration<double, std::chrono::nanoseconds::period>>(
maximum_safe_cast_ns);
if (period > ns_max_as_double) {
throw std::invalid_argument{
"timer period must be less than std::chrono::nanoseconds::max()"};
}

const auto period_ns = std::chrono::duration_cast<std::chrono::nanoseconds>(period);
if (period_ns < std::chrono::nanoseconds::zero()) {
throw std::runtime_error{
"Casting timer period to nanoseconds resulted in integer overflow."};
}

auto timer = rclcpp::WallTimer<CallbackT>::make_shared(
std::chrono::duration_cast<std::chrono::nanoseconds>(period),
std::move(callback),
node_base->get_context());
period_ns, std::move(callback), node_base->get_context());
node_timers->add_timer(timer, group);
return timer;
}
Expand Down
1 change: 1 addition & 0 deletions rclcpp/src/rclcpp/node_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ NodeOptions::operator=(const NodeOptions & other)
this->allow_undeclared_parameters_ = other.allow_undeclared_parameters_;
this->automatically_declare_parameters_from_overrides_ =
other.automatically_declare_parameters_from_overrides_;
this->node_options_.reset();
}
return *this;
}
Expand Down
14 changes: 5 additions & 9 deletions rclcpp/src/rclcpp/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,11 @@ TimerBase::TimerBase(
rcl_clock_t * clock_handle = clock_->get_clock_handle();
{
std::lock_guard<std::mutex> clock_guard(clock_->get_clock_mutex());
if (
rcl_timer_init(
timer_handle_.get(), clock_handle, rcl_context.get(), period.count(), nullptr,
rcl_get_default_allocator()) != RCL_RET_OK)
{
RCUTILS_LOG_ERROR_NAMED(
"rclcpp",
"Couldn't initialize rcl timer handle: %s\n", rcl_get_error_string().str);
rcl_reset_error();
rcl_ret_t ret = rcl_timer_init(
timer_handle_.get(), clock_handle, rcl_context.get(), period.count(), nullptr,
rcl_get_default_allocator());
if (ret != RCL_RET_OK) {
rclcpp::exceptions::throw_from_rcl_error(ret, "Couldn't initialize rcl timer handle");
}
}
}
Expand Down
84 changes: 84 additions & 0 deletions rclcpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ rosidl_generate_interfaces(${PROJECT_NAME}_test_msgs
SKIP_INSTALL
)

ament_add_gtest(test_allocator_memory_strategy rclcpp/strategies/test_allocator_memory_strategy.cpp)
if(TARGET test_allocator_memory_strategy)
ament_target_dependencies(test_allocator_memory_strategy
"rcl"
"test_msgs"
)
target_link_libraries(test_allocator_memory_strategy ${PROJECT_NAME})
endif()
ament_add_gtest(test_any_service_callback rclcpp/test_any_service_callback.cpp)
if(TARGET test_any_service_callback)
ament_target_dependencies(test_any_service_callback
"test_msgs"
)
target_link_libraries(test_any_service_callback ${PROJECT_NAME})
endif()
ament_add_gtest(test_any_subscription_callback rclcpp/test_any_subscription_callback.cpp)
if(TARGET test_any_subscription_callback)
ament_target_dependencies(test_any_subscription_callback
"test_msgs"
)
target_link_libraries(test_any_subscription_callback ${PROJECT_NAME})
endif()
ament_add_gtest(test_client rclcpp/test_client.cpp)
if(TARGET test_client)
ament_target_dependencies(test_client
Expand All @@ -39,6 +61,13 @@ if(TARGET test_create_timer)
target_link_libraries(test_create_timer ${PROJECT_NAME})
target_include_directories(test_create_timer PRIVATE rclcpp/)
endif()
ament_add_gtest(test_create_subscription rclcpp/test_create_subscription.cpp)
if(TARGET test_create_subscription)
target_link_libraries(test_create_subscription ${PROJECT_NAME})
ament_target_dependencies(test_create_subscription
"test_msgs"
)
endif()
ament_add_gtest(test_expand_topic_or_service_name rclcpp/test_expand_topic_or_service_name.cpp)
if(TARGET test_expand_topic_or_service_name)
ament_target_dependencies(test_expand_topic_or_service_name
Expand Down Expand Up @@ -115,6 +144,52 @@ ament_add_gtest(test_node_interfaces__get_node_interfaces
if(TARGET test_node_interfaces__get_node_interfaces)
target_link_libraries(test_node_interfaces__get_node_interfaces ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_base
rclcpp/node_interfaces/test_node_base.cpp)
if(TARGET test_node_interfaces__node_base)
target_link_libraries(test_node_interfaces__node_base ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_clock
rclcpp/node_interfaces/test_node_clock.cpp)
if(TARGET test_node_interfaces__node_clock)
target_link_libraries(test_node_interfaces__node_clock ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_graph
rclcpp/node_interfaces/test_node_graph.cpp)
if(TARGET test_node_interfaces__node_graph)
ament_target_dependencies(
test_node_interfaces__node_graph
"test_msgs")
target_link_libraries(test_node_interfaces__node_graph ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_parameters
rclcpp/node_interfaces/test_node_parameters.cpp)
if(TARGET test_node_interfaces__node_parameters)
target_link_libraries(test_node_interfaces__node_parameters ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_services
rclcpp/node_interfaces/test_node_services.cpp)
if(TARGET test_node_interfaces__node_services)
target_link_libraries(test_node_interfaces__node_services ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_timers
rclcpp/node_interfaces/test_node_timers.cpp)
if(TARGET test_node_interfaces__node_timers)
target_link_libraries(test_node_interfaces__node_timers ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_topics
rclcpp/node_interfaces/test_node_topics.cpp)
if(TARGET test_node_interfaces__node_topics)
ament_target_dependencies(
test_node_interfaces__node_topics
"test_msgs")
target_link_libraries(test_node_interfaces__node_topics ${PROJECT_NAME})
endif()
ament_add_gtest(test_node_interfaces__node_waitables
rclcpp/node_interfaces/test_node_waitables.cpp)
if(TARGET test_node_interfaces__node_waitables)
target_link_libraries(test_node_interfaces__node_waitables ${PROJECT_NAME})
endif()

# TODO(wjwwood): reenable these build failure tests when I can get Jenkins to ignore their output
# rclcpp_add_build_failure_test(build_failure__get_node_topics_interface_const_ref_rclcpp_node
Expand Down Expand Up @@ -391,6 +466,15 @@ if(TARGET test_multi_threaded_executor)
target_link_libraries(test_multi_threaded_executor ${PROJECT_NAME})
endif()

ament_add_gtest(test_static_executor_entities_collector rclcpp/executors/test_static_executor_entities_collector.cpp
APPEND_LIBRARY_DIRS "${append_library_dirs}")
if(TARGET test_static_executor_entities_collector)
ament_target_dependencies(test_static_executor_entities_collector
"rcl"
"test_msgs")
target_link_libraries(test_static_executor_entities_collector ${PROJECT_NAME})
endif()

ament_add_gtest(test_guard_condition rclcpp/test_guard_condition.cpp
APPEND_LIBRARY_DIRS "${append_library_dirs}")
if(TARGET test_guard_condition)
Expand Down
Loading