]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Add a bit less and slightly smaller sections for addsections
authorMark Wielaard <mark@klomp.org>
Fri, 16 Jun 2023 23:40:38 +0000 (01:40 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 16 Jun 2023 23:40:38 +0000 (01:40 +0200)
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
tests/run-copymany-sections.sh

index c1b0fa81f5acaf7d586d769ab923934de314458f..a4e42038605ff7aa3bd46db1b1316acaaba6a361 100644 (file)
@@ -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);
 }
 
index 84c052c957fcf992c905257958c38993564cb47e..01348229131cecfffe8233bfa1adb24ac52cff11 100755 (executable)
@@ -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