79 lines
3.0 KiB
Bash
79 lines
3.0 KiB
Bash
|
#!/bin/bash
|
||
|
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
#
|
||
|
# runtest.sh of /tools/chan/Sanity/sanity-test
|
||
|
# Description: Sanity upstream test of chan package
|
||
|
# Author: Jan Kuřík <jkurik@redhat.com>
|
||
|
#
|
||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
#
|
||
|
# Copyright (c) 2020 Red Hat, Inc.
|
||
|
#
|
||
|
# This program is free software: you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License as
|
||
|
# published by the Free Software Foundation, either version 2 of
|
||
|
# the License, or (at your option) any later version.
|
||
|
#
|
||
|
# 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, see http://www.gnu.org/licenses/.
|
||
|
#
|
||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
|
||
|
# Include Beaker environment
|
||
|
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||
|
|
||
|
PACKAGE="chan"
|
||
|
BUILD_USER=${BUILD_USER:-chanbld}
|
||
|
|
||
|
rlJournalStart
|
||
|
rlPhaseStartSetup
|
||
|
rlAssertRpm $PACKAGE
|
||
|
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||
|
rlRun "pushd $TmpDir"
|
||
|
rlPhaseEnd
|
||
|
|
||
|
rlPhaseStartTest "Get source code and setup build environment"
|
||
|
rlFetchSrcForInstalled "${PACKAGE}" \
|
||
|
|| rlDie "Can not download SRPM of ${PACKAGE} - giving up"
|
||
|
rlRun "yum-builddep -y \
|
||
|
$(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}.$(arch))" \
|
||
|
|| rlDie "Can not install build dependencies - giving up"
|
||
|
rlRun "useradd -m -N $BUILD_USER" 0,9 && del="yes"
|
||
|
rlPhaseEnd
|
||
|
|
||
|
rlPhaseStartTest "Build ${PACKAGE}"
|
||
|
rlRun "rpm -D \"_topdir ${TmpDir}\" -U \
|
||
|
$(rpm -q --qf '%{name}-%{version}-%{release}.src.rpm' ${PACKAGE}.$(arch))"
|
||
|
rlRun "chown -R ${BUILD_USER}:users ${TmpDir}"
|
||
|
rlRun -s "su -c \
|
||
|
'rpmbuild -D \"_topdir ${TmpDir}\" -bc ${TmpDir}/SPECS/${PACKAGE}.spec' \
|
||
|
${BUILD_USER}"
|
||
|
rlFileSubmit "${rlRun_LOG}" "rpmbuild-${PACKAGE}.log"
|
||
|
rlPhaseEnd
|
||
|
|
||
|
rlPhaseStartTest "Run upstream testsuite"
|
||
|
BDIR=$(rpm -q --qf '%{name}-%{version}' ${PACKAGE}.$(arch))
|
||
|
if rlRun "pushd ${TmpDir}/BUILD/${BDIR}"; then
|
||
|
rlRun "rm -f .libs/libchan.so*"
|
||
|
rlRun "ln -s /usr/lib64/libchan.so.0 .libs/libchan.so"
|
||
|
rlRun "ln -s /usr/lib64/libchan.so.0 .libs/libchan.so.0"
|
||
|
rlRun "make src/chan_test"
|
||
|
rlRun -s "src/chan_test"
|
||
|
rlAssertGrep '[0-9]+ passed' "${rlRun_LOG}" -E
|
||
|
rlRun "popd"
|
||
|
fi
|
||
|
rlPhaseEnd
|
||
|
|
||
|
rlPhaseStartCleanup
|
||
|
rlRun "popd"
|
||
|
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||
|
rlPhaseEnd
|
||
|
rlJournalPrintText
|
||
|
rlJournalEnd
|