libunwind-devel
[Top][All Lists]
Advanced

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

[Libunwind-devel] [PATCH 1/5] Make coredump test also test unw_get_proc_


From: Martin Milata
Subject: [Libunwind-devel] [PATCH 1/5] Make coredump test also test unw_get_proc_name
Date: Fri, 10 Aug 2012 16:03:53 +0200

Signed-off-by: Martin Milata <address@hidden>
---
 tests/run-coredump-unwind    |    8 ++------
 tests/test-coredump-unwind.c |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/tests/run-coredump-unwind b/tests/run-coredump-unwind
index 18060c5..d6dd7e0 100755
--- a/tests/run-coredump-unwind
+++ b/tests/run-coredump-unwind
@@ -1,7 +1,8 @@
 #!/bin/sh
 
 TESTDIR=`pwd`
-TEMPDIR=`mktemp -d`
+TEMPDIR=`mktemp --tmpdir -d libunwind-test-XXXXXXXXXX`
+trap "rm -r -- $TEMPDIR" EXIT
 
 # create core dump
 (
@@ -11,10 +12,5 @@ TEMPDIR=`mktemp -d`
 ) 2>/dev/null
 COREFILE=$TEMPDIR/core*
 
-# fail if any command fails
-set -e
-
 # magic option -testcase enables checking for the specific contents of the 
stack
 ./test-coredump-unwind $COREFILE -testcase `cat $TEMPDIR/backing_files`
-
-rm -r -- $TEMPDIR
diff --git a/tests/test-coredump-unwind.c b/tests/test-coredump-unwind.c
index ab1ff03..2b2d4b9 100644
--- a/tests/test-coredump-unwind.c
+++ b/tests/test-coredump-unwind.c
@@ -269,9 +269,11 @@ main(int argc, char **argv)
   int ret;
 
 #define TEST_FRAMES 4
+#define TEST_NAME_LEN 16
   int testcase = 0;
   int test_cur = 0;
   long test_start_ips[TEST_FRAMES];
+  char test_names[TEST_FRAMES][TEST_NAME_LEN];
 
   install_sigsegv_handler();
 
@@ -338,7 +340,13 @@ main(int argc, char **argv)
 
       if (testcase && test_cur < TEST_FRAMES)
         {
+           unw_word_t off;
+
            test_start_ips[test_cur] = (long) pi.start_ip;
+           if (unw_get_proc_name(&c, test_names[test_cur], 
sizeof(test_names[0]), &off) != 0)
+           {
+             test_names[test_cur][0] = '\0';
+           }
            test_cur++;
         }
 
@@ -366,6 +374,18 @@ main(int argc, char **argv)
       return -1;
     }
 
+  if (testcase &&
+       (  strcmp(test_names[0], "a")
+       || strcmp(test_names[1], "b")
+       || strcmp(test_names[2], "b")
+       || strcmp(test_names[3], "main")
+       )
+     )
+    {
+      fprintf(stderr, "FAILURE: procedure names are missing/incorrect\n");
+      return -1;
+    }
+
   _UCD_destroy(ui);
 
   return 0;
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]