|
|
7f89380 |
#!/bin/bash
|
|
|
7f89380 |
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
|
7f89380 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# runtest.sh of /CoreOS/bash/Sanity/smoke
|
|
|
7f89380 |
# Description: Basic sanity smoke test
|
|
|
7f89380 |
# Author: Miroslav Hradilek <mhradile@redhat.com>
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# Copyright (c) 2012 Red Hat, Inc.
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# This program is free software: you can redistribute it and/or
|
|
|
7f89380 |
# modify it under the terms of the GNU General Public License as
|
|
|
7f89380 |
# published by the Free Software Foundation, either version 2 of
|
|
|
7f89380 |
# the License, or (at your option) any later version.
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# This program is distributed in the hope that it will be
|
|
|
7f89380 |
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
7f89380 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
7f89380 |
# PURPOSE. See the GNU General Public License for more details.
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# You should have received a copy of the GNU General Public License
|
|
|
7f89380 |
# along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
7f89380 |
#
|
|
|
7f89380 |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
7f89380 |
|
|
|
7f89380 |
# Include Beaker environment
|
|
|
7f89380 |
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
|
|
7f89380 |
|
|
|
7f89380 |
PACKAGES=${PACKAGES:-"bash"}
|
|
|
7f89380 |
SH_BIN=${SH_BIN:-"bash"}
|
|
|
7f89380 |
|
|
|
7f89380 |
rlJournalStart
|
|
|
7f89380 |
rlPhaseStartSetup
|
|
|
7f89380 |
rlAssertRpm --all
|
|
|
7f89380 |
rlAssertBinaryOrigin $SH_BIN
|
|
|
7f89380 |
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
|
|
7f89380 |
rlRun "cp t_* $TmpDir/." 0 "Copying additional test files"
|
|
|
7f89380 |
rlRun "pushd $TmpDir"
|
|
|
7f89380 |
rlPhaseEnd
|
|
|
7f89380 |
|
|
|
7f89380 |
rlPhaseStartTest
|
|
|
7f89380 |
rlLog "Commandline options"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'echo OK' | grep OK" 0 "Testing -c option"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "Assorted tests"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'echo \`echo OK\`' | grep OK" 0 "Testing command substitution"
|
|
|
7f89380 |
[ "$SH_BIN" == "bash" ] && EXTRAPARAM="-i"
|
|
|
7f89380 |
rlRun "$SH_BIN $EXTRAPARAM t_alias | grep OK" 0 "Testing alias"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'echo \$((1+1))' | grep 2" 0 "Arithmetic expansion"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'writedown(){ echo \$1; }; writedown OK' | grep OK" 0 "Testing function"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "Variables"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'testvar1=\"OK\"; echo \"\$testvar1\"' | grep OK" 0 "Testing variable assignment"
|
|
|
7f89380 |
rlRun "$SH_BIN t_variables | grep 'default,OK'" 0 "Testing variable substitution"
|
|
|
7f89380 |
rlRun "$SH_BIN -c \"cat nonexistent; echo \$?\" | grep 1" 0 "Testing predefined variable \$?"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "File expansion"
|
|
|
7f89380 |
rlRun "touch testfile" 0 "Creating test file"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'echo test*' | grep testfile" 0 "Testing expansion to the test file name"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "Builtins"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'test -e testfile'" 0 "Testing test builtin"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "Redirection and pipeline"
|
|
|
7f89380 |
rlRun "$SH_BIN -c \"echo 'aBc' | grep B >redirection_out\"" 0 "Testing pipeline"
|
|
|
7f89380 |
rlRun "grep 'aBc' redirection_out" 0 "Testing redirection"
|
|
|
7f89380 |
|
|
|
7f89380 |
rlLog "Control structures"
|
|
|
7f89380 |
rlRun "$SH_BIN -c 'for i in 1 2 3; do echo -n \$i; done' | grep 123" 0 "Testing cycle for"
|
|
|
7f89380 |
rlRun "$SH_BIN t_conditionals | grep 'operator,if,else,test'" 0 "Testing if and it's && operator shorthand"
|
|
|
7f89380 |
rlPhaseEnd
|
|
|
7f89380 |
|
|
|
7f89380 |
rlPhaseStartCleanup
|
|
|
7f89380 |
rlRun "popd"
|
|
|
7f89380 |
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
|
|
7f89380 |
rlPhaseEnd
|
|
|
7f89380 |
rlJournalPrintText
|
|
|
7f89380 |
rlJournalEnd
|