Define RCUTILS_FAULT_INJECTION_MAYBE_FAIL
Defined in File fault_injection.h
Define Documentation
-
RCUTILS_FAULT_INJECTION_MAYBE_FAIL(failure_code)
This macro checks and decrements a static global variable atomic counter and executes
failure_code
if the counter is 0 inside a scoped block (any variables declared in failure_code) will not be avaliable outside of this scoped block.This macro is not a function itself, so it will cause the calling function to execute the code from within an if loop.
Set the counter with
RCUTILS_FAULT_INJECTION_SET_COUNT
. If the count is less than 0, thenRCUTILS_FAULT_INJECTION_MAYBE_FAIL
will not execute the failure code.This macro is thread-safe, and ensures that at most one invocation results in a failure for each time the fault injection counter is set with
RCUTILS_FAULT_INJECTION_SET_COUNT
- Parameters:
failure_code – the code to execute in the case of fault injected failure.