Scrutiny  1.1.0
C testing framework for POSIX environments
Data Structures | Macros | Typedefs | Functions
run.h File Reference

Defines the runner functionality. More...

#include <stdbool.h>
#include <sys/types.h>
#include "definitions.h"
Include dependency graph for run.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  scrTestOptions
 Options to pass to scrAddTest. More...
 
struct  scrGroupOptions
 Options to pass to scrGroupCreate. More...
 
struct  scrOptions
 Options to pass to scrRun. More...
 
struct  scrStats
 Holds the test results. More...
 

Macros

#define SCR_TF_XFAIL
 Indicates that a test is expected to fail.
 
#define SCR_RF_FAIL_FAST
 Instructs the runner to stop as soon as a test fails.
 
#define SCR_RF_VERBOSE
 Displays output even when tests pass.
 

Typedefs

typedef size_t scrGroup
 A representation of a testing group.
 
typedef void scrTestFn(void)
 The signature for a test function.
 
typedef struct scrTestOptions scrTestOptions
 Options to pass to scrAddTest.
 
typedef void * scrCtxCreateFn(void *)
 The signature for a group context creation function.
 
typedef void scrCtxCleanupFn(void *)
 The signature for a group context cleanup function.
 
typedef struct scrGroupOptions scrGroupOptions
 Options to pass to scrGroupCreate.
 
typedef struct scrOptions scrOptions
 Options to pass to scrRun.
 
typedef struct scrStats scrStats
 Holds the test results.
 

Functions

scrGroup scrGroupCreate (const scrGroupOptions *options) SCR_EXPORT
 Creates a new test group. More...
 
void scrAddTest (scrGroup group, const char *name, scrTestFn test_fn, const scrTestOptions *options) SCR_EXPORT SCR_NONNULL(2
 Adds a test to a group. More...
 
bool scrPatchFunction (scrGroup group, const char *func_name, const char *file_substring, void *new_func) SCR_EXPORT SCR_NONNULL(2
 Enables monkeypatching of a function for all of a group's tests. More...
 
int scrRun (const scrOptions *options, scrStats *stats) SCR_EXPORT
 Runs all of the tests. More...
 

Detailed Description

Defines the runner functionality.

Function Documentation

◆ scrGroupCreate()

scrGroup scrGroupCreate ( const scrGroupOptions options)

Creates a new test group.

Parameters
optionsA pointer to the options to use. If NULL, then default options will be used.
Returns
A group handle.

◆ scrAddTest()

void scrAddTest ( scrGroup  group,
const char *  name,
scrTestFn  test_fn,
const scrTestOptions options 
)

Adds a test to a group.

Parameters
groupThe group handle.
nameThe name of the test.
test_fnThe test function.
optionsA pointer to the options to use. If NULL, then default options will be used.

◆ scrPatchFunction()

bool scrPatchFunction ( scrGroup  group,
const char *  func_name,
const char *  file_substring,
void *  new_func 
)

Enables monkeypatching of a function for all of a group's tests.

Parameters
groupThe group handle.
func_nameThe name of the function to patch.
file_substringIf not NULL, then only files containing this value as a substring will be patched.
new_funcThe new function to use.
Returns
true if successful and false otherwise. If monkeypatching was not enabled at compile time, then this function will always return false.
Note
Functions within libscrutiny.so cannot be monkeypatched.

◆ scrRun()

int scrRun ( const scrOptions options,
scrStats stats 
)

Runs all of the tests.

Parameters
optionsA pointer to options to use. If NULL, then default options will be used.
[out]statsIf not NULL, then will be populated with the run's statistics.
Returns
0 if all of the tests either passed or were skipped and 1 otherwise.