iPXE
test.h
Go to the documentation of this file.
00001 #ifndef _IPXE_TEST_H
00002 #define _IPXE_TEST_H
00003 
00004 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00005 
00006 /** @file
00007  *
00008  * Self-test infrastructure
00009  *
00010  */
00011 
00012 #include <ipxe/tables.h>
00013 
00014 /** A self-test set */
00015 struct self_test {
00016         /** Test set name */
00017         const char *name;
00018         /** Run self-tests */
00019         void ( * exec ) ( void );
00020         /** Number of tests run */
00021         unsigned int total;
00022         /** Number of test failures */
00023         unsigned int failures;
00024         /** Number of assertion failures */
00025         unsigned int assertion_failures;
00026 };
00027 
00028 /** Self-test table */
00029 #define SELF_TESTS __table ( struct self_test, "self_tests" )
00030 
00031 /** Declare a self-test */
00032 #define __self_test __table_entry ( SELF_TESTS, 01 )
00033 
00034 extern void test_ok ( int success, const char *file, unsigned int line,
00035                       const char *test );
00036 
00037 /**
00038  * Report test result
00039  *
00040  * @v success           Test succeeded
00041  * @v file              File name
00042  * @v line              Line number
00043  */
00044 #define okx( success, file, line ) \
00045         test_ok ( success, file, line, #success )
00046 #define ok( success ) \
00047         okx ( success, __FILE__, __LINE__ )
00048 
00049 #endif /* _IPXE_TEST_H */