cd2f8b7
#!/bin/bash
cd2f8b7
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
cd2f8b7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cd2f8b7
#
cd2f8b7
#   runtest.sh of /tools/dwz/Sanity/dwz-testsuite
cd2f8b7
#   Description: dwz testing by upstream testsuite
cd2f8b7
#   Author: Michal Kolar <mkolar@redhat.com>
cd2f8b7
#
cd2f8b7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cd2f8b7
#
cd2f8b7
#   Copyright (c) 2021 Red Hat, Inc.
cd2f8b7
#
cd2f8b7
#   This program is free software: you can redistribute it and/or
cd2f8b7
#   modify it under the terms of the GNU General Public License as
cd2f8b7
#   published by the Free Software Foundation, either version 2 of
cd2f8b7
#   the License, or (at your option) any later version.
cd2f8b7
#
cd2f8b7
#   This program is distributed in the hope that it will be
cd2f8b7
#   useful, but WITHOUT ANY WARRANTY; without even the implied
cd2f8b7
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
cd2f8b7
#   PURPOSE.  See the GNU General Public License for more details.
cd2f8b7
#
cd2f8b7
#   You should have received a copy of the GNU General Public License
cd2f8b7
#   along with this program. If not, see http://www.gnu.org/licenses/.
cd2f8b7
#
cd2f8b7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cd2f8b7
cd2f8b7
# Include Beaker environment
cd2f8b7
. /usr/share/beakerlib/beakerlib.sh || exit 1
cd2f8b7
cd2f8b7
BUILD_USER=${BUILD_USER:-dwzbld}
cd2f8b7
TESTS_COUNT_MIN=${TESTS_COUNT_MIN:-20}
cd2f8b7
PACKAGE="dwz"
cd2f8b7
REQUIRES="$PACKAGE rpm-build"
cd2f8b7
if rlIsFedora; then
cd2f8b7
  REQUIRES="$REQUIRES dnf-utils"
cd2f8b7
else
cd2f8b7
  REQUIRES="$REQUIRES yum-utils"
cd2f8b7
fi
cd2f8b7
cd2f8b7
rlJournalStart
cd2f8b7
  rlPhaseStartSetup
cd2f8b7
    rlShowRunningKernel
cd2f8b7
    rlAssertRpm --all
cd2f8b7
    rlRun "TmpDir=`mktemp -d`"
cd2f8b7
    rlRun "pushd $TmpDir"
cd2f8b7
    rlFetchSrcForInstalled $PACKAGE
cd2f8b7
    rlRun "useradd -M -N $BUILD_USER" 0,9
cd2f8b7
    [ "$?" == "0" ] && rlRun "del=yes"
cd2f8b7
    rlRun "chown -R $BUILD_USER:users $TmpDir"
cd2f8b7
  rlPhaseEnd
cd2f8b7
cd2f8b7
  rlPhaseStartSetup "build dwz"
cd2f8b7
    rlRun "rpm -D \"_topdir $TmpDir\" -U *.src.rpm"
cd2f8b7
    rlRun "dnf builddep -y $TmpDir/SPECS/*.spec"
cd2f8b7
    rlRun "su -c 'rpmbuild -D \"_topdir $TmpDir\" -bp $TmpDir/SPECS/*.spec &>$TmpDir/rpmbuild.log' $BUILD_USER"
cd2f8b7
    rlRun "rlFileSubmit $TmpDir/rpmbuild.log"
cd2f8b7
    rlRun "cd $TmpDir/BUILD/dwz"
cd2f8b7
    rlRun "su -c './configure &>$TmpDir/configure.log' $BUILD_USER"
cd2f8b7
    rlRun "rlFileSubmit $TmpDir/configure.log"
cd2f8b7
    rlRun "su -c 'make &>$TmpDir/make.log' $BUILD_USER"
cd2f8b7
    rlRun "rlFileSubmit $TmpDir/make.log"
cd2f8b7
    rlRun "ln -fs `which dwz` . && touch dwz"
cd2f8b7
cd2f8b7
    # workaround
cd2f8b7
    [ -f testsuite/dwz.tests/pr24468.sh ] && rlRun "mv testsuite/dwz.tests/pr24468.sh testsuite/dwz.tests/pr24468.sh~" 0 "Disabling pr24468.sh due to bz1893921"
cd2f8b7
  rlPhaseEnd
cd2f8b7
cd2f8b7
  rlPhaseStartTest "run testsuite"
cd2f8b7
    rlRun "su -c 'make check RUNTESTFLAGS=-a |& tee $TmpDir/testsuite.log; test \${PIPESTATUS[0]} -eq 0' $BUILD_USER"
cd2f8b7
    rlRun "rlFileSubmit $TmpDir/testsuite.log"
cd2f8b7
    rlLogInfo "`awk '/=== dwz Summary ===/,0' dwz.sum`"
cd2f8b7
  rlPhaseEnd
cd2f8b7
cd2f8b7
  rlPhaseStartTest "evaluate results"
cd2f8b7
    rlRun "grep -E '^FAIL:' dwz.sum" 1 "There should be no failure"
cd2f8b7
    rlRun "tests_count=\$(grep -E '^PASS:' dwz.sum | wc -l)"
cd2f8b7
    [ "$tests_count" -ge "$TESTS_COUNT_MIN" ] && rlLogInfo "Test counter: $tests_count" || rlFail "Test counter $tests_count should be greater than or equal to $TESTS_COUNT_MIN"
cd2f8b7
  rlPhaseEnd
cd2f8b7
cd2f8b7
  rlPhaseStartCleanup
cd2f8b7
    rlRun "popd"
cd2f8b7
    rlRun "rm -r $TmpDir"
cd2f8b7
    [ "$del" == "yes" ] && rlRun "userdel -f $BUILD_USER"
cd2f8b7
  rlPhaseEnd
cd2f8b7
rlJournalPrintText
cd2f8b7
rlJournalEnd