diff options
author | Michael Brown <mcb30@ipxe.org> | 2013-11-27 03:03:16 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2013-11-27 11:27:45 +0000 |
commit | 1312c467ee6b3e158b1babb13735114dce8c3690 (patch) | |
tree | 8b90d8228adcc0c4150be02c9b309d8de9812337 /src | |
parent | 017e6c56af0a77354662f9a1a8faaf65a7376580 (diff) | |
download | ipxe-1312c467ee6b3e158b1babb13735114dce8c3690.tar.gz |
[test] Include failing code within failed test result output
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ipxe/test.h | 7 | ||||
-rw-r--r-- | src/tests/test.c | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/include/ipxe/test.h b/src/include/ipxe/test.h index 8c361d284..6b74ff007 100644 --- a/src/include/ipxe/test.h +++ b/src/include/ipxe/test.h @@ -31,15 +31,16 @@ struct self_test { /** Declare a self-test */ #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 * * @v success Test succeeded */ -#define ok( success ) do { \ - test_ok ( (success), __FILE__, __LINE__ ); \ +#define ok( success ) do { \ + test_ok ( (success), __FILE__, __LINE__, #success ); \ } while ( 0 ) #endif /* _IPXE_TEST_H */ diff --git a/src/tests/test.c b/src/tests/test.c index 62f7c97d9..9b65e3514 100644 --- a/src/tests/test.c +++ b/src/tests/test.c @@ -45,8 +45,10 @@ static struct self_test *current_tests; * @v success Test succeeded * @v file Test code file * @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 */ assert ( current_tests != NULL ); @@ -57,8 +59,8 @@ void test_ok ( int success, const char *file, unsigned int line ) { /* Report failure if applicable */ if ( ! success ) { current_tests->failures++; - printf ( "FAILURE: \"%s\" test failed at %s line %d\n", - current_tests->name, file, line ); + printf ( "FAILURE: \"%s\" test failed at %s line %d: ( %s )\n", + current_tests->name, file, line, test ); } } |