Define RCUTILS_NO_FAULT_INJECTION

Define Documentation

RCUTILS_NO_FAULT_INJECTION(code)

A convenience macro built around rcutils_fault_injection_set_count() to pause fault injection during code execution. This macro is intended to be used within RCUTILS_FAULT_INJECTION_TEST() blocks.

code is executed within a do-while loop and therefore any variables declared within are in their own scope block.

Here’s a simple example: RCUTILS_FAULT_INJECTION_TEST({ rcl_ret_t ret = rcl_init(argc, argv, options, context); if (RCL_RET_OK == ret) { RCUTILS_NO_FAULT_INJECTION({ ret = rcl_shutdown(context); }); } });

In this example, on successful rcl_init(), rcl_shutdown() is called while ensuring that it will not fail due to fault injection.