3 .\" Manual for the test vector framework
5 .\" (c) 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH tvec 3mLib "11 March 2024" "Straylight/Edgeware" "mLib utilities library"
33 .\"--------------------------------------------------------------------------
35 tvec \- test vector framework
43 .\"--------------------------------------------------------------------------
46 .B "#include <mLib/tvec.h>"
49 .B "union tvec_misc {"
52 .B " unsigned long u;"
65 .B "union tvec_regval {"
67 .B " unsigned long u;"
70 .B " struct { char *p; size_t sz; } text;"
71 .B " struct { unsigned char *p; size_t sz; } bytes;"
73 .B " unsigned char *p; size_t sz;"
79 .B "struct tvec_reg {"
81 .B " union tvec_regval v;"
83 .B "#define TVRF_LIVE ..."
86 .B "struct tvec_regdef {"
87 .B " const char *name;"
88 .B " const struct tvec_regty *ty;"
91 .B " union tvec_misc arg;"
93 .B "#define TVRF_UNSET ..."
94 .B "#define TVRF_OPT ..."
95 .B "#define TVRF_ID ..."
96 .B "#define TVEC_ENDREGS ..."
98 .B "struct tvec_state;"
100 .B "struct tvec_env;"
101 .ta \w'\fBtypedef void tvec_testfn('u
102 .BI "typedef void tvec_testfn(const struct tvec_reg *" in ,
103 .BI " struct tvec_reg *" out ,
106 .B "struct tvec_test {"
107 .B " const char *name;"
108 .B " const struct tvec_regdef *regs;"
109 .B " const struct tvec_env *env;"
110 .B " tvec_testfn *fn;"
112 .B "#define TVEC_ENDTESTS ..."
115 .B "struct tvec_config {"
116 .B " const struct tvec_test *tests;"
117 .B " unsigned nrout, nreg;"
120 .B "struct tvec_output;"
122 .ta \w'\fBvoid tvec_begin('u
123 .BI "void tvec_begin(struct tvec_state *" tv_out ,
124 .BI " const struct tvec_config *" config ,
125 .BI " struct tvec_output *" o );
126 .BI "int tvec_end(struct tvec_state *" tv );
127 .BI "int tvec_read(struct tvec_state *" tv ", const char *" infile ", FILE *" fp );
129 .BI "extern struct tvec_output *tvec_humanoutput(FILE *" fp );
130 .BI "extern struct tvec_output *tvec_machineoutput(FILE *" fp );
131 .BI "extern struct tvec_output *tvec_tapoutput(FILE *" fp );
132 .BI "extern struct tvec_output *tvec_dfltoutput(FILE *" fp );
135 .\"--------------------------------------------------------------------------
140 header file provides definitions and declarations
141 for the core of mLib's
142 .IR "test vector framework" .
144 The test vector framework is rather large and complicated,
145 so the documentation for it is split into multiple manual pages.
146 This one provides a conceptual overview
147 and describes the essentials for using it to build simple tests.
149 .SS Conceptual overview
152 runs a collection of tests
153 and reports on the outcome.
157 involves exercising some functionality
158 and checking that it behaves properly.
163 the functionality behaved properly.
166 the functionality did not behave properly.
168 .IR "expected failure" :
169 the functionality behaved as expected,
170 but the expected behaviour is known to be incorrect.
173 for some reason, the test couldn't be performed.
175 Tests are gathered together into
177 Each test group has a name.
178 Like a individual tests, test groups also have outcomes:
179 they can pass, fail, or be skipped.
180 A test group cannot experience expected failure.
182 A session may also encounter
184 e.g., as a result of malformed input
185 or failures reported by system facilities.
187 A test session can either
188 be driven from data provided by an input file,
189 or it can be driven by the program alone.
190 The latter case is called
194 This manual page describes file-driven testing.
196 When it begins a session for file-directed testing,
197 the program provides a table of
198 .IR "test definitions" .
199 A test definition has a
202 .IR "test function" ,
204 .IR "test environment" ,
206 .IR "register definitions" .
207 Test environments are explained further below.
211 is a place which can store a single item of test data;
212 registers are the means
213 by which input test data is provided to a test function,
214 and by which a test function returns its results.
215 A test definition's register definitions
216 establish a collection of
219 Each active register has a
225 which are established by its register definition.
226 The register's name is used to refer to the register in the test data file,
227 and its index is used to refer to it
228 in the test function and test environments.
229 The register's type describes the acceptable values for the register,
230 and how they are to be compared,
231 read from the input file,
232 and dumped in diagnostic output.
233 New register types can be defined fairly easily: see
236 A register definition may describe an
241 input registers provide input data to the test function, while
242 output registers collect output data from the test function.
243 The data file provides values for both input and output registers:
244 the values for the input registers are passed to the test function;
245 the values for the output registers are
246 .I "reference outputs"
247 against which the test function's outputs are to be checked.
249 The test function is called with two vectors of registers,
250 one containing input values for the test function to read,
251 and another for output values that the test function should write;
254 provided by the test environment.
255 The test function's task is to exercise the functionality to be tested,
256 providing it the input data from its input registers,
257 and collecting the output in its output registers.
258 It is the responsibility of the test environment or the framework
259 to compare the output register values against reference values
260 provided in the input data.
262 The input file syntax is described in full below.
266 Comments begin with a semicolon character
268 and extend to the end of the line.
271 by headings in square brackets:
275 Each section contains a number of
277 separated by blank lines.
278 Each paragraph consists of one or more
288 When the framework encounters a section heading,
289 it finishes any test group currently in progress,
290 and searches for a test definition whose name matches the
292 name in the section heading.
294 it begins a new test group with the same name.
295 Each paragraph of assignments is used to provide
296 input and reference output values
300 name in an assignment must match the name of an active register;
303 is stored in the named register.
305 A test environment fits in between
306 the framework and the test function.
307 It can establish hook functions which are called
308 at various stages during the test group.
312 hook is called once at the start of the test group.
316 hook is called once at the end of the test group.