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 back trace more robust. At least ...
details: https://anonhg.NetBSD.org/src/rev/437587236e96
branches: trunk
changeset: 787222:437587236e96
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Jun 06 17:40:09 2013 +0000
description:
Make back trace more robust. At least on i386, one of the intermediate
functions in ATF is not replaced by tail recursion elimination, so
mark it as optional.
diffstat:
tests/lib/libexecinfo/t_backtrace.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diffs (60 lines):
diff -r ab9fc42fd7e0 -r 437587236e96 tests/lib/libexecinfo/t_backtrace.c
--- a/tests/lib/libexecinfo/t_backtrace.c Thu Jun 06 09:13:41 2013 +0000
+++ b/tests/lib/libexecinfo/t_backtrace.c Thu Jun 06 17:40:09 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $ */
+/* $NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $");
+__RCSID("$NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $");
#include <atf-c.h>
#include <atf-c/config.h>
@@ -45,13 +45,23 @@
myfunc3(size_t ncalls)
{
static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body",
- "atf_tc_run", "atf_tp_main", "main", "___start" };
- size_t j, nptrs;
+ "atf_tc_run", "atf_tp_run", "atf_tp_main", "main", "___start" };
+ static bool optional_frame[] = { false, false, false, true, false, false, false };
+ size_t j, nptrs, min_frames, max_frames;
void *buffer[ncalls + 10];
char **strings;
+ __CTASSERT(__arraycount(top) == __arraycount(optional_frame));
+ min_frames = 0;
+ max_frames = 0;
+ for (j = 0; j < __arraycount(optional_frame); ++j) {
+ if (!optional_frame[j])
+ ++min_frames;
+ ++max_frames;
+ }
nptrs = backtrace(buffer, __arraycount(buffer));
- ATF_REQUIRE_EQ(nptrs, ncalls + 8);
+ ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames);
+ ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames);
strings = backtrace_symbols_fmt(buffer, nptrs, "%n");
@@ -62,8 +72,13 @@
for (j = 2; j < ncalls + 2; j++)
ATF_CHECK_STREQ(strings[j], "myfunc1");
- for (size_t i = 0; j < nptrs; i++, j++)
+ for (size_t i = 0; j < nptrs; i++, j++) {
+ if (optional_frame[i] && strcmp(strings[j], top[i])) {
+ --i;
+ continue;
+ }
ATF_CHECK_STREQ(strings[j], top[i]);
+ }
free(strings);
}
Home |
Main Index |
Thread Index |
Old Index