Import RHEL's test Sanity/testsuite

It's a wrapper for the upstream test suite.

There's one small addition (already inherited from RHEL) covering
but I'm keeping it here for convenience as it works with the upstream
test suite too. I've slightly modified it to make it work beyond
RHEL 8. The modification is based on the final upstream fix [1] and
the related discussion in thread [2].

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6bf4a34047452f882c5cc66bd85812ee1bb5a41c
[2] https://sourceware.org/pipermail/binutils/2018-August/104304.html
This commit is contained in:
Václav Kadlčík 2021-05-14 10:11:23 +02:00 committed by mcermak
parent 2680508b04
commit 473ccf2683
4 changed files with 242 additions and 0 deletions

View File

@ -0,0 +1,68 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/binutils/Sanity/testsuite
# Description: The test rebuilds binutils.src.rpm and runs the suite.
# 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.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/tools/binutils/Sanity/testsuite
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE \
expected-fails-8.0.0-aarch64.txt \
expected-fails-8.0.0-s390x.txt \
expected-fails-8.2.0-aarch64.txt \
expected-fails-8.2.0-s390x.txt
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Michael Petlan <mpetlan@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: The test rebuilds binutils.src.rpm and runs the suite." >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 3h" >> $(METADATA)
@echo "RunFor: binutils" >> $(METADATA)
@echo "Requires: binutils texinfo glibc-static dejagnu bison flex zlib-static sharutils yum-utils libstdc++-static rpm-build gcc-c++ annobin" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,3 @@
PURPOSE of /tools/binutils/Sanity/testsuite
Description: The test rebuilds binutils.src.rpm and runs the suite.
Author: Michael Petlan <mpetlan@redhat.com>

View File

@ -0,0 +1,25 @@
summary: The test rebuilds binutils.src.rpm and runs the suite.
description: ''
contact: Michael Petlan <mpetlan@redhat.com>
component:
- binutils
test: ./runtest.sh
framework: beakerlib
recommend:
- binutils
- texinfo
- glibc-static
- dejagnu
- bison
- flex
- zlib-static
- sharutils
- yum-utils
- libstdc++-static
- rpm-build
- gcc-c++
- annobin
- koji
duration: 3h
extra-summary: /tools/binutils/Sanity/testsuite
extra-task: /tools/binutils/Sanity/testsuite

146
tests/Sanity/testsuite/runtest.sh Executable file
View File

