diff mbox series

[v2,1/4] elf: Always write audit log to elf/tst-audit23.out

Message ID 525b784edd12948565604c56f036309e61c8c428.1725379370.git.fweimer@redhat.com
State New
Headers show
Series Audit fixes for proxy link maps | expand

Commit Message

Florian Weimer Sept. 3, 2024, 4:04 p.m. UTC
Hopefully, this will simplify debugging test failures.
---
 elf/tst-audit23.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/elf/tst-audit23.c b/elf/tst-audit23.c
index d2640fe8b2..ca4219c82b 100644
--- a/elf/tst-audit23.c
+++ b/elf/tst-audit23.c
@@ -85,6 +85,20 @@  do_test (int argc, char *argv[])
     = support_capture_subprogram (spargv[0], spargv, NULL);
   support_capture_subprocess_check (&result, "tst-audit22", 0, sc_allow_stderr);
 
+  {
+    FILE *fp = fmemopen (result.err.buffer, result.err.length, "r");
+    TEST_VERIFY (fp != NULL);
+    unsigned int line = 0;
+    char *buffer = NULL;
+    size_t buffer_length = 0;
+    puts ("info: *** audit log start ***");
+    while (xgetline (&buffer, &buffer_length, fp))
+      printf ("%6u\t%s", ++line, buffer);
+    puts ("info: *** audit log end ***");
+    free (buffer);
+    xfclose (fp);
+  }
+
   /* The expected la_objopen/la_objclose:
      1. executable
      2. loader
@@ -115,8 +129,10 @@  do_test (int argc, char *argv[])
   TEST_VERIFY (out != NULL);
   char *buffer = NULL;
   size_t buffer_length = 0;
+  unsigned int line = 0;
   while (xgetline (&buffer, &buffer_length, out))
     {
+      ++line;
       if (startswith (buffer, "la_activity: "))
 	{
 	  uintptr_t cookie;
@@ -174,8 +190,8 @@  do_test (int argc, char *argv[])
 	  if (is_vdso (lname))
 	    continue;
 	  if (nobjs == max_objs)
-	    FAIL_EXIT1 ("non expected la_objopen: %s %"PRIxPTR" %ld",
-			lname, laddr, lmid);
+	    FAIL_EXIT1 ("(line %u) non expected la_objopen: %s %"PRIxPTR" %ld",
+			line, lname, laddr, lmid);
 	  objs[nobjs].lname = lname;
 	  objs[nobjs].laddr = laddr;
 	  objs[nobjs].lmid = lmid;