Skip to content

Commit

Permalink
Perform fault injection in all creation/destruction APIs. (#453)
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored Oct 2, 2020
1 parent f887e5f commit 09b81c8
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions rmw_fastrtps_cpp/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "fastrtps/Domain.h"
#include "fastrtps/participant/Participant.h"

#include "rcutils/macros.h"

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/rmw.h"
Expand Down Expand Up @@ -52,6 +54,8 @@ rmw_fastrtps_cpp::create_publisher(
bool keyed,
bool create_publisher_listener)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);

RMW_CHECK_ARGUMENT_FOR_NULL(participant_info, nullptr);
RMW_CHECK_ARGUMENT_FOR_NULL(type_supports, nullptr);
RMW_CHECK_ARGUMENT_FOR_NULL(topic_name, nullptr);
Expand Down
3 changes: 3 additions & 0 deletions rmw_fastrtps_cpp/src/subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <utility>

#include "rcutils/allocator.h"
#include "rcutils/macros.h"
#include "rcutils/strdup.h"

#include "rmw/allocators.h"
Expand Down Expand Up @@ -58,6 +59,8 @@ create_subscription(
bool keyed,
bool create_subscription_listener)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);

RMW_CHECK_ARGUMENT_FOR_NULL(participant_info, nullptr);
RMW_CHECK_ARGUMENT_FOR_NULL(type_supports, nullptr);
RMW_CHECK_ARGUMENT_FOR_NULL(topic_name, nullptr);
Expand Down
7 changes: 5 additions & 2 deletions rmw_fastrtps_shared_cpp/src/participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ rmw_fastrtps_shared_cpp::create_participant(
const char * enclave,
rmw_dds_common::Context * common_context)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);

if (!security_options) {
RMW_SET_ERROR_MSG("security_options is null");
return nullptr;
Expand Down Expand Up @@ -261,7 +263,6 @@ rmw_fastrtps_shared_cpp::create_participant(
rmw_ret_t
rmw_fastrtps_shared_cpp::destroy_participant(CustomParticipantInfo * participant_info)
{
rmw_ret_t result_ret = RMW_RET_OK;
if (!participant_info) {
RMW_SET_ERROR_MSG("participant_info is null");
return RMW_RET_ERROR;
Expand All @@ -270,5 +271,7 @@ rmw_fastrtps_shared_cpp::destroy_participant(CustomParticipantInfo * participant
delete participant_info->listener;
participant_info->listener = nullptr;
delete participant_info;
return result_ret;

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return RMW_RET_OK;
}
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ destroy_publisher(
rmw_free(const_cast<char *>(publisher->topic_name));
rmw_publisher_free(publisher);

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return RMW_RET_OK;
}
} // namespace rmw_fastrtps_shared_cpp
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ __rmw_destroy_client(
rmw_free(const_cast<char *>(client->service_name));
rmw_client_free(client);

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return ret;
}
} // namespace rmw_fastrtps_shared_cpp
9 changes: 7 additions & 2 deletions rmw_fastrtps_shared_cpp/src/rmw_guard_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace rmw_fastrtps_shared_cpp
rmw_guard_condition_t *
__rmw_create_guard_condition(const char * identifier)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);

rmw_guard_condition_t * guard_condition_handle = new rmw_guard_condition_t;
guard_condition_handle->implementation_identifier = identifier;
guard_condition_handle->data = new GuardCondition();
Expand All @@ -33,12 +35,15 @@ __rmw_create_guard_condition(const char * identifier)
rmw_ret_t
__rmw_destroy_guard_condition(rmw_guard_condition_t * guard_condition)
{
rmw_ret_t ret = RMW_RET_ERROR;

if (guard_condition) {
delete static_cast<GuardCondition *>(guard_condition->data);
delete guard_condition;
return RMW_RET_OK;
ret = RMW_RET_OK;
}

return RMW_RET_ERROR;
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return ret;
}
} // namespace rmw_fastrtps_shared_cpp
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ __rmw_destroy_node(
rmw_free(const_cast<char *>(node->name));
rmw_free(const_cast<char *>(node->namespace_));
rmw_node_free(node);

return ret;
}

Expand Down
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ __rmw_destroy_service(
rmw_free(const_cast<char *>(service->service_name));
rmw_service_free(service);

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return ret;
}
} // namespace rmw_fastrtps_shared_cpp
5 changes: 5 additions & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "fastrtps/subscriber/Subscriber.h"

#include "rcutils/macros.h"

#include "rmw/error_handling.h"
#include "rmw/rmw.h"

Expand Down Expand Up @@ -99,6 +101,9 @@ __rmw_wait(
rmw_wait_set_t * wait_set,
const rmw_time_t * wait_timeout)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);
RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INCORRECT_RMW_IMPLEMENTATION);

RMW_CHECK_ARGUMENT_FOR_NULL(wait_set, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
wait set handle,
Expand Down
5 changes: 5 additions & 0 deletions rmw_fastrtps_shared_cpp/src/rmw_wait_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "rcutils/macros.h"

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/rmw.h"
Expand All @@ -26,6 +28,7 @@ namespace rmw_fastrtps_shared_cpp
rmw_wait_set_t *
__rmw_create_wait_set(const char * identifier, rmw_context_t * context, size_t max_conditions)
{
RCUTILS_CAN_RETURN_WITH_ERROR_OF(nullptr);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
Expand Down Expand Up @@ -96,6 +99,8 @@ __rmw_destroy_wait_set(const char * identifier, rmw_wait_set_t * wait_set)
rmw_free(wait_set->data);
}
rmw_wait_set_free(wait_set);

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return result;
}
} // namespace rmw_fastrtps_shared_cpp
1 change: 1 addition & 0 deletions rmw_fastrtps_shared_cpp/src/subscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ destroy_subscription(
rmw_free(const_cast<char *>(subscription->topic_name));
rmw_subscription_free(subscription);

RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR); // on completion
return ret;
}
} // namespace rmw_fastrtps_shared_cpp

0 comments on commit 09b81c8

Please sign in to comment.