From d4c9fd1e0a5f2a09d14c06d516716cd2199e90b5 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 31 Aug 2020 10:21:58 +0200 Subject: [PATCH] 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 --- tests/suites/helpers.function | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function index d2057861f..8f5cef5e0 100644 --- a/tests/suites/helpers.function +++ b/tests/suites/helpers.function @@ -165,6 +165,12 @@ test_info; void test_fail( const char *test, int line_no, const char* filename ) { + if( test_info.failed ) + { + /* We've already recorded the test as having failed. Don't + * overwrite any previous information about the failure. */ + return; + } test_info.failed = 1; test_info.test = test; test_info.line_no = line_no;