Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libexecinfo Use a struct for pair of frame name an...



details:   https://anonhg.NetBSD.org/src/rev/a977a934bc48
branches:  trunk
changeset: 327570:a977a934bc48
user:      joerg <joerg%NetBSD.org@localhost>
date:      Tue Mar 11 13:43:23 2014 +0000

description:
Use a struct for pair of frame name and whether it is optional. Add some
additional entries found in a -O0 build of ATF on PowerPC.

diffstat:

 tests/lib/libexecinfo/t_backtrace.c |  32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diffs (69 lines):

diff -r 9e5624708d10 -r a977a934bc48 tests/lib/libexecinfo/t_backtrace.c
--- a/tests/lib/libexecinfo/t_backtrace.c       Tue Mar 11 08:19:45 2014 +0000
+++ b/tests/lib/libexecinfo/t_backtrace.c       Tue Mar 11 13:43:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_backtrace.c,v 1.12 2014/01/11 19:48:22 martin Exp $  */
+/*     $NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 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.12 2014/01/11 19:48:22 martin Exp $");
+__RCSID("$NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 joerg Exp $");
 
 #include <atf-c.h>
 #include <atf-c/config.h>
@@ -53,19 +53,28 @@
 void
 myfunc3(size_t ncalls)
 {
-       static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body",
-           "atf_tc_run", "atf_tp_run", "atf_tp_main", "main", "___start" };
-       static bool optional_frame[] = { false, false, false, true, false,
-           true, true };
+       static const struct {
+               const char *name;
+               bool is_optional;
+       } frames[] = {
+           { "myfunc", false },
+           { "atfu_backtrace_fmt_basic_body", false },
+           { "atf_tc_run", false }, 
+           { "atf_tp_run", true },
+           { "run_tc", true },
+           { "controlled_main", true },
+           { "atf_tp_main", false },
+           { "main", true },
+           { "___start", true },
+       };
        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])
+       for (j = 0; j < __arraycount(frames); ++j) {
+               if (!frames[j].is_optional)
                        ++min_frames;
                ++max_frames;
        }
@@ -90,11 +99,12 @@
                ATF_CHECK_STREQ(strings[j], "myfunc1");
 
        for (size_t i = 0; j < nptrs; i++, j++) {
-               if (optional_frame[i] && strcmp(strings[j], top[i])) {
+               if (frames[i].is_optional &&
+                   strcmp(strings[j], frames[i].name)) {
                        --i;
                        continue;
                }
-               ATF_CHECK_STREQ(strings[j], top[i]);
+               ATF_CHECK_STREQ(strings[j], frames[i].name);
        }
 
        free(strings);



Home | Main Index | Thread Index | Old Index