tst-backtrace4: expand output even on failures

When debugging failures in this test, it's helpful to see as much output
as possible.  So rather than returning immediately, let the code run as
far as it can.  We still mark failures as soon as they happen.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2013-12-30 10:31:19 +00:00
parent ac8cc9e300
commit 0b7c7473b9
2 changed files with 13 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2014-02-08 Mike Frysinger <vapier@gentoo.org>
* debug/tst-backtrace4.c (handle_signal): Add NUM_FUNCTIONS to output.
Only return early when n is <= 0. Delete unused return statement.
2014-02-08 Mike Frysinger <vapier@gentoo.org> 2014-02-08 Mike Frysinger <vapier@gentoo.org>
* debug/Makefile (CFLAGS-tst-longjmp_chk3.c): Define. * debug/Makefile (CFLAGS-tst-longjmp_chk3.c): Define.

View File

@ -49,12 +49,16 @@ handle_signal (int signum)
/* Get the backtrace addresses. */ /* Get the backtrace addresses. */
n = backtrace (addresses, sizeof (addresses) / sizeof (addresses[0])); n = backtrace (addresses, sizeof (addresses) / sizeof (addresses[0]));
printf ("Obtained backtrace with %d functions\n", n); printf ("Obtained backtrace with %d functions (but wanted at least %d)\n",
/* Check that there are at least six functions. */ n, NUM_FUNCTIONS);
/* Check that there are at least six functions. */
if (n < NUM_FUNCTIONS) if (n < NUM_FUNCTIONS)
{ {
FAIL (); FAIL ();
return; /* Only return if we got no symbols at all. The partial output is
still useful for debugging failures. */
if (n <= 0)
return;
} }
/* Convert them to symbols. */ /* Convert them to symbols. */
symbols = backtrace_symbols (addresses, n); symbols = backtrace_symbols (addresses, n);
@ -68,10 +72,7 @@ handle_signal (int signum)
printf ("Function %d: %s\n", i, symbols[i]); printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */ /* Check that the function names obtained are accurate. */
if (!match (symbols[0], "handle_signal")) if (!match (symbols[0], "handle_signal"))
{ FAIL ();
FAIL ();
return;
}
/* Do not check name for signal trampoline. */ /* Do not check name for signal trampoline. */
for (i = 2; i < n - 1; i++) for (i = 2; i < n - 1; i++)
if (!match (symbols[i], "fn")) if (!match (symbols[i], "fn"))