bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tests: Support showing all assertion failures, not just the first one


From: Bruno Haible
Subject: tests: Support showing all assertion failures, not just the first one
Date: Sat, 18 May 2024 23:46:22 +0200

Sometimes a test has several failures on a certain platform (e.g. the
test-c32is* tests). In order to display all failed ASSERTs, not just the
first one, so far I hand-edited tests/macros.h.

But this approach does not work with CI builds, because
  - it's not easy to hand-edit a file,
  - it's also not possible to use gdb.

As a mitigation, I'm introducing a CONTINUE_AFTER_ASSERT macro that, when
defined, will let the test progress after an ASSERT failure. Of course the
test should still be failing, then, even though abort() may not be called.

The following two patches achieve this.

It's a small complication for writing new unit tests, but not a heavy one,
because it's trivial to change
   return 0;
to
   return test_exit_status;
(It's not a requirement that the test continues properly after an ASSERT
failure. It's OK if the test crashes through undefined behaviour, such as a
NULL pointer access.)


2024-05-18  Bruno Haible  <bruno@clisp.org>

        abort-debug: Integrate with CONTINUE_AFTER_ASSERT.
        * lib/stdlib.in.h (_gl_pre_abort): New declaration.
        * lib/abort-debug.c (_gl_pre_abort): New function.
        * tests/macros.h (ASSERT, ASSERT_NO_STDIO): If CONTINUE_AFTER_ASSERT
        is 1 and the assertion fails, invoke _gl_pre_abort.

2024-05-18  Bruno Haible  <bruno@clisp.org>

        tests: Support showing all assertion failures, not just the first one.
        * tests/macros.h (CONTINUE_AFTER_ASSERT): New macro.
        (test_exit_status): New variable.
        (ASSERT, ASSERT_NO_STDIO): If CONTINUE_AFTER_ASSERT is 1, set
        test_exit_status instead of aborting.
        * tests/**/test-*.{c,h,cc} (main): Instead of exiting with exit code 0,
        exit with exit code test_exit_status.
        * tests/test-spawn-pipe-child.c: Undefine CONTINUE_AFTER_ASSERT.
        * tests/uninorm/test-nf*.c: Include macros.h.
        * tests/uninorm/test-u32-nf*-big.c: Likewise.
        * tests/random*.c: Define NO_MAIN_HERE.

Attachment: 0001-tests-Support-showing-all-assertion-failures-not-jus.patch.gz
Description: application/gzip

Attachment: 0002-abort-debug-Integrate-with-CONTINUE_AFTER_ASSERT.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]