| |
@@ -0,0 +1,183 @@
|
| |
+ #!/bin/bash
|
| |
+ # runtest.sh - bz447416-segfaults - Bugzilla(s) 447416
|
| |
+ # Author: Petr Muller <pmuller@redhat.com>
|
| |
+ # Location: /tools/elfutils/Regression/bz447416-segfaults/runtest.sh
|
| |
+
|
| |
+ # Description: Tests various ELFs on various utils, looking for segfaults
|
| |
+
|
| |
+ # Copyright (c) 2008 Red Hat, Inc. All rights reserved. This copyrighted material
|
| |
+ # is made available to anyone wishing to use, modify, copy, or
|
| |
+ # redistribute it subject to the terms and conditions of the GNU General
|
| |
+ # Public License v.2.
|
| |
+ #
|
| |
+ # This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
| |
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
| |
+ # PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
| |
+ #
|
| |
+ # You should have received a copy of the GNU General Public License
|
| |
+ # along with this program; if not, write to the Free Software
|
| |
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
| |
+
|
| |
+ test_binary(){
|
| |
+ command="$1"
|
| |
+ args="$2"
|
| |
+ expected="$3"
|
| |
+ comment="$4"
|
| |
+
|
| |
+ echo $command >> $TESTED
|
| |
+ rlRun "$command $args > /dev/null" $expected "$comment"
|
| |
+ excode=$?
|
| |
+ if [ $excode -gt 127 ]
|
| |
+ then
|
| |
+ rlLog "Unusual exit code: $excode"
|
| |
+ fi
|
| |
+ }
|
| |
+
|
| |
+ PACKAGE=elfutils
|
| |
+
|
| |
+ . /usr/share/beakerlib/beakerlib.sh
|
| |
+
|
| |
+ rlJournalStart
|
| |
+
|
| |
+ rlPhaseStartSetup "Setting up testcases"
|
| |
+ tar xfz testcases.tar.gz
|
| |
+ rlAssertExists binaries
|
| |
+ export TESTED=`mktemp`
|
| |
+ export TOBE=`mktemp`
|
| |
+
|
| |
+ rlRun "gcc -o binaries/testprog -g testprog.c"
|
| |
+
|
| |
+ for file in $(rpm -ql `rpm -qa | grep elfutils` | grep 'bin' | grep -v '\.')
|
| |
+ do
|
| |
+ NAME=`basename $file`
|
| |
+ if [ "$NAME" != "bin" ]
|
| |
+ then
|
| |
+ basename $file >> $TOBE
|
| |
+ fi
|
| |
+ done
|
| |
+ sort $TOBE -o $TOBE
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ pushd binaries &> /dev/null
|
| |
+ for arch in i386 ia64 ppc ppc64 s390 s390x x86_64
|
| |
+ do
|
| |
+ rlPhaseStartTest "Testing $arch binary inputs"
|
| |
+ if rlIsRHEL 5 || rlIsFedora || rlIsRHEL 6 || rlIsRHEL 7 || rlIsRHEL 8 || rlIsRHEL 9
|
| |
+ then
|
| |
+ test_binary "eu-elfcmp" "eu-readelf-$arch eu-readelf-$arch" 0 "Testing eu-elfcmp on identical files"
|
| |
+ fi
|
| |
+
|
| |
+ test_binary "eu-elflint" "eu-readelf-$arch" 0,1 "Testing elflint without --gnu-ld"
|
| |
+ test_binary "eu-elflint" "eu-readelf-$arch -q --gnu-ld" 0,1 "Testing elflint with --gnu-ld"
|
| |
+ test_binary "eu-nm" "eu-readelf-$arch" 1 "Testing nm"
|
| |
+ test_binary "eu-nm" "-D eu-readelf-$arch" 0 "Testing nm -D"
|
| |
+
|
| |
+ if rlIsRHEL 5 || rlIsFedora || rlIsRHEL 6 || rlIsRHEL 7 || rlIsRHEL 8 || rlIsRHEL 9
|
| |
+ then
|
| |
+ test_binary "eu-objdump" "-ds eu-readelf-$arch" 0,1 "Testing objdump -ds"
|
| |
+ fi
|
| |
+
|
| |
+ options="-A0 -d0 -h0 -I0 -l0 -n0 -r0 -s0 -S0 -V0 -w1"
|
| |
+ options="-a0 $options"
|
| |
+
|
| |
+ if rlIsRHEL 5 || rlIsFedora || rlIsRHEL 6 || rlIsRHEL 7
|
| |
+ then
|
| |
+ options="$options -c1 -p0"
|
| |
+ fi
|
| |
+
|
| |
+ for option in $options
|
| |
+ do
|
| |
+ opt=${option:0:2}
|
| |
+ exp=${option:2}
|
| |
+ test_binary "eu-readelf" "$opt eu-readelf-$arch" $exp "Testing readelf $opt"
|
| |
+ done
|
| |
+ test_binary "eu-size" "eu-readelf-$arch" 0 "Testing eu-size"
|
| |
+ if rlIsRHEL 5 || rlIsFedora || rlIsRHEL 6 || rlIsRHEL 7 || rlIsRHEL 8 || rlIsRHEL 9
|
| |
+ then
|
| |
+ test_binary "eu-strings" "eu-readelf-$arch" 0 "Testing eu-strings"
|
| |
+ fi
|
| |
+ test_binary "eu-strip" "eu-readelf-$arch" 0 "Testing eu-strip"
|
| |
+
|
| |
+ test_binary "eu-ar" "rcs test.a eu-readelf-$arch" 0 "Testing eu-ar - creating an archive"
|
| |
+ test_binary "eu-ar" "pv test.a" 0 "Testing eu-ar - print the list of modules"
|
| |
+ test_binary "eu-ar" "tv test.a" 0 "Testing eu-ar - print the file table"
|
| |
+
|
| |
+ test_binary "eu-ranlib" "test.a" 0 "Testing eu-ranlib"
|
| |
+
|
| |
+ # This test should be done better - eu-make-debug-archive should do real things
|
| |
+ test_binary "eu-make-debug-archive" "--kernel test.a" 0,1 "Testing eu-make-debug-archive"
|
| |
+
|
| |
+ # This test should be done better - eu-findtextrel should do real things
|
| |
+ test_binary "eu-findtextrel" "eu-readelf-$arch" 0,1 "Testing eu-findtextrel"
|
| |
+
|
| |
+ test_binary "eu-addr2line" "stderr -A -f -e eu-readelf-$arch" 0 "Testing eu-addr2line"
|
| |
+
|
| |
+ rlRun "objcopy --only-keep-debug testprog testprog.debuginfo"
|
| |
+ rlRun "eu-strip --strip-debug -o testprog.stripped testprog"
|
| |
+ test_binary "eu-unstrip" "-o testprog.restored testprog.stripped testprog.debuginfo" 0 "Testing eu-unstrip"
|
| |
+
|
| |
+ rlPhaseEnd
|
| |
+ done
|
| |
+
|
| |
+ rlPhaseStart FAIL "eu-stack specific asserts (in elfutils since 0.158)"
|
| |
+ if grep -q '^eu-stack$' $TOBE
|
| |
+ then
|
| |
+ test_binary "eu-stack" "-p 1" 0,1 "Testing eu-stack"
|
| |
+ fi
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStart FAIL "eu-elfcompress specific asserts (in elfutils since 0.165)"
|
| |
+ # eu-elfcompress
|
| |
+ if grep -q '^eu-elfcompress$' $TOBE
|
| |
+ then
|
| |
+ for i in zlib zlib-gabi gnu zlib-gnu; do
|
| |
+ test_binary "eu-elfcompress" "-o testprog.compressed.$i -t $i testprog" 0 "Testing eu-elfcompress ($i)"
|
| |
+ rlRun "eu-elfcmp testprog testprog.compressed.$i"
|
| |
+ test_binary "eu-elfcompress" "-o testprog.uncompressed -t none testprog" 0 "Testing eu-elfcompress (none)"
|
| |
+ rlRun "eu-elfcmp testprog testprog.uncompressed"
|
| |
+ done
|
| |
+ fi
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ if grep -q '^eu-elfclassify$' $TOBE; then
|
| |
+ rlPhaseStart FAIL "Test eu-elfclassify (in elfutils since 0.178)"
|
| |
+ for copt in --elf --elf-file --executable --loadable --program --unstripped; do
|
| |
+ test_binary "eu-elfclassify" "$copt testprog" 0 "Testing eu-elfclassify $copt"
|
| |
+ done
|
| |
+ for copt in --core --debug-only --elf-archive --library --linux-kernel-module --shared; do
|
| |
+ test_binary "eu-elfclassify" "$copt testprog" 1 "Testing eu-elfclassify $copt"
|
| |
+ done
|
| |
+ rlPhaseEnd
|
| |
+ fi
|
| |
+
|
| |
+ if grep -q '^debuginfod$' $TOBE; then
|
| |
+ rlPhaseStart FAIL "Test debuginfod (in elfutils since 0.178)"
|
| |
+ test_binary debuginfod "--help" 0 "Test debuginfod for a trivial segv"
|
| |
+ rlPhaseEnd
|
| |
+ fi
|
| |
+
|
| |
+ if grep -q '^debuginfod-find$' $TOBE; then
|
| |
+ rlPhaseStart FAIL "Test debuginfod-find (in elfutils since 0.178)"
|
| |
+ test_binary "debuginfod-find" "--help" 0 "Test debuginfod-find for a trivial segv"
|
| |
+ rlPhaseEnd
|
| |
+ fi
|
| |
+
|
| |
+ popd &> /dev/null
|
| |
+
|
| |
+ rlPhaseStartTest "Testing if complete elfutils were tested"
|
| |
+ sort -u $TESTED -o $TESTED
|
| |
+ for file in `cat $TOBE`
|
| |
+ do
|
| |
+ rlLog "Checking if $file was tested"
|
| |
+ rlAssertGrep $file $TESTED
|
| |
+ done
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartCleanup
|
| |
+ rm -rf binaries $TOBE $TESTED
|
| |
+ rm -f test.a testprog testprog.debuginfo testprog.stripped testprog.restored
|
| |
+ rlAssertNotExists binaries
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlJournalPrintText
|
| |
+ rlJournalEnd
|
| |
Introduce CI gating tests.