diff options
| author | martin <martin@NetBSD.org> | 2014-01-11 19:13:41 +0000 |
|---|---|---|
| committer | martin <martin@NetBSD.org> | 2014-01-11 19:13:41 +0000 |
| commit | 804dfcea552c359efc1a67268b5fd4c5d573b1bf (patch) | |
| tree | 20053ebc2cd015196fb47dd55d612c0ac266edf2 | |
| parent | d5fd0a9606fdcc8fce550afa155b9a35ba03f284 (diff) | |
Make the output of the test case better suited for debugging (output full
backtrace before failing any unclear asserts)
| -rw-r--r-- | tests/lib/libexecinfo/t_backtrace.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/lib/libexecinfo/t_backtrace.c b/tests/lib/libexecinfo/t_backtrace.c index 3710de3ea42..dd26780bdb8 100644 --- a/tests/lib/libexecinfo/t_backtrace.c +++ b/tests/lib/libexecinfo/t_backtrace.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,11 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $"); #include <atf-c.h> #include <atf-c/config.h> #include <string.h> +#include <stdio.h> #include <stdlib.h> #include <execinfo.h> #include <unistd.h> @@ -69,12 +70,19 @@ myfunc3(size_t ncalls) ++max_frames; } nptrs = backtrace(buffer, __arraycount(buffer)); - ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); - ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); - strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); ATF_CHECK(strings != NULL); + + printf("got nptrs=%zu ncalls=%zu (min_frames: %zu, max_frames: %zu)\n", + nptrs, ncalls, min_frames, max_frames); + printf("backtrace is:\n"); + for (j = 0; j < nptrs; j++) { + printf("#%zu: %s\n", j, strings[j]); + } + + ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); + ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); ATF_CHECK_STREQ(strings[0], "myfunc3"); ATF_CHECK_STREQ(strings[1], "myfunc2"); |
