| 1 |
#ifndef COWSQL_TEST_HEAP_H |
| 2 |
#define COWSQL_TEST_HEAP_H |
| 3 |
|
| 4 |
#include "munit.h" |
| 5 |
|
| 6 |
/* Munit parameter defining the delay of the faulty memory implementation. */ |
| 7 |
#define TEST_HEAP_FAULT_DELAY "mem-fault-delay" |
| 8 |
|
| 9 |
/* Munit parameter defining the repeat of the faulty memory implementation. */ |
| 10 |
#define TEST_HEAP_FAULT_REPEAT "mem-fault-repeat" |
| 11 |
|
| 12 |
void test_heap_setup(const MunitParameter params[], void *user_data); |
| 13 |
void test_heap_tear_down(void *data); |
| 14 |
|
| 15 |
/* Configure the faulty memory management implementation so malloc()-related |
| 16 |
* functions start returning NULL pointers after 'delay' calls, and keep failing |
| 17 |
* for 'repeat' consecutive times. |
| 18 |
* |
| 19 |
* Note that the faults won't automatically take place, an explicit call to |
| 20 |
* test_mem_fault_enable() is needed. This allows configuration and actual |
| 21 |
* behavior to happen at different times (e.g. configure at test setup time and |
| 22 |
* enable at test case time). */ |
| 23 |
void test_heap_fault_config(int delay, int repeat); |
| 24 |
|
| 25 |
/* Enable the faulty behavior, which from this point on will honor the |
| 26 |
* parameters passed to test_mem_fault_config(). */ |
| 27 |
void test_heap_fault_enable(void); |
| 28 |
|
| 29 |
#define SETUP_HEAP test_heap_setup(params, user_data); |
| 30 |
#define TEAR_DOWN_HEAP test_heap_tear_down(data); |
| 31 |
|
| 32 |
#endif /* COWSQL_TEST_HEAP_H */ |