| 1 |
/** |
| 2 |
* Helper for test components supporting fault injection. |
| 3 |
*/ |
| 4 |
|
| 5 |
#ifndef TEST_FAULT_H |
| 6 |
#define TEST_FAULT_H |
| 7 |
|
| 8 |
#include <stdbool.h> |
| 9 |
|
| 10 |
/** |
| 11 |
* Information about a fault that should occurr in a component. |
| 12 |
*/ |
| 13 |
struct test_fault |
| 14 |
{ |
| 15 |
int countdown; /* Trigger the fault when this counter gets to zero. */ |
| 16 |
int n; /* Repeat the fault this many times. Default is -1. */ |
| 17 |
bool enabled; /* Enable fault triggering. */ |
| 18 |
}; |
| 19 |
|
| 20 |
/** |
| 21 |
* Initialize a fault. |
| 22 |
*/ |
| 23 |
void test_fault_init(struct test_fault *f); |
| 24 |
|
| 25 |
/** |
| 26 |
* Advance the counters of the fault. Return true if the fault should be |
| 27 |
* triggered, false otherwise. |
| 28 |
*/ |
| 29 |
bool test_fault_tick(struct test_fault *f); |
| 30 |
|
| 31 |
/** |
| 32 |
* Configure the fault with the given values. |
| 33 |
*/ |
| 34 |
void test_fault_config(struct test_fault *f, int delay, int repeat); |
| 35 |
|
| 36 |
/** |
| 37 |
* Enable fault triggering. |
| 38 |
*/ |
| 39 |
void test_fault_enable(struct test_fault *f); |
| 40 |
|
| 41 |
#endif /* TEST_FAULT_H */ |