File: fault.h

package info (click to toggle)
dqlite 1.18.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,372 kB
  • sloc: ansic: 57,583; makefile: 336; sh: 243
file content (41 lines) | stat: -rw-r--r-- 884 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * Helper for test components supporting fault injection.
 */

#ifndef TEST_FAULT_H
#define TEST_FAULT_H

#include <stdbool.h>

/**
 * Information about a fault that should occurr in a component.
 */
struct test_fault
{
	int countdown; /* Trigger the fault when this counter gets to zero. */
	int n;         /* Repeat the fault this many times. Default is -1. */
	bool enabled;  /* Enable fault triggering. */
};

/**
 * Initialize a fault.
 */
void test_fault_init(struct test_fault *f);

/**
 * Advance the counters of the fault. Return true if the fault should be
 * triggered, false otherwise.
 */
bool test_fault_tick(struct test_fault *f);

/**
 * Configure the fault with the given values.
 */
void test_fault_config(struct test_fault *f, int delay, int repeat);

/**
 * Enable fault triggering.
 */
void test_fault_enable(struct test_fault *f);

#endif /* TEST_FAULT_H */