Scrutiny  1.1.0
C testing framework for POSIX environments
run.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <stdbool.h>
9 #include <sys/types.h>
10 
11 #include "definitions.h"
12 
16 typedef size_t scrGroup;
17 
21 typedef void
22 scrTestFn(void);
23 
27 typedef struct scrTestOptions {
28  unsigned int timeout;
29  unsigned int flags;
31 
35 typedef void *
37 
41 typedef void
43 
47 typedef struct scrGroupOptions {
48  scrCtxCreateFn *create_fn;
49  scrCtxCleanupFn *cleanup_fn;
51 
55 typedef struct scrOptions {
56  void *global_ctx;
57  unsigned int flags;
58 } scrOptions;
59 
63 typedef struct scrStats {
64  unsigned int num_passed;
65  unsigned int num_skipped;
66  unsigned int num_failed;
67  unsigned int
69 } scrStats;
70 
74 #define SCR_TF_XFAIL 0x00000001
75 
79 #define SCR_RF_FAIL_FAST 0x00000001
80 
83 #define SCR_RF_VERBOSE 0x00000002
84 
93 scrGroupCreate(const scrGroupOptions *options) SCR_EXPORT;
94 
103 void
104 scrAddTest(scrGroup group, const char *name, scrTestFn test_fn, const scrTestOptions *options) SCR_EXPORT
105  SCR_NONNULL(2, 3);
106 
107 void
108 scrGroupAddTest(scrGroup group, const char *name, scrTestFn test_fn, const scrTestOptions *options) SCR_EXPORT
109  SCR_NONNULL(2, 3) __attribute__((deprecated("scrGroupAddTest is deprecated. Use scrAddTest.")));
110 
124 bool
125 scrPatchFunction(scrGroup group, const char *func_name, const char *file_substring, void *new_func) SCR_EXPORT
126  SCR_NONNULL(2, 4);
127 
128 bool
129 scrGroupPatchFunction(scrGroup group, const char *func_name, const char *file_substring,
130  void *new_func) SCR_EXPORT SCR_NONNULL(2, 4)
131  __attribute__((deprecated("scrGroupPatchFunction is deprecated. Use scrPatchFunction.")));
132 
141 int
142 scrRun(const scrOptions *options, scrStats *stats) SCR_EXPORT;
int scrRun(const scrOptions *options, scrStats *stats) SCR_EXPORT
Runs all of the tests.
unsigned int num_passed
Definition: run.h:64
void scrTestFn(void)
The signature for a test function.
Definition: run.h:22
unsigned int num_failed
Definition: run.h:66
unsigned int num_errored
Definition: run.h:68
struct scrGroupOptions scrGroupOptions
Options to pass to scrGroupCreate.
unsigned int timeout
Definition: run.h:28
scrGroup scrGroupCreate(const scrGroupOptions *options) SCR_EXPORT
Creates a new test group.
Holds the test results.
Definition: run.h:63
unsigned int num_skipped
Definition: run.h:65
void * global_ctx
Definition: run.h:56
unsigned int flags
Definition: run.h:57
struct scrTestOptions scrTestOptions
Options to pass to scrAddTest.
void scrCtxCleanupFn(void *)
The signature for a group context cleanup function.
Definition: run.h:42
size_t scrGroup
A representation of a testing group.
Definition: run.h:16
void * scrCtxCreateFn(void *)
The signature for a group context creation function.
Definition: run.h:36
unsigned int flags
Definition: run.h:29
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&#39;s tests.
Options to pass to scrAddTest.
Definition: run.h:27
Options to pass to scrRun.
Definition: run.h:55
struct scrStats scrStats
Holds the test results.
void scrAddTest(scrGroup group, const char *name, scrTestFn test_fn, const scrTestOptions *options) SCR_EXPORT SCR_NONNULL(2
Adds a test to a group.
Options to pass to scrGroupCreate.
Definition: run.h:47
struct scrOptions scrOptions
Options to pass to scrRun.