|
|
bc88b57 |
#!/bin/bash
|
|
|
bc88b57 |
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
|
bc88b57 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# runtest.sh of /CoreOS/openscap/Sanity/smoke-test
|
|
|
bc88b57 |
# Description: Test runs upstream test suite.
|
|
|
bc88b57 |
# Author: Ondrej Moris <omoris@redhat.com>
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# This copyrighted material is made available to anyone wishing
|
|
|
bc88b57 |
# to use, modify, copy, or redistribute it subject to the terms
|
|
|
bc88b57 |
# and conditions of the GNU General Public License version 2.
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# This program is distributed in the hope that it will be
|
|
|
bc88b57 |
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
bc88b57 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
bc88b57 |
# PURPOSE. See the GNU General Public License for more details.
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# You should have received a copy of the GNU General Public
|
|
|
bc88b57 |
# License along with this program; if not, write to the Free
|
|
|
bc88b57 |
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
bc88b57 |
# Boston, MA 02110-1301, USA.
|
|
|
bc88b57 |
#
|
|
|
bc88b57 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
bc88b57 |
|
|
|
bc88b57 |
. /usr/lib/beakerlib/beakerlib.sh
|
|
|
bc88b57 |
|
|
|
bc88b57 |
PACKAGE="openscap"
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlJournalStart
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlPhaseStartSetup
|
|
|
bc88b57 |
rlImport --all || rlDie "Failed to import libraries"
|
|
|
bc88b57 |
rlAssertRpm "$PACKAGE"
|
|
|
bc88b57 |
|
|
|
bc88b57 |
RpmSnapshotCreate
|
|
|
bc88b57 |
CleanupRegister "RpmSnapshotRevert"
|
|
|
bc88b57 |
rlRun "TmpDir=\$(mktemp -d)" 0
|
|
|
bc88b57 |
CleanupRegister "rlRun 'rm -r $TmpDir' 0 'Removing tmp directory'"
|
|
|
bc88b57 |
rlRun "cp fix_hugepages_err.patch $TmpDir"
|
|
|
bc88b57 |
rlRun "pushd $TmpDir"
|
|
|
bc88b57 |
CleanupRegister "rlRun 'popd'"
|
|
|
bc88b57 |
rlServiceStart sendmail
|
|
|
bc88b57 |
CleanupRegister "rlRun 'rlServiceRestore sendmail'"
|
|
|
bc88b57 |
|
|
|
bc88b57 |
if rlIsRHEL 7; then
|
|
|
bc88b57 |
rlLog "Build system is using the latest version of python, therefore"
|
|
|
bc88b57 |
rlLog "python3 packages must not be present on the machine to make"
|
|
|
bc88b57 |
rlLog "sure that the build system configures with python2."
|
|
|
bc88b57 |
rlRun "yum remove -y python3*" 0 "python3 packages must not be installed"
|
|
|
bc88b57 |
elif rlIsRHEL ">=8"; then
|
|
|
bc88b57 |
rlFileBackup "/etc/yum.repos.d/"
|
|
|
bc88b57 |
CleanupRegister "rlFileRestore"
|
|
|
bc88b57 |
# we have to enable buildroot repo
|
|
|
bc88b57 |
rlRun "dnf config-manager --set-enabled rhel-buildroot{,-debuginfo,-source}" 0-255
|
|
|
bc88b57 |
# Some packages needed to build openscap moved from rhel-buildroot to rhel-CRB
|
|
|
bc88b57 |
rlRun "dnf config-manager --set-enabled rhel-CRB{,-debuginfo,-source}" 0-255
|
|
|
bc88b57 |
rlRun "dnf config-manager --set-enabled beaker-CRB{,-debuginfo,-source}" 0-255
|
|
|
bc88b57 |
# AppStream source repo is not enabled by default
|
|
|
bc88b57 |
rlRun "dnf config-manager --set-enabled beaker-AppStream-source" 0-255
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlFetchSrcForInstalled $PACKAGE
|
|
|
bc88b57 |
if rlIsFedora || rlIsRHEL ">=8"; then
|
|
|
14d490c |
rlRun "dnf builddep -y $PACKAGE*"
|
|
|
bc88b57 |
else
|
|
|
bc88b57 |
rlRun "yum-builddep -y $PACKAGE*"
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
TOPDIR=`rpm --eval %_topdir`
|
|
|
bc88b57 |
rlRun "rm -rf ${TOPDIR}/BUILD/${PACKAGE}*" 0-255
|
|
|
bc88b57 |
rlRun "rpm -ihv `ls *.rpm`" 0 "Install $PACKAGE source RPM"
|
|
|
bc88b57 |
rlPhaseEnd
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlPhaseStartSetup "Prepare upstream test suite (%prep and %build stages from the spec file)"
|
|
|
bc88b57 |
rlRun "rpmbuild -v -bc ${TOPDIR}/SPECS/${PACKAGE}.spec"
|
|
|
bc88b57 |
CleanupRegister "rlRun 'rm -rf ${TOPDIR}/BUILD/${PACKAGE}*'"
|
|
|
bc88b57 |
CleanupRegister "rlRun 'rm -rf ${TOPDIR}/SPECS/${PACKAGE}*'"
|
|
|
bc88b57 |
CleanupRegister "rlRun 'rm -rf ${TOPDIR}/SOURCES/*'"
|
|
|
bc88b57 |
if rlIsRHEL 7; then
|
|
|
bc88b57 |
rlLogInfo "Waive the known issue with hugepages on ppc64/ppc64le"
|
|
|
bc88b57 |
rlLogInfo "platforms which won't be fixed in RHEL7:"
|
|
|
bc88b57 |
rlLogInfo "https://bugzilla.redhat.com/show_bug.cgi?id=1607382"
|
|
|
bc88b57 |
TEST_CWD=$(pwd)
|
|
|
bc88b57 |
TREE_CWD=$(readlink -f ${TOPDIR}/BUILD/${PACKAGE}*)
|
|
|
bc88b57 |
rlRun "cp fix_hugepages_err.patch $TREE_CWD"
|
|
|
bc88b57 |
rlRun "cd $TREE_CWD"
|
|
|
bc88b57 |
rlRun "patch -p1 < fix_hugepages_err.patch"
|
|
|
bc88b57 |
rlRun "cd $TEST_CWD" 0 "Restore test default working directory"
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
rlPhaseEnd
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlPhaseStartTest "Run upstream test suite against installed $PACKAGE"
|
|
|
bc88b57 |
rlRun "export OSCAP_FULL_VALIDATION=1"
|
|
|
bc88b57 |
rlRun "export CUSTOM_OSCAP=$(which oscap)"
|
|
Milan Lysonek |
cd55c6e |
BUILD_DIR="$(rpm --eval %{_vpath_builddir})"
|
|
|
bc88b57 |
if rlIsFedora || rlIsRHEL ">=8"; then
|
|
Milan Lysonek |
cd55c6e |
rlRun -s "cmake --build $(readlink -f ${TOPDIR}/BUILD/${PACKAGE}*/${BUILD_DIR}) --target test"
|
|
|
bc88b57 |
rv=$?
|
|
|
bc88b57 |
# cmake output does not contain enough information, submit verbose output log
|
|
|
bc88b57 |
FILE="$TOPDIR/BUILD/openscap*/build/Testing/Temporary/LastTest.log"
|
|
|
bc88b57 |
rlFileSubmit $(readlink -f $FILE) test_verbose_output.log
|
|
|
bc88b57 |
else
|
|
|
bc88b57 |
rlRun -s "make -C $(readlink -f ${TOPDIR}/BUILD/${PACKAGE}*) check"
|
|
|
bc88b57 |
rv=$?
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
|
|
|
bc88b57 |
# if we got error, submit file with result of particular test for easier debugging
|
|
|
bc88b57 |
if [ $rv -ne 0 ]; then
|
|
|
bc88b57 |
if rlIsFedora || rlIsRHEL ">=8"; then
|
|
Milan Lysonek |
cd55c6e |
FILE="${TOPDIR}/BUILD/${PACKAGE}*/${BUILD_DIR}/tests"
|
|
|
bc88b57 |
rlBundleLogs test_outputs_all $(readlink -f $FILE)
|
|
|
bc88b57 |
elif grep "See tests/" $rlRun_LOG; then
|
|
|
bc88b57 |
RESULT=`grep "See tests/" $rlRun_LOG | sed -e "s/See tests\(.*\)/tests\1/"`
|
|
|
bc88b57 |
FILE="${TOPDIR}/BUILD/${PACKAGE}*/${RESULT}"
|
|
|
bc88b57 |
cat $(readlink -f $FILE)
|
|
|
bc88b57 |
rlBundleLogs test_outputs $(dirname $FILE)
|
|
|
bc88b57 |
if grep "See tests/" $FILE; then # we need to go deeper ...
|
|
|
bc88b57 |
RESULT=`grep "See tests/" $FILE | sed -e "s/See tests\(.*\)/tests\1/"`
|
|
|
bc88b57 |
FILE="${TOPDIR}/BUILD/${PACKAGE}*/${RESULT}"
|
|
|
bc88b57 |
cat $(readlink -f $FILE)
|
|
|
bc88b57 |
rlBundleLogs test_outputs_deep $(dirname $FILE)
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
fi
|
|
|
bc88b57 |
rlPhaseEnd
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlPhaseStartCleanup
|
|
|
bc88b57 |
CleanupDo
|
|
|
bc88b57 |
rlPhaseEnd
|
|
|
bc88b57 |
|
|
|
bc88b57 |
rlJournalPrintText
|
|
|
bc88b57 |
rlJournalEnd
|