binutils/tests/testsuite/test.sh
2024-07-31 10:01:30 +02:00

98 lines
3.5 KiB
Bash
Executable file

#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Run binutils upstream test suite
#
# Author: Milos Prchlik <mprchlik@redhat.com>
# Author: Michael Petlan <mpetlan@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2015 Red Hat, Inc.
#
# 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 version 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
. "$TMT_TREE/tests/lib.sh" || exit 1
. ./interesting-cases.sh || exit 1
rlJournalStart
rlPhaseStartSetup
buTestHeader
ARCH="$(rlGetPrimaryArch)"
BUILD_ARCHS="$ARCH"
rlLogInfo "ARCH=$ARCH"
rlLogInfo "BUILD_ARCHS=$BUILD_ARCHS"
buEnterTmpDir
rlRun "LOGDIR=$TmpDir/LOGS"
rlRun "BUILDDIR=$(rpm --define='_topdir $TmpDir' --eval=%_builddir)"
rlRun "CURRENT_BUILD=${BUILDDIR}/binutils-$(rpmquery "$BINUTILS_PACKAGE" --queryformat=%{VERSION})"
rlRun "mkdir $LOGDIR"
buPrepareSRPM "$BINUTILS_PACKAGE"
rlPhaseEnd
rlPhaseStartSetup "Rebuild binutils"
buBuildSRPM
rlRun "cp $CURRENT_BUILD/binutils/binutils.log $LOGDIR/binutils-$ARCH.log"
rlRun "cp $CURRENT_BUILD/binutils/binutils.sum $LOGDIR/binutils-$ARCH.sum"
rlRun "cp $CURRENT_BUILD/ld/ld.log $LOGDIR/ld-$ARCH.log"
rlRun "cp $CURRENT_BUILD/ld/ld.sum $LOGDIR/ld-$ARCH.sum"
rlRun "cp $CURRENT_BUILD/gas/testsuite/gas.log $LOGDIR/gas-$ARCH.log"
rlRun "cp $CURRENT_BUILD/gas/testsuite/gas.sum $LOGDIR/gas-$ARCH.sum"
rlPhaseEnd
for TOOL in binutils ld gas; do
tool_label="$TOOL / $ARCH"
tool_log="$LOGDIR/$TOOL-$ARCH"
rlPhaseStartTest "$tool_label"
rlLogInfo "$tool_label Summary"
rlLogInfo "$(grep -A 50 '=== .* Summary ===' "$tool_log.sum")"
rlRun "awk \"/=== $TOOL tests ===/,/=== $TOOL Summary ===/\" $tool_log.sum > $tool_log.tests" 0,1 "Save results of all tests"
rlRun "grep -E '^FAIL: ' $tool_log.tests | sort > $tool_log.failed" 0,1 "Save failures"
rlRun "grep '# of unexpected failures' $tool_log.sum" 1 "Checking number of unexpected failures"
rlLogInfo "Failed tests:\n$(sort < "$tool_log.failed")"
rlLogInfo "All tests:\n$(grep -E '^[A-Z]+:' "$tool_log.tests" | sort)"
rlPhaseEnd
verify_interesting_cases "$TOOL" "$tool_label" "$tool_log"
done
rlPhaseStartCleanup
rlRun "tar czf $TmpDir/logs.tgz $LOGDIR/*.sum $LOGDIR/*.log $LOGDIR/*.tests $LOGDIR/*.failed"
rlRun "tar czf $TmpDir/buildroot.tgz $CURRENT_BUILD/"
rlFileSubmit logs.tar.gz
rlFileSubmit buildroot.tgz
buExitTmpDir
rlPhaseEnd
rlJournalPrintText
rlJournalEnd