public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] tests: Add a bit less and slightly smaller sections for addsections
@ 2023-06-17  0:11 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2023-06-17  0:11 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-17  0:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-17  0:11 [COMMITTED] tests: Add a bit less and slightly smaller sections for addsections Mark Wielaard

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).