iPXE
test.h
Go to the documentation of this file.
1 #ifndef _IPXE_TEST_H
2 #define _IPXE_TEST_H
3 
4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5 
6 /** @file
7  *
8  * Self-test infrastructure
9  *
10  */
11 
12 #include <ipxe/tables.h>
13 
14 /** A self-test set */
15 struct self_test {
16  /** Test set name */
17  const char *name;
18  /** Run self-tests */
19  void ( * exec ) ( void );
20  /** Number of tests run */
21  unsigned int total;
22  /** Number of test failures */
23  unsigned int failures;
24  /** Number of assertion failures */
25  unsigned int assertion_failures;
26 };
27 
28 /** Self-test table */
29 #define SELF_TESTS __table ( struct self_test, "self_tests" )
30 
31 /** Declare a self-test */
32 #define __self_test __table_entry ( SELF_TESTS, 01 )
33 
34 extern void test_ok ( int success, const char *file, unsigned int line,
35  const char *test );
36 
37 /**
38  * Report test result
39  *
40  * @v success Test succeeded
41  * @v file File name
42  * @v line Line number
43  */
44 #define okx( success, file, line ) \
45  test_ok ( success, file, line, #success )
46 #define ok( success ) \
47  okx ( success, __FILE__, __LINE__ )
48 
49 #endif /* _IPXE_TEST_H */
unsigned int failures
Number of test failures.
Definition: test.h:23
unsigned int total
Number of tests run.
Definition: test.h:21
void(* exec)(void)
Run self-tests.
Definition: test.h:19
const char * name
Test set name.
Definition: test.h:17
A self-test set.
Definition: test.h:15
unsigned int assertion_failures
Number of assertion failures.
Definition: test.h:25
Linker tables.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void test_ok(int success, const char *file, unsigned int line, const char *test)
Report test result.
Definition: test.c:55
static int test
Definition: epic100.c:73