#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/scap-workbench/Sanity/cmdline
# Description: Performs check of command line arguments
# Author: Marek Haicman <mhaicman@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2017 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# update
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="scap-workbench"
rlJournalStart
rlPhaseStartSetup
rlImport --all || rlDie "Failed to import libraries"
rlAssertRpm $PACKAGE
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
CleanupRegister "rlRun 'rm -r $TmpDir' 0 'Removing tmp directory'"
rlRun "pushd $TmpDir"
CleanupRegister "rlRun 'popd'"
VERSION_STRING=$(rpm -q --queryformat '%{VERSION}' scap-workbench)
rlPhaseEnd
rlPhaseStartTest "Test version"
rlRun "rlWatchdog \"xvfb-run scap-workbench --version > output\" 20"
rlAssertGrep "SCAP Workbench $VERSION_STRING" output || cat output
if rlIsRHEL ">=8" || rlIsFedora; then
VERSION_SHORT_OPTION="-v"
else
VERSION_SHORT_OPTION="-V"
fi
rlRun "rlWatchdog \"xvfb-run scap-workbench ${VERSION_SHORT_OPTION} > output\" 20"
rlAssertGrep "SCAP Workbench $VERSION_STRING" output || cat output
rlPhaseEnd
rlPhaseStartTest "Test help"
rlRun "rlWatchdog \"xvfb-run scap-workbench --help > output\" 20"
rlAssertGrep "Usage: \(\./\)\?scap-workbench" output || cat output
rlRun "rlWatchdog \"xvfb-run scap-workbench -h > output\" 20"
rlAssertGrep "Usage: \(\./\)\?scap-workbench" output || cat output
rlPhaseEnd
rlPhaseStartCleanup
CleanupDo
rlPhaseEnd
rlJournalPrintText
rlJournalEnd