Skip to content

Commit

Permalink
Updating comments
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <brawner@gmail.com>
  • Loading branch information
brawner committed Aug 17, 2020
1 parent b03d89e commit b823bc1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions include/rcutils/testing/fault_injection.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ bool
rcutils_fault_injection_is_test_complete(void);

/**
* \def RCUTILS_FAULT_INJECTION_SET_COUNT
* \brief Atomically set the fault injection counter.
*
* There will be at most one fault injected failure per call to RCUTILS_FAULT_INJECTION_SET_COUNT.
* There will be at most one fault injected failure per call to `rcutils_fault_injection_set_count`.
* To test all reachable fault injection locations, call this macro inside a loop and set the count
* to an incrementing count variable.
*
* for (int i = 0; i < SUFFICIENTLY_LARGE_ITERATION_COUNT; ++i) {
* RCUTILS_FAULT_INJECTION_SET_COUNT(i);
* rcutils_fault_injection_set_count(i);
* ... // Call function under test
* }
* ASSERT_LT(RCUTILS_FAULT_INJECTION_NEVER_FAIL, RCUTILS_FAULT_INJECTION_GET_COUNT());
Expand All @@ -69,20 +68,25 @@ void
rcutils_fault_injection_set_count(int count);

/**
* \def RCUTILS_FAULT_INJECTION_GET_COUNT
* \brief Atomically get the fault injection counter value
*
* Use this macro after running the code under test to check whether the counter reached a negative
* value. This is helpful so you can verify that you ran the fault injection test in a loop a
* sufficient number of times. Likewise, if the code under test returned with an error, but the
* count value was greater or equal to 0, then the failure was not caused by the fault injection
* counter.
* Use this function after running the code under test to check whether the counter reached a
* negative value. This is helpful so you can verify that you ran the fault injection test in a
* loop a sufficient number of times. Likewise, if the code under test returned with an error, but
* the count value was greater or equal to 0, then the failure was not caused by the fault
* injection counter.
*/
RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
int_least64_t
rcutils_fault_injection_get_count(void);

/**
* \brief Implementation of fault injection decrementer
*
* This is included inside of macros, so it needs to be exported as a public function, but it
* should not be used directly.
*/
RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
int_least64_t
Expand Down

0 comments on commit b823bc1

Please sign in to comment.