From: Mark Wielaard Date: Fri, 16 Jun 2023 23:40:38 +0000 (+0200) Subject: tests: Add a bit less and slightly smaller sections for addsections X-Git-Tag: elfutils-0.190~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8bcce843fd11ea5fcc1dd350db9069843757e94f;p=thirdparty%2Felfutils.git tests: Add a bit less and slightly smaller sections for addsections 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 --- diff --git a/tests/addsections.c b/tests/addsections.c index c1b0fa81f..a4e420386 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 84c052c95..013482291 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