Allows for mocking any function call (typically used for syscalls) to see how they operate in failure conditions.
More...
Go to the source code of this file.
|
|
#define | QEV_MOCK(fn_ret, fn,...) fn(__VA_ARGS__) |
| | If you don't enable testing, the mocks are ignored.
|
| |
|
| typedef guint64(* | qev_mock_cb )(va_list args) |
| | Function type for callbacks from mocks. More...
|
| |
Allows for mocking any function call (typically used for syscalls) to see how they operate in failure conditions.
Mocks just change return values and do not operate on the variables passed to the functions.
- Author
- Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com
- Copyright
- 2012-2014 Clear Channel Inc.
| typedef guint64(* qev_mock_cb)(va_list args) |
Function type for callbacks from mocks.
- Parameters
-
| args | The arguments passed to the function |
| void qev_mock_add |
( |
const gchar * |
parent, |
|
|
const gchar * |
fn, |
|
|
const guint64 |
ret, |
|
|
const qev_mock_cb |
cb, |
|
|
const gint |
err |
|
) |
| |
Adds a mock to the current run suite.
- Attention
- This is not thread-safe. It should be run from a single thread before test cases start running.
- Parameters
-
| parent | The name of the parent function that contains the mocked function |
| fn | The name of the function that is being mocked |
| ret | The value that the function should return |
| cb | A callback to use instead of ret |
| err | An optional errno you may set (0 to leave alone) |
Clears all the mocks.
- Attention
- This is not thread-safe. It should be run after all tests to clean out any and all mocks.