public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [COMMITTED] tests: Add a bit less and slightly smaller sections for addsections
Date: Sat, 17 Jun 2023 02:11:44 +0200	[thread overview]
Message-ID: <20230617001144.232737-1-mark@klomp.org> (raw)

The run-copymany-sections.sh testcase adds 64K sections (twice)
to a couple of times. Each section is just 6 bytes long, but each
data section is malloced and freed. That adds up. And is especially
slow when running under valgrind.

Reduce the number of sections added to 32K (twice) and make each
section data just one single zero byte.

	* tests/addsections.c (add_sections): Don't strdup and free
	the string ".extra", but just add the empty string.
	* tests/run-copymany-sections.sh: Call addsections with
	32768 instead of 65535.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 tests/addsections.c            | 7 ++++---
 tests/run-copymany-sections.sh | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/tests/addsections.c b/tests/addsections.c
index c1b0fa81..a4e42038 100644
--- a/tests/addsections.c
+++ b/tests/addsections.c
@@ -153,8 +153,8 @@ add_sections (const char *name, size_t nr, int use_mmap, size_t sec_size)
   size_t bufsz;
   if (sec_size == 0)
     {
-      buf = strdup ("extra");
-      bufsz = strlen ("extra") + 1;
+      buf = "";
+      bufsz = 1;
     }
   else
     {
@@ -293,7 +293,8 @@ add_sections (const char *name, size_t nr, int use_mmap, size_t sec_size)
       exit (1);
     }
 
-  free (buf);
+  if (sec_size != 0)
+    free (buf);
   free (new_shstrtab_buf);
 }
 
diff --git a/tests/run-copymany-sections.sh b/tests/run-copymany-sections.sh
index 84c052c9..01348229 100755
--- a/tests/run-copymany-sections.sh
+++ b/tests/run-copymany-sections.sh
@@ -35,12 +35,13 @@ test_copy_and_add ()
   testrun ${abs_top_builddir}/src/elfcmp ${in_file} ${out_file}
 
   # Can we add a section (in-place)?
-  testrun ${abs_builddir}/addsections 65535 ${out_file}
+  testrun ${abs_builddir}/addsections 32768 ${out_file}
   testrun ${abs_top_builddir}/src/readelf -S ${out_file} > readelf.out
   nr=$(grep '.extra' readelf.out | wc -l)
   # We try twice...
-  if test ${nr} != 65535 -a ${nr} != 131070; then
+  if test ${nr} != 32768 -a ${nr} != 65536; then
     # Show what went wrong
+    echo nr: ${nr}
     testrun ${abs_top_builddir}/src/readelf -S ${out_file}
     exit 1
   fi
-- 
2.39.3


                 reply	other threads:[~2023-06-17  0:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230617001144.232737-1-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).