From ea03c0b0dac8f08e060a20db24ce060be1534fc9 Mon Sep 17 00:00:00 2001
From: Michel Hidalgo <michel@ekumenlabs.com>
Date: Tue, 22 Sep 2020 11:06:30 -0300
Subject: [PATCH] Inject faults on __rmw_publish() and run_listener_thread()
 call.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
---
 rmw_fastrtps_shared_cpp/src/listener_thread.cpp | 2 ++
 rmw_fastrtps_shared_cpp/src/rmw_publish.cpp     | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/rmw_fastrtps_shared_cpp/src/listener_thread.cpp b/rmw_fastrtps_shared_cpp/src/listener_thread.cpp
index 50be5b3da..b4bb435ce 100644
--- a/rmw_fastrtps_shared_cpp/src/listener_thread.cpp
+++ b/rmw_fastrtps_shared_cpp/src/listener_thread.cpp
@@ -44,6 +44,8 @@ node_listener(rmw_context_t * context);
 rmw_ret_t
 rmw_fastrtps_shared_cpp::run_listener_thread(rmw_context_t * context)
 {
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR);
+
   auto common_context = static_cast<rmw_dds_common::Context *>(context->impl->common);
   common_context->thread_is_running.store(true);
   common_context->listener_thread_gc = rmw_fastrtps_shared_cpp::__rmw_create_guard_condition(
diff --git a/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp b/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp
index 5a417bb12..947f1c55e 100644
--- a/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp
+++ b/rmw_fastrtps_shared_cpp/src/rmw_publish.cpp
@@ -33,6 +33,10 @@ __rmw_publish(
   const void * ros_message,
   rmw_publisher_allocation_t * allocation)
 {
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR);
+
   (void) allocation;
   RMW_CHECK_FOR_NULL_WITH_MSG(
     publisher, "publisher handle is null",
@@ -66,6 +70,10 @@ __rmw_publish_serialized_message(
   const rmw_serialized_message_t * serialized_message,
   rmw_publisher_allocation_t * allocation)
 {
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INVALID_ARGUMENT);
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
+  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RMW_RET_ERROR);
+
   (void) allocation;
   RMW_CHECK_FOR_NULL_WITH_MSG(
     publisher, "publisher handle is null",