From: Ulf Hermann Date: Thu, 17 Jan 2019 14:00:46 +0000 (+0100) Subject: tests: Use separate files for strip outputs X-Git-Tag: elfutils-0.176~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b548f4fe92c43e117cac395a8d23cb9c1fab02af;p=thirdparty%2Felfutils.git tests: Use separate files for strip outputs This way we can verify that strip actually created all of them. Also, check that strip, unstrip, elflint actually succeed in run-strip-test-many.sh. This exposed the fact that the generated testfile in run-strip-test-many.sh is considered as illformed by strip -g. Signed-off-by: Ulf Hermann --- diff --git a/tests/ChangeLog b/tests/ChangeLog index 2dd8026d4..9b5899675 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2019-01-18 Ulf Hermann + + * run-annobingroup.sh: Use different files for strip output. + * run-strip-test-many.sh: Use different files for strip output, + check results of strip, unstrip, elflint. + 2019-01-24 Mark Wielaard * addsections.c (add_sections): Change the name of the old shstrtab diff --git a/tests/run-annobingroup.sh b/tests/run-annobingroup.sh index fd36e4acb..16b031a19 100755 --- a/tests/run-annobingroup.sh +++ b/tests/run-annobingroup.sh @@ -25,7 +25,7 @@ # gcc -g -O2 -fplugin=annobin -c testfile-annobingroup.c testfiles testfile-annobingroup.o -tempfiles merged.elf stripped.elf debugfile.elf remerged.elf +tempfiles merged.elf stripped.elf debugfile1.elf debugfile2.elf debugfile3.elf remerged.elf testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup.o << EOF @@ -35,7 +35,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent [ 9] .text.unlikely EOF -testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup.o +testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile1.elf testfile-annobingroup.o testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF @@ -45,7 +45,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent [ 9] .text.unlikely EOF -testrun_compare ${abs_top_builddir}/src/readelf -g debugfile.elf << EOF +testrun_compare ${abs_top_builddir}/src/readelf -g debugfile1.elf << EOF Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: [ 7] .gnu.build.attributes..text.unlikely @@ -53,7 +53,7 @@ Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 ent [ 9] .text.unlikely EOF -testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf +testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile1.elf testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF @@ -81,7 +81,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai [13] .text.__x86.get_pc_thunk.ax EOF -testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-i386.o +testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile2.elf testfile-annobingroup-i386.o testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF @@ -94,7 +94,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai [13] .text.__x86.get_pc_thunk.ax EOF -testrun_compare ${abs_top_builddir}/src/readelf -g debugfile.elf << EOF +testrun_compare ${abs_top_builddir}/src/readelf -g debugfile2.elf << EOF Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: [ 8] .gnu.build.attributes..text.unlikely @@ -105,7 +105,7 @@ COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contai [13] .text.__x86.get_pc_thunk.ax EOF -testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf +testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile2.elf testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF @@ -143,13 +143,13 @@ Section group [ 4] '.group' with signature '.text.unlikely..group' contains 1 en [27] .text.unlikely EOF -testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-x86_64.o +testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile3.elf testfile-annobingroup-x86_64.o # This would/should work, except for the unknown NOTEs. # testrun ${abs_top_builddir}/src/elflint --gnu stripped.elf -# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile.elf +# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile3.elf -testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf +testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile3.elf testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-x86_64.o remerged.elf diff --git a/tests/run-strip-test-many.sh b/tests/run-strip-test-many.sh index 9a9657cda..b0cbad8b1 100755 --- a/tests/run-strip-test-many.sh +++ b/tests/run-strip-test-many.sh @@ -17,50 +17,67 @@ . $srcdir/test-subr.sh +status=0 + # Use the original file from run-strip-test.sh but with many sections testfiles testfile -tempfiles testfile.strip testfile.debug testfile.unstrip +tempfiles testfile1.strip testfile2.strip testfile1.debug testfile2.debug testfile.unstrip echo "Adding sections to testfile" -testrun ${abs_builddir}/addsections 65535 testfile +testrun ${abs_builddir}/addsections 65535 testfile || +{ echo "*** failure addsections testfile"; status=1; } echo "Testing strip -o" -testrun ${abs_top_builddir}/src/strip -o testfile.strip -f testfile.debug testfile +testrun ${abs_top_builddir}/src/strip -o testfile1.strip -f testfile1.debug testfile || +{ echo "*** failure strip -o"; status=1; } # Do the parts check out? -echo "elflint testfile.strip" -testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.strip -echo "elflint testfile.debug" -testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug +echo "elflint testfile1.strip" +testrun ${abs_top_builddir}/src/elflint --gnu -q testfile1.strip || +{ echo "*** failure elflint testfile1.strip"; status=1; } + +echo "elflint testfile1.debug" +testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile1.debug || +{ echo "*** failure elflint testfile1.debug"; status=1; } # Now test unstrip recombining those files. echo "unstrip" -testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile.strip testfile.debug +testrun ${abs_top_builddir}/src/unstrip -o testfile.unstrip testfile1.strip testfile1.debug || +{ echo "*** failure unstrip"; status=1; } + echo "elfcmp" -testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip +testrun ${abs_top_builddir}/src/elfcmp testfile testfile.unstrip || +{ echo "*** failure elfcmp"; status=1; } # test strip -g echo "Testing strip -g" -testrun ${abs_top_builddir}/src/strip -g -o testfile.strip -f testfile.debug testfile +testrun ${abs_top_builddir}/src/strip -g -o testfile2.strip -f testfile2.debug testfile || +{ echo "*** failure strip -g"; status=1; } # Do the parts check out? -echo "elflint testfile.strip" -testrun ${abs_top_builddir}/src/elflint --gnu -q testfile.strip -echo "elflint testfile.debug" -testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile.debug +echo "elflint testfile2.strip" +testrun ${abs_top_builddir}/src/elflint --gnu -q testfile2.strip || +{ echo "*** failure elflint testfile2.strip"; status=1; } + +echo "elflint testfile2.debug" +testrun ${abs_top_builddir}/src/elflint --gnu -q -d testfile2.debug || +{ echo "*** failure elflint testfile2.debug"; status=1; } # Now strip "in-place" and make sure it is smaller. -echo "TEsting strip in-place" +echo "Testing strip in-place" SIZE_original=$(stat -c%s testfile) echo "original size $SIZE_original" -testrun ${abs_top_builddir}/src/strip testfile +testrun ${abs_top_builddir}/src/strip testfile || +{ echo "*** failure strip in-place"; status=1; } + SIZE_stripped=$(stat -c%s testfile) echo "stripped size $SIZE_stripped" test $SIZE_stripped -lt $SIZE_original || { echo "*** failure in-place strip file not smaller $original"; exit 1; } echo "elflint in-place" -testrun ${abs_top_builddir}/src/elflint --gnu -q testfile +testrun ${abs_top_builddir}/src/elflint --gnu -q testfile || +{ echo "*** failure elflint in-place"; status=1; } -exit 0 +exit $status