Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libexecinfo Make the output of the test case bette...
details: https://anonhg.NetBSD.org/src/rev/6b1ff8a15c8b
branches: trunk
changeset: 325928:6b1ff8a15c8b
user: martin <martin%NetBSD.org@localhost>
date: Sat Jan 11 19:13:41 2014 +0000
description:
Make the output of the test case better suited for debugging (output full
backtrace before failing any unclear asserts)
diffstat:
tests/lib/libexecinfo/t_backtrace.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r e740b72d1c5f -r 6b1ff8a15c8b tests/lib/libexecinfo/t_backtrace.c
--- a/tests/lib/libexecinfo/t_backtrace.c Sat Jan 11 18:38:00 2014 +0000
+++ b/tests/lib/libexecinfo/t_backtrace.c Sat Jan 11 19:13:41 2014 +0000
@@ -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 @@
++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");
Home |
Main Index |
Thread Index |
Old Index