3 * $Id: testrig.h,v 1.7 2004/04/08 01:36:13 mdw Exp $
7 * (c) 1998 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the mLib utilities library.
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with mLib; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
37 /*----- Header files ------------------------------------------------------*/
44 /*----- Magical numbers ---------------------------------------------------*/
46 #define TEST_FIELDMAX 16 /* Maximum fields in a line */
48 /*----- Data structures ---------------------------------------------------*/
50 typedef struct test_results
{
51 unsigned tests
, failed
;
54 /* --- Test field definition --- */
56 typedef struct test_type
{
57 void (*cvt
)(const char *buf
, dstr
*d
); /* Conversion function */
58 void (*dump
)(dstr
*d
, FILE *fp
); /* Dump function */
61 /* --- Test chunk definition --- */
63 typedef struct test_chunk
{
64 const char *name
; /* Name of this chunk */
65 int (*test
)(dstr
/*dv*/[]); /* Test verification function */
66 const test_type
*f
[TEST_FIELDMAX
]; /* Field definitions */
69 typedef struct test_suite
{
70 const char *name
; /* Name of this suite */
71 const test_chunk
*chunks
; /* Chunks contained in this suite */
74 /*----- Predefined data types ---------------------------------------------*/
76 extern const test_type type_hex
;
77 extern const test_type type_string
;
78 extern const test_type type_int
;
79 extern const test_type type_long
;
80 extern const test_type type_ulong
;
81 extern const test_type type_uint32
;
83 /*----- Functions provided ------------------------------------------------*/
85 /* --- @test_do@ --- *
87 * Arguments: @const test_suite suites[]@ = pointer to suite definitions
88 * @FILE *fp@ = test vector file, ready opened
89 * @test_results *results@ = where to put results
91 * Returns: Negative if something bad happened, or the number of
94 * Use: Runs a collection of tests against a file of test vectors and
95 * reports the results.
98 extern int test_do(const test_suite
/*suite*/[],
100 test_results */
*results*/
);
102 /* --- @test_run@ --- *
104 * Arguments: @int argc@ = number of command line arguments
105 * @char *argv[]@ = pointer to command line arguments
106 * @const test_chunk chunk[]@ = pointer to chunk definitions
107 * @const char *def@ = name of default test vector file
111 * Use: Runs a set of test vectors to ensure that a component is
115 extern void test_run(int /*argc*/, char */
*argv*/
[],
116 const test_chunk
/*chunk*/[],
117 const char */
*def*/
);
119 /*----- That's all, folks -------------------------------------------------*/