Report the first failure, not the last one

If test_fail is called multiple times in the same test case, report
the location of the first failure, not the last one.

With this change, you no longer need to take care in tests that use
auxiliary functions not to fail in the main function if the auxiliary
function has failed.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2020-08-29 15:18:23 +02:00
parent de4bcf22c1
commit dfb5cff2f5

View file

@ -336,6 +336,12 @@ jmp_buf jmp_tmp;
void test_fail( const char *test, int line_no, const char* filename )
{
if( test_info.result == TEST_RESULT_FAILED )
{
/* We've already recorded the test as having failed. Don't
* overwrite any previous information about the failure. */
return;
}
test_info.result = TEST_RESULT_FAILED;
test_info.test = test;
test_info.line_no = line_no;