libfiu (internal) 0.90
Defines | Functions
fiu.h File Reference

This header contains the API that your project should use when defining points of failure in your real (non-testing) code. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define fiu_do_on(name, action)
 Performs the given action when the given point of failure fails.
#define fiu_exit_on(name)   fiu_do_on(name, exit(EXIT_FAILURE))
 Exits the program when the given point of failure fails.
#define fiu_return_on(name, retval)   fiu_do_on(name, return retval)
 Makes the function return the given retval when the given point of failure fails.

Functions

int fiu_init (unsigned int flags)
 Initializes the library.
int fiu_fail (const char *name)
 Returns the failure status of the given point of failure.
void * fiu_failinfo (void)
 Returns the information associated with the last failure.

Detailed Description

This header contains the API that your project should use when defining points of failure in your real (non-testing) code.

If you want to avoid having libfiu as a mandatory build-time dependency, you should add fiu-local.h to your project, and #include that instead.

Definition in file fiu.h.


Define Documentation

#define fiu_do_on (   name,
  action 
)
Value:
do { \
                if (fiu_fail(name)) { \
                        action; \
                } \
        } while (0)

Performs the given action when the given point of failure fails.

Mostly used in the following macros.

Definition at line 52 of file fiu.h.

#define fiu_exit_on (   name)    fiu_do_on(name, exit(EXIT_FAILURE))

Exits the program when the given point of failure fails.

Definition at line 60 of file fiu.h.

#define fiu_return_on (   name,
  retval 
)    fiu_do_on(name, return retval)

Makes the function return the given retval when the given point of failure fails.

Definition at line 64 of file fiu.h.


Function Documentation

int fiu_init ( unsigned int  flags)

Initializes the library.

Must be called before any other library function. It is safe to invoke it more than once.

Parameters:
flagsUnused.
Returns:
0 if success, < 0 if error.

Definition at line 259 of file fiu.c.

Here is the call graph for this function:

int fiu_fail ( const char *  name)

Returns the failure status of the given point of failure.

Parameters:
namePoint of failure name.
Returns:
The failure status (0 means it should not fail).

Definition at line 297 of file fiu.c.

Here is the call graph for this function:

void* fiu_failinfo ( void  )

Returns the information associated with the last failure.

Please note that this function is thread-safe and thread-local, so the information returned will be for the last failure in the same thread.

Returns:
The information associated with the last failure, or NULL if there isn't one.

Definition at line 368 of file fiu.c.