# 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
[ 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
[ 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
[ 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
[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
[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
[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
[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
. $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