Blame Sanity/oscap-builds-ssg/runtest.sh

445a9a4
#!/bin/bash
445a9a4
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
445a9a4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445a9a4
#
445a9a4
#   runtest.sh of /tools/openscap/Sanity/oscap-builds-ssg
445a9a4
#   Description: Checks that scap-security-guide can be built by the tested oscap.
445a9a4
#   Author: Matej Tyc <matyc@redhat.com>
445a9a4
#
445a9a4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445a9a4
#
445a9a4
#   Copyright (c) 2018 Red Hat, Inc.
445a9a4
#
445a9a4
#   This program is free software: you can redistribute it and/or
445a9a4
#   modify it under the terms of the GNU General Public License as
445a9a4
#   published by the Free Software Foundation, either version 2 of
445a9a4
#   the License, or (at your option) any later version.
445a9a4
#
445a9a4
#   This program is distributed in the hope that it will be
445a9a4
#   useful, but WITHOUT ANY WARRANTY; without even the implied
445a9a4
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
445a9a4
#   PURPOSE.  See the GNU General Public License for more details.
445a9a4
#
445a9a4
#   You should have received a copy of the GNU General Public License
445a9a4
#   along with this program. If not, see http://www.gnu.org/licenses/.
445a9a4
#
445a9a4
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
445a9a4
445a9a4
# Include Beaker environment
445a9a4
. /usr/bin/rhts-environment.sh || exit 1
445a9a4
. /usr/share/beakerlib/beakerlib.sh || exit 1
445a9a4
445a9a4
PACKAGE="openscap-utils"
445a9a4
ed19e9f
ssgname="content"
445a9a4
445a9a4
rlJournalStart
445a9a4
    rlPhaseStartSetup
445a9a4
        rlAssertRpm $PACKAGE
ed19e9f
        rlRun "git clone https://github.com/ComplianceAsCode/${ssgname}" 0 "Cloning SSG source"
ed19e9f
        rlRun "pushd $ssgname"
ed19e9f
        # Get tag of the latest release.
ed19e9f
        ssgtag=$(git tag -l | grep "v0\.1\.[0-9]\+" | sort | tail -n1)
445a9a4
        rlRun "git checkout $ssgtag" 0 "Check out to the latest released version."
445a9a4
        rlRun "mkdir -p build" 0 "Ensuring that build dir exists"
445a9a4
        rlRun "pushd build"
445a9a4
        rlRun "rm -rf * && cmake .. && make" 0 "Get rid of everything and build ssg from scratch."
445a9a4
    rlPhaseEnd
445a9a4
445a9a4
    rlPhaseStartTest
ed19e9f
        rlRun "ctest --output-on-failure" 0 "Checking that the freshly built SSG is OK"
445a9a4
    rlPhaseEnd
445a9a4
445a9a4
    rlPhaseStartCleanup
445a9a4
        rlRun "popd"
445a9a4
        rlRun "popd"
445a9a4
        rlRun "rm -rf $ssgname" 0 "Removing the whole SSG tree."
445a9a4
    rlPhaseEnd
445a9a4
rlJournalPrintText
445a9a4
rlJournalEnd