QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Typedefs | Functions
mock.h File Reference

Allows for mocking any function call (typically used for syscalls) to see how they operate in failure conditions. More...

#include "qev.h"

Go to the source code of this file.

Macros

#define QEV_MOCK(fn_ret, fn,...)   fn(__VA_ARGS__)
 If you don't enable testing, the mocks are ignored.
 

Typedefs

typedef guint64(* qev_mock_cb )(va_list args)
 Function type for callbacks from mocks. More...
 

Functions

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. More...
 
void qev_mock_done ()
 Clears all the mocks. More...
 

Detailed Description

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

Typedef Documentation

typedef guint64(* qev_mock_cb)(va_list args)

Function type for callbacks from mocks.

Parameters
argsThe arguments passed to the function

Function Documentation

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
parentThe name of the parent function that contains the mocked function
fnThe name of the function that is being mocked
retThe value that the function should return
cbA callback to use instead of ret
errAn optional errno you may set (0 to leave alone)
void qev_mock_done ( )

Clears all the mocks.

Attention
This is not thread-safe. It should be run after all tests to clean out any and all mocks.