mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 01:52:08 +03:00
[test] Include failing code within failed test result output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -31,7 +31,8 @@ struct self_test {
|
|||||||
/** Declare a self-test */
|
/** Declare a self-test */
|
||||||
#define __self_test __table_entry ( SELF_TESTS, 01 )
|
#define __self_test __table_entry ( SELF_TESTS, 01 )
|
||||||
|
|
||||||
extern void test_ok ( int success, const char *file, unsigned int line );
|
extern void test_ok ( int success, const char *file, unsigned int line,
|
||||||
|
const char *test );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report test result
|
* Report test result
|
||||||
@@ -39,7 +40,7 @@ extern void test_ok ( int success, const char *file, unsigned int line );
|
|||||||
* @v success Test succeeded
|
* @v success Test succeeded
|
||||||
*/
|
*/
|
||||||
#define ok( success ) do { \
|
#define ok( success ) do { \
|
||||||
test_ok ( (success), __FILE__, __LINE__ ); \
|
test_ok ( (success), __FILE__, __LINE__, #success ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#endif /* _IPXE_TEST_H */
|
#endif /* _IPXE_TEST_H */
|
||||||
|
|||||||
@@ -45,8 +45,10 @@ static struct self_test *current_tests;
|
|||||||
* @v success Test succeeded
|
* @v success Test succeeded
|
||||||
* @v file Test code file
|
* @v file Test code file
|
||||||
* @v line Test code line
|
* @v line Test code line
|
||||||
|
* @v test Test code
|
||||||
*/
|
*/
|
||||||
void test_ok ( int success, const char *file, unsigned int line ) {
|
void test_ok ( int success, const char *file, unsigned int line,
|
||||||
|
const char *test ) {
|
||||||
|
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
assert ( current_tests != NULL );
|
assert ( current_tests != NULL );
|
||||||
@@ -57,8 +59,8 @@ void test_ok ( int success, const char *file, unsigned int line ) {
|
|||||||
/* Report failure if applicable */
|
/* Report failure if applicable */
|
||||||
if ( ! success ) {
|
if ( ! success ) {
|
||||||
current_tests->failures++;
|
current_tests->failures++;
|
||||||
printf ( "FAILURE: \"%s\" test failed at %s line %d\n",
|
printf ( "FAILURE: \"%s\" test failed at %s line %d: ( %s )\n",
|
||||||
current_tests->name, file, line );
|
current_tests->name, file, line, test );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user