Function rcutils_fault_injection_set_count

Function Documentation

void rcutils_fault_injection_set_count(int_least64_t count)

Atomically set the fault injection counter.

This is typically not the preferred method of interacting directly with the fault injection logic, instead use RCUTILS_FAULT_INJECTION_TEST instead.

This function may also be used for pausing code inside of a RCUTILS_FAULT_INJECTION_TEST with something like the following:

RCUTILS_FAULT_INJECTION_TEST({ … // code to run with fault injection int64_t count = rcutils_fault_injection_get_count(); rcutils_fault_injection_set_count(RCUTILS_FAULT_INJECTION_NEVER_FAIL); … // code to run without fault injection rcutils_fault_injection_set_count(count); … // code to run with fault injection });

Parameters:

count – The count to set the fault injection counter to. If count is negative, then fault injection errors will be disabled. The counter is globally initialized to RCUTILS_FAULT_INJECTION_NEVER_FAIL.