1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* Copyright © 2015 Samsung Electronics Co., Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
@page zunitc zunitc
- @ref zunitc_overview
- @ref zunitc_execution
- @ref zunitc_execution_commandline
- @ref zunitc_execution_matching
- @ref zunitc_execution_wildcards
- @ref zunitc_execution_repeat
- @ref zunitc_execution_randomize
- @ref zunitc_fixtures
- @ref zunitc_functions
@section zunitc_overview Overview
A simple test framework in plain C suitable for basic unit and integration testing.
The main rationale for creating this framework was to have a simple to use testing
framework with tests implemented in C using common patterns and under a
compatible license. The structure of the test code and macro use is intended to
follow common patterns established by frameworks such as Boost Test and Google Test.
To get started, one or more tests should be defined via ZUC_TEST() and/or
ZUC_TEST_F(), which set up automatic test registration via gcc extensions.
To actually execute tests, ZUC_RUN_TESTS() should be called.
Tests can use several ZUC_ASSERT_* or ZUC_ASSERTG_* checks to validate
conditions. The ZUC_ASSERT_* ones upon failure will mark the current test
as failing and immediatly execute a return. On the other hand, the
ZUC_ASSERTG_* tests will mark the current test as failed and then execute a
'goto' targeting the specified label.
The set of fatal test checks are
- ZUC_ASSERT_TRUE()
- ZUC_ASSERT_FALSE()
- ZUC_ASSERT_NULL()
- ZUC_ASSERT_NOT_NULL()
- ZUC_ASSERT_EQ()
- ZUC_ASSERT_NE()
- ZUC_ASSERT_LT()
- ZUC_ASSERT_LE()
- ZUC_ASSERT_GT()
- ZUC_ASSERT_GE()
- ZUC_ASSERT_STREQ()
- ZUC_ASSERT_STRNE()
and
- ZUC_ASSERTG_TRUE()
- ZUC_ASSERTG_FALSE()
- ZUC_ASSERTG_NULL()
- ZUC_ASSERTG_NOT_NULL()
- ZUC_ASSERTG_EQ()
- ZUC_ASSERTG_NE()
- ZUC_ASSERTG_LT()
- ZUC_ASSERTG_LE()
- ZUC_ASSERTG_GT()
- ZUC_ASSERTG_GE()
- ZUC_ASSERTG_STREQ()
- ZUC_ASSERTG_STRNE()
Unconditional test values for logging and termination are
- ZUC_SKIP()
- ZUC_FATAL()
Unconditional message logging for failure cases only is
- ZUC_TRACEPOINT()
@section zunitc_execution Controlling Execution
To control execution, the various zuc_set_* functions can be called
before invoking ZUC_RUN_TESTS().
@subsection zunitc_execution_commandline Commandline Parameters
The current implementation defers processing of command-line parameters
to the main application hosting the testing. It is possible that a
helper to process certain parameters may be added.
@subsection zunitc_execution_matching Matching Patterns for Tests
The function zuc_set_filter() can be used to specify a pattern for
matching or excluding tests from a run. The general form is
match1[:match2[:match3..n]][:-exclude1[:exclude2[:exclude3..n]]]
@subsection zunitc_execution_wildcards Matching Wildcards
Wildcards can be used in the match/exclude patterns and recognize the
following two special characters:
- '*' matches any number of characters including zero.
- '?' matches any single character.
Calling zuc_list_tests() after zuc_set_filter() can be done to show the
effects of the matching without needing to actually run tests.
@subsection zunitc_execution_repeat Repeating Tests
Setting the repeat count higher than 1 ( via zuc_set_repeat() ) will
cause the tests to be executed several times in a row. This can be
useful for stress testing, checking for leaks, etc.
@subsection zunitc_execution_randomize Randomizing Tests
Test ordering can be randomized by setting a non-zero positive value to
zuc_set_random(). Setting it to 1 will cause the framework to pick a
random seed based on the time. A value greater than 1 will be taken as a
random seed itself. And setting it to 0 will disable randomization and
allow the test to be executed in their natural ordering.
@section zunitc_fixtures Fixtures
Per-suite and per-test setup and teardown fixtures can be implemented by
defining an instance of struct zuc_fixture and using it as the first
parameter to ZUC_TEST_F().
@section zunitc_functions Functions
- ZUC_TEST()
- ZUC_TEST_F()
- ZUC_RUN_TESTS()
- zuc_cleanup()
- zuc_list_tests()
- zuc_set_filter()
- zuc_set_random()
- zuc_set_spawn()
- zuc_set_output_tap()
- zuc_set_output_junit()
- zuc_has_skip()
- zuc_has_failure()
*/
|