@ -0,0 +1,146 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/binutils/Sanity/testsuite
#
# Description: The test rebuilds binutils.src.rpm and runs the suite.
# The test is based on /tools/binutils/testsuite, but it had to be
# rewritten.
#
# 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
LD="${LD:-$(which ld)}"
GCC="${GCC:-$(which gcc)}"
BUILT_BY="${BUILT_BY:-$(which built-by)}"
PACKAGE="${PACKAGE:-$(rpm --qf '%{name}\n' -qf $(which $LD) | head -1)}"
GCC_PACKAGE="${GCC_PACKAGE:-$(rpm --qf '%{name}\n' -qf $(which $GCC) | head -1)}"
ANNOBIN_PACKAGE="${ANNOBIN_PACKAGE:-$(rpm --qf '%{name}\n' -qf $(which $BUILT_BY) | head -1)}"
PACKAGES="${PACKAGES:-$PACKAGE}"
REQUIRES="${REQUIRES:-$GCC_PACKAGE $ANNOBIN_PACKAGE}"
rlJournalStart
rlPhaseStartSetup
rlLogInfo "PACKAGES=$PACKAGES"
rlLogInfo "REQUIRES=$REQUIRES"
rlLogInfo "COLLECTIONS=$COLLECTIONS"
rlLogInfo "PACKAGE=$PACKAGE"
rlLogInfo "LD=$LD"
rlLogInfo "GCC=$GCC"
rlLogInfo "SKIP_COLLECTION_METAPACKAGE_CHECK=$SKIP_COLLECTION_METAPACKAGE_CHECK"
# We optionally need to skip checking for the presence of the metapackage
# because that would pull in all the dependent toolset subrpms. We do not
# always want that, especially in CI.
_COLLECTIONS="$COLLECTIONS"
if ! test -z $SKIP_COLLECTION_METAPACKAGE_CHECK; then
for c in $SKIP_COLLECTION_METAPACKAGE_CHECK; do
rlLogInfo "ignoring metapackage check for collection $c"
export COLLECTIONS=$(shopt -s extglob && echo ${COLLECTIONS//$c/})
done
fi
rlLogInfo "(without skipped) COLLECTIONS=$COLLECTIONS"
rlAssertRpm --all
export COLLECTIONS="$_COLLECTIONS"
# temp dir
rlRun "TESTDIR=$PWD"
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "mkdir LOGS"
rlRun "LOGDIR=$TmpDir/LOGS"
# fetch'n'build the source
rlRun "koji download-build --arch=src $(rpm -q binutils)"
rlRun "dnf builddep -y *.src.rpm"
rlRun "rpm -i *.src.rpm"
export SPECDIR=`rpm --eval=%_specdir`
export BUILDDIR=`rpm --eval=%_builddir`
export CURRENT_BUILD=${BUILDDIR}/binutils-`rpmquery $PACKAGE --queryformat=%{VERSION}`
rlRun "rpmbuild -bc $SPECDIR/binutils.spec"
rlRun "cp $CURRENT_BUILD/binutils/binutils.log $CURRENT_BUILD/binutils/binutils.sum $LOGDIR/"
rlRun "cp $CURRENT_BUILD/ld/ld.log $CURRENT_BUILD/ld/ld.sum $LOGDIR/"
rlRun "cp $CURRENT_BUILD/gas/testsuite/gas.log $CURRENT_BUILD/gas/testsuite/gas.sum $LOGDIR/"
rlPhaseEnd
if [ "$(arch)" = "x86_64" ]; then
rlPhaseStartTest Regression-bz1614908
rlLogInfo "Checking if bz#1614908 is reproducible"
rlRun "gold_test_binary=$(find $CURRENT_BUILD -iname gnu_property_test -type f -executable)" 0 "Looking for binary from gold testsuite"
rlAssertExists $gold_test_binary
rlAssertEquals 'Just one .note.gnu.property section' "$(readelf --wide --sections $gold_test_binary | grep -c -F .note.gnu.property)" 1
rlAssertEquals 'The .note.gnu.property section is aligned to 8' "$(readelf --wide --sections $gold_test_binary | awk '/\.note\.gnu\.property/ {print $NF}')" 8
rlAssertEquals 'First NOTE segment is aligned to 8' "$(readelf --wide --segments $gold_test_binary | awk '/NOTE/ {print $NF; exit}')" '0x8'
rlPhaseEnd
fi
for TOOL in binutils ld gas; do
rlPhaseStartTest "$TOOL"
rlLogInfo "$TOOL Summary"
rlLogInfo "$(grep -A 50 '=== .* Summary ===' $LOGDIR/$TOOL.sum)"
# Store list of failed test cases
rlRun "egrep '^FAIL: ' $LOGDIR/$TOOL.sum |& sort | tee $LOGDIR/$TOOL.failed" 0,1
rlRun "grep '# of unexpected failures' $LOGDIR/$TOOL.sum" 0,1 "Checking number of unexpected failures"
# Handle expected failures
if [ "$?" = "0" ]; then
expected_fails_file="" # here we define expected failures if needed
if [ "$expected_fails_file" = "" ]; then
rlFail "No list of expected failures exists for this environment: release=$(cat /etc/redhat-release), arch=$(arch), tool=$TOOL"
rlFail "Unexpected failures found"
else
rlRun "diff $expected_fails_file $LOGDIR/$TOOL.failed" 0,1
if [ "$?" != "0" ]; then
rlFail "Unexpected failures found"
else
rlPass "No unexpected failures found"
fi
fi
else
rlPass "No unexpected failures found"
fi
rlPhaseEnd
done
rlPhaseStartCleanup
rlRun "tar czf $TmpDir/logs.tgz $LOGDIR/*.sum $LOGDIR/*.log"
rlRun "tar czf $TmpDir/buildroot.tgz $CURRENT_BUILD/"
rlFileSubmit logs.tar.gz
rlFileSubmit buildroot.tgz
rlRun "popd" # $TmpDir
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd