Skip to content

Commit

Permalink
Fix qos tests
Browse files Browse the repository at this point in the history
* Refactor test_events
** Change EXPECT_EQ argument order for consistency
* Amend actual_qos tests

Signed-off-by: Ross Desmond <44277324+ross-desmond@users.noreply.github.com>
  • Loading branch information
ross-desmond committed Apr 11, 2019
1 parent deb6cd9 commit 7b88f59
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 119 deletions.
26 changes: 26 additions & 0 deletions rcl/include/rcl/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,32 @@ RCL_WARN_UNUSED
rcl_ret_t
rcl_node_get_domain_id(const rcl_node_t * node, size_t * domain_id);

/// Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE)
/**
* If the rmw Liveliness policy is set to RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE, the creator of
* this node may manually call `assert_liveliness` at some point in time to signal to the rest
* of the system that this Node is still alive.
* This function must be called at least as often as the qos_profile's liveliness_lease_duration
*
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] node handle to the node that needs liveliness to be asserted
* \return `RCL_RET_OK` if the liveliness assertion was completed successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
* \return `RCL_RET_NODE_INVALID` if the node is invalid, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
*/
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_node_assert_liveliness(const rcl_node_t * node);

/// Return the rmw node handle.
/**
* The handle returned is a pointer to the internally held rmw handle.
Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ rcl_take_event(
}
if (!taken) {
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "take_event request complete, unable to take event");
ROS_PACKAGE_NAME, "take_event request complete, unable to take event");
return RCL_RET_EVENT_TAKE_FAILED;
}
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "take_event request success");
ROS_PACKAGE_NAME, "take_event request success");
return rcl_convert_rmw_ret_to_rcl_ret(ret);
}

Expand Down
13 changes: 13 additions & 0 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,19 @@ rcl_node_get_domain_id(const rcl_node_t * node, size_t * domain_id)
return RCL_RET_OK;
}

rcl_ret_t
rcl_node_assert_liveliness(const rcl_node_t * node)
{
if (!rcl_node_is_valid(node)) {
return RCL_RET_NODE_INVALID; // error already set
}
if (rmw_node_assert_liveliness(node->impl->rmw_node_handle) != RMW_RET_OK) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
return RCL_RET_ERROR;
}
return RCL_RET_OK;
}

rmw_node_t *
rcl_node_get_rmw_handle(const rcl_node_t * node)
{
Expand Down
2 changes: 1 addition & 1 deletion rcl/test/rcl/test_count_matched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ TEST_F(CLASSNAME(TestCountFixture, RMW_IMPLEMENTATION),

rcl_subscription_t sub = rcl_get_zero_initialized_subscription();

rcl_subscription_options_t sub_ops;
rcl_subscription_options_t sub_ops = rcl_subscription_get_default_options();
sub_ops.qos.history = RMW_QOS_POLICY_HISTORY_KEEP_LAST;
sub_ops.qos.depth = 10;
sub_ops.qos.reliability = RMW_QOS_POLICY_RELIABILITY_RELIABLE;
Expand Down
Loading

0 comments on commit 7b88f59

Please sign in to comment.