This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] Replace assert_perror with assert


assert_perror is a GNU extension, it's not provided by uClibc and it's
only used in tests. Replace it with assert.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 tests/ChangeLog         |  8 ++++++++
 tests/backtrace-child.c |  4 ++--
 tests/backtrace-data.c  | 22 +++++++++++-----------
 tests/backtrace-dwarf.c |  4 ++--
 tests/backtrace.c       | 10 +++++-----
 5 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 11e96a7..a899947 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
+
+	* backtrace-child.c (stdarg, main): Replace assert_perror with assert.
+	* backtrace-data.c (memory_read, maps_lookup, set_initial_registers)
+	(main): Likewise.
+	* backtrace-dwarf.c (main): Likewise.
+	* backtrace.c (prepare_thread, exec_dump): Likewise.
+
 2015-05-04  Anthony G. Basile  <blueness@gentoo.org>
 
 	* Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD)
diff --git a/tests/backtrace-child.c b/tests/backtrace-child.c
index 788801c..40e7b32 100644
--- a/tests/backtrace-child.c
+++ b/tests/backtrace-child.c
@@ -154,7 +154,7 @@ stdarg (int f UNUSED, ...)
   if (ptraceme)
     {
       long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
-      assert_perror (errno);
+      assert (errno == 0);
       assert (l == 0);
     }
 #ifdef __x86_64__
@@ -226,7 +226,7 @@ main (int argc UNUSED, char **argv)
     {
       errno = 0;
       long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
-      assert_perror (errno);
+      assert (errno == 0);
       assert (l == 0);
     }
   if (gencore)
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
index 01c1c00..5a93a9c 100644
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -74,7 +74,7 @@ memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result,
 
   errno = 0;
   long l = ptrace (PTRACE_PEEKDATA, child, (void *) (uintptr_t) addr, NULL);
-  assert_perror (errno);
+  assert (errno == 0);
   *result = l;
 
   /* We could also return false for failed ptrace.  */
@@ -89,10 +89,10 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
 {
   char *fname;
   int i = asprintf (&fname, "/proc/%ld/maps", (long) pid);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (i > 0);
   FILE *f = fopen (fname, "r");
-  assert_perror (errno);
+  assert (errno == 0);
   assert (f);
   free (fname);
   for (;;)
@@ -100,7 +100,7 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
       // 37e3c22000-37e3c23000 rw-p 00022000 00:11 49532 /lib64/ld-2.14.90.so */
       unsigned long start, end, offset;
       i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset);
-      assert_perror (errno);
+      assert (errno == 0);
       assert (i == 3);
       char *filename = strdup ("");
       assert (filename);
@@ -121,7 +121,7 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep)
       if (start <= addr && addr < end)
 	{
 	  i = fclose (f);
-	  assert_perror (errno);
+	  assert (errno == 0);
 	  assert (i == 0);
 
 	  *basep = start - offset;
@@ -171,7 +171,7 @@ set_initial_registers (Dwfl_Thread *thread,
 
   struct user_regs_struct user_regs;
   long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (l == 0);
 
   Dwarf_Word dwarf_regs[17];
@@ -271,11 +271,11 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
   switch (child)
   {
     case -1:
-      assert_perror (errno);
+      assert (errno == 0);
       assert (0);
     case 0:;
       long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
-      assert_perror (errno);
+      assert (errno == 0);
       assert (l == 0);
       raise (SIGUSR1);
       return 0;
@@ -285,7 +285,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
 
   int status;
   pid_t pid = waitpid (child, &status, 0);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (pid == child);
   assert (WIFSTOPPED (status));
   assert (WSTOPSIG (status) == SIGUSR1);
@@ -303,7 +303,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
 
   struct user_regs_struct user_regs;
   long l = ptrace (PTRACE_GETREGS, child, NULL, &user_regs);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (l == 0);
   report_module (dwfl, child, user_regs.rip);
 
@@ -317,7 +317,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
   dwfl_end (dwfl);
   kill (child, SIGKILL);
   pid = waitpid (child, &status, 0);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (pid == child);
   assert (WIFSIGNALED (status));
   assert (WTERMSIG (status) == SIGKILL);
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index fbcb22e..a644c8a 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -143,7 +143,7 @@ main (int argc __attribute__ ((unused)), char **argv)
       abort ();
     case 0:;
       long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
-      assert_perror (errno);
+      assert (errno == 0);
       assert (l == 0);
       cleanup_13_main ();
       abort ();
@@ -154,7 +154,7 @@ main (int argc __attribute__ ((unused)), char **argv)
   errno = 0;
   int status;
   pid_t got = waitpid (pid, &status, 0);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (got == pid);
   assert (WIFSTOPPED (status));
   assert (WSTOPSIG (status) == SIGABRT);
diff --git a/tests/backtrace.c b/tests/backtrace.c
index 8b19b94..abd56ab 100644
--- a/tests/backtrace.c
+++ b/tests/backtrace.c
@@ -263,16 +263,16 @@ prepare_thread (pid_t pid2 __attribute__ ((unused)),
   struct user_regs_struct user_regs;
   errno = 0;
   l = ptrace (PTRACE_GETREGS, pid2, 0, (intptr_t) &user_regs);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (l == 0);
   user_regs.rip = (intptr_t) jmp;
   l = ptrace (PTRACE_SETREGS, pid2, 0, (intptr_t) &user_regs);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (l == 0);
   l = ptrace (PTRACE_CONT, pid2, NULL, (void *) (intptr_t) SIGUSR2);
   int status;
   pid_t got = waitpid (pid2, &status, __WALL);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (got == pid2);
   assert (WIFSTOPPED (status));
   assert (WSTOPSIG (status) == SIGUSR1);
@@ -340,7 +340,7 @@ exec_dump (const char *exec)
   errno = 0;
   int status;
   pid_t got = waitpid (pid, &status, 0);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (got == pid);
   assert (WIFSTOPPED (status));
   // Main thread will signal SIGUSR2.  Other thread will signal SIGUSR1.
@@ -350,7 +350,7 @@ exec_dump (const char *exec)
      __WCLONE, probably despite pthread_create already had to be called the new
      task is not yet alive enough for waitpid.  */
   pid_t pid2 = waitpid (-1, &status, __WALL);
-  assert_perror (errno);
+  assert (errno == 0);
   assert (pid2 > 0);
   assert (pid2 != pid);
   assert (WIFSTOPPED (status));
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]