Add tests from the upstream first repo
Adding an initial set of tests from the upstream first repository: https://upstreamfirst.fedorainfracloud.org/bash
This commit is contained in:
parent
22e040981f
commit
7f89380569
15 changed files with 584 additions and 0 deletions
64
func/Makefile
Normal file
64
func/Makefile
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# Makefile
|
||||
# Author: Jan Scotka <jscotka@redhat.com>
|
||||
# Location:
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2008 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/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
TOPLEVEL_NAMESPACE=/CoreOS
|
||||
PACKAGE_NAME=bash
|
||||
RELATIVE_PATH=sanity/func
|
||||
|
||||
export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
chmod a+x ./runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
|
||||
$(METADATA): Makefile
|
||||
@touch $(METADATA)
|
||||
@echo "Owner: Jan Scotka <jscotka@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Description: Try shell basic functionality" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 2h" >> $(METADATA)
|
||||
@echo "RunFor: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "Requires: $(PACKAGE_NAME)" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
||||
1
func/PURPOSE
Normal file
1
func/PURPOSE
Normal file
|
|
@ -0,0 +1 @@
|
|||
Basic test of functions in Bourne-Again SHell, testing purpose for Test Container Project
|
||||
65
func/runtest.sh
Normal file
65
func/runtest.sh
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2008 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 rhts and rhtslib environment
|
||||
. /usr/bin/rhts-environment.sh
|
||||
. /usr/share/beakerlib/beakerlib.sh
|
||||
|
||||
PACKAGES=${PACKAGES:-bash}
|
||||
SH_BIN=${SH_BIN:-bash}
|
||||
|
||||
rlJournalStart
|
||||
|
||||
rlPhaseStartSetup "Init phase"
|
||||
rlAssertRpm --all
|
||||
if [ $SH_BIN == "zsh" ]; then
|
||||
ZSH_OPT="-i"
|
||||
else
|
||||
ZSH_OPT=""
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
|
||||
rlPhaseStartTest "Test of functions"
|
||||
rlRun "${SH_BIN} -c pwd" 0 "Checking if ${SH_BIN} do pwd command"
|
||||
rlRun "${SH_BIN} -c unexistcommand3241" 127 "Checking if ${SH_BIN} return 127 if command doesnt exist"
|
||||
rm /tmp/unexistfile &>/dev/null
|
||||
rlRun "${SH_BIN} -c 'ls /tmp/unexistfile'" 2 "Checking if ${SH_BIN} return 2 if none file"
|
||||
rlRun "${SH_BIN} -c 'echo aba| sed s/a/b/g |grep -q bbb'" 0 "Checking pipes"
|
||||
TT=`mktemp`
|
||||
TEXT=sometihngverylong
|
||||
rlRun "${SH_BIN} -c 'echo $TEXT > $TT; cat $TT |grep -q $TEXT'" 0 "Checking redirecting to file"
|
||||
rlRun " ${SH_BIN} -c 'let a=1+1;echo \$a|grep -q 2'" 0 "Checking 'let' arithmetic operation 1+1"
|
||||
# rlRun "${SH_BIN} -c 'sleep 100&; WC=\`jobs|wc -l\`; [[ \$WC -ge 1 ]]'" 0 "Checking process at background is running"
|
||||
rlRun "${SH_BIN} $ZSH_OPT -c 'sleep 100& WC=\$(jobs|wc -l) ; [[ \$WC -ge 1 ]]'" 0 "Checking process at background is running"
|
||||
|
||||
USER=${SH_BIN}user
|
||||
rlRun "adduser -s /bin/${SH_BIN} $USER" 0,9 "Created user with ${SH_BIN} as default shell"
|
||||
rlRun "su -l $USER -c 'echo \$PATH'" 0 "Logged as previous created user and run echo PATH"
|
||||
rlPhaseEnd
|
||||
|
||||
# cleanup
|
||||
rlPhaseStartCleanup "Cleaning up"
|
||||
rlRun "true" 0 "True action"
|
||||
rlRun "rm $TT" 0 "Checking delete of $TT"
|
||||
sleep 10
|
||||
rlRun "userdel $USER" 0 "Deleted user with ${SH_BIN} as default shell"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
66
login/Makefile
Normal file
66
login/Makefile
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/bash/Sanity/login-shell
|
||||
# Description: the test creates user with bash as login shell and verified the user can log in and get th
|
||||
# Author: Martin Kyral <mkyral@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2016 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/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/bash/Sanity/login-shell
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE script.exp ssh.exp tst.sh
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
test -x runtest.sh || chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Martin Kyral <mkyral@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: the test creates user with bash as login shell and verified the user can log in and get th" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: ksh zsh bash dash mksh pdksh" >> $(METADATA)
|
||||
@echo "Requires: bash" >> $(METADATA)
|
||||
@echo "Requires: expect" >> $(METADATA)
|
||||
@echo "Requires: procps-ng" >> $(METADATA)
|
||||
@echo "Requires: passwd" >> $(METADATA)
|
||||
@echo "Requires: openssh-clients openssh-server" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2+" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
||||
3
login/PURPOSE
Normal file
3
login/PURPOSE
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PURPOSE of /CoreOS/bash/Sanity/login-shell
|
||||
Description: the test creates user with bash as login shell and verified the user can log in and get th
|
||||
Author: Your Name <mkyral@redhat.com>
|
||||
94
login/runtest.sh
Normal file
94
login/runtest.sh
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#!/bin/bash
|
||||
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/bash/Sanity/login-shell
|
||||
# Description: the test creates user with bash as login shell and verified the user can log in and get th
|
||||
# Author: Martin Kyral <mkyral@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2016 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/bin/rhts-environment.sh || exit 1
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGES=${PACKAGES:-"bash"}
|
||||
SH_BIN=${SH_BIN:-"bash"}
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm --all
|
||||
rlAssertBinaryOrigin $SH_BIN
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "cp script.exp ssh.exp tst.sh $TmpDir"
|
||||
rlRun "pushd $TmpDir"
|
||||
#USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||
USER="user${RANDOM}"
|
||||
rlRun "useradd -s /bin/${SH_BIN} -d /home/${USER} ${USER}"
|
||||
rlRun "echo krava | passwd --stdin ${USER}"
|
||||
rlRun "sed -i 's/shelluser/${USER}/g' script.exp"
|
||||
rlRun "sed -i 's/shelluser/${USER}/g' ssh.exp"
|
||||
rlRun "sed -i 's/shelluser/${USER}/g' tst.sh"
|
||||
rlRun "sed -i 's/shellbin/${SH_BIN}/g' script.exp"
|
||||
rlRun "sed -i 's/shellbin/${SH_BIN}/g' ssh.exp"
|
||||
rlRun "sed -i 's/shellbin/${SH_BIN}/g' tst.sh"
|
||||
rlRun "cp tst.sh /home/${USER}/"
|
||||
rlRun "chown ${USER} /home/${USER}/tst.sh"
|
||||
rlRun "mv /etc/profile.d/tps-cd.sh /root/tps-cd.sh" 0,1 "Backing tps-cd.sh up"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "::::: 'su -c' test :::::"
|
||||
rlRun "su ${USER} -c 'echo something' | tee test1.log" 0 "echo something test"
|
||||
rlLog "test1.log: $(cat test1.log)"
|
||||
rlAssertGrep "something" "test1.log"
|
||||
rlRun "su ${USER} -c 'echo \$0 | tee /home/${USER}/ps1.log'" 0 "shell detection test"
|
||||
rlLog "ps1.log: $(cat /home/${USER}/ps1.log)"
|
||||
rlAssertGrep "$SH_BIN" "/home/${USER}/ps1.log"
|
||||
# the following does not work with pdksh for some reason
|
||||
# not a big deal, ssh test can substitute this
|
||||
[ "$SH_BIN" != "pdksh" ] && {
|
||||
rlLog "::::: 'su -l' test :::::"
|
||||
expect script.exp &
|
||||
sleep 20
|
||||
pgrep expect && pkill expect
|
||||
rlLog "test2.log: $(cat /home/${USER}/test2.log)"
|
||||
rlAssertGrep "something" "/home/${USER}/test2.log"
|
||||
rlLog "ps2.log: $(cat /home/${USER}/ps2.log)"
|
||||
rlAssertGrep "$SH_BIN" "/home/${USER}/ps2.log"
|
||||
}
|
||||
rlLog "::::: ssh login test :::::"
|
||||
expect ssh.exp &
|
||||
sleep 20
|
||||
pgrep expect && pkill expect
|
||||
rlLog "ps3.log: $(cat /home/${USER}/ps3.log)"
|
||||
rlAssertGrep "$SH_BIN" "/home/${USER}/ps3.log"
|
||||
rlAssertExists "/home/${USER}/tst.dat"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "mv /root/tps-cd.sh /etc/profile.d/tps-cd.sh" 0,1 "Restoring tps-cd.sh"
|
||||
rlRun "su -c 'kill -9 -1' ${USER}" 0 "Killing all processes of ${USER}"
|
||||
rlRun "userdel -r ${USER}"
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
57
login/script.exp
Normal file
57
login/script.exp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/expect -f
|
||||
#
|
||||
# This Expect script was generated by autoexpect on Wed Jan 13 12:41:15 2016
|
||||
# Expect and autoexpect were both written by Don Libes, NIST.
|
||||
#
|
||||
# Note that autoexpect does not guarantee a working script. It
|
||||
# necessarily has to guess about certain things. Two reasons a script
|
||||
# might fail are:
|
||||
#
|
||||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
|
||||
# etc.) and devices discard or ignore keystrokes that arrive "too
|
||||
# quickly" after prompts. If you find your new script hanging up at
|
||||
# one spot, try adding a short sleep just before the previous send.
|
||||
# Setting "force_conservative" to 1 (see below) makes Expect do this
|
||||
# automatically - pausing briefly before sending each character. This
|
||||
# pacifies every program I know of. The -c flag makes the script do
|
||||
# this in the first place. The -C flag allows you to define a
|
||||
# character to toggle this mode off and on.
|
||||
|
||||
set force_conservative 0 ;# set to 1 to force conservative mode even if
|
||||
;# script wasn't run conservatively originally
|
||||
if {$force_conservative} {
|
||||
set send_slow {1 .1}
|
||||
proc send {ignore arg} {
|
||||
sleep .1
|
||||
exp_send -s -- $arg
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# 2) differing output - Some programs produce different output each time
|
||||
# they run. The "date" command is an obvious example. Another is
|
||||
# ftp, if it produces throughput statistics at the end of a file
|
||||
# transfer. If this causes a problem, delete these patterns or replace
|
||||
# them with wildcards. An alternative is to use the -p flag (for
|
||||
# "prompt") which makes Expect only look for the last line of output
|
||||
# (i.e., the prompt). The -P flag allows you to define a character to
|
||||
# toggle this mode off and on.
|
||||
#
|
||||
# Read the man page for more info.
|
||||
#
|
||||
# -Don
|
||||
|
||||
|
||||
set timeout -1
|
||||
spawn "/bin/shellbin"
|
||||
match_max 100000
|
||||
send -- "su -l shelluser\r"
|
||||
sleep 3
|
||||
send -- "cd\r"
|
||||
send -- "echo something\r"
|
||||
send -- "echo something > test2.log\r"
|
||||
send -- "pwd\r"
|
||||
send -- "echo \$0 | tee ps2.log\r"
|
||||
send -- "exit\r"
|
||||
send -- "exit\r"
|
||||
expect eof
|
||||
67
login/ssh.exp
Normal file
67
login/ssh.exp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/expect -f
|
||||
#
|
||||
# This Expect script was generated by autoexpect on Mon Jan 18 05:25:00 2016
|
||||
# Expect and autoexpect were both written by Don Libes, NIST.
|
||||
#
|
||||
# Note that autoexpect does not guarantee a working script. It
|
||||
# necessarily has to guess about certain things. Two reasons a script
|
||||
# might fail are:
|
||||
#
|
||||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
|
||||
# etc.) and devices discard or ignore keystrokes that arrive "too
|
||||
# quickly" after prompts. If you find your new script hanging up at
|
||||
# one spot, try adding a short sleep just before the previous send.
|
||||
# Setting "force_conservative" to 1 (see below) makes Expect do this
|
||||
# automatically - pausing briefly before sending each character. This
|
||||
# pacifies every program I know of. The -c flag makes the script do
|
||||
# this in the first place. The -C flag allows you to define a
|
||||
# character to toggle this mode off and on.
|
||||
|
||||
set force_conservative 0 ;# set to 1 to force conservative mode even if
|
||||
;# script wasn't run conservatively originally
|
||||
if {$force_conservative} {
|
||||
set send_slow {1 .1}
|
||||
proc send {ignore arg} {
|
||||
sleep .1
|
||||
exp_send -s -- $arg
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# 2) differing output - Some programs produce different output each time
|
||||
# they run. The "date" command is an obvious example. Another is
|
||||
# ftp, if it produces throughput statistics at the end of a file
|
||||
# transfer. If this causes a problem, delete these patterns or replace
|
||||
# them with wildcards. An alternative is to use the -p flag (for
|
||||
# "prompt") which makes Expect only look for the last line of output
|
||||
# (i.e., the prompt). The -P flag allows you to define a character to
|
||||
# toggle this mode off and on.
|
||||
#
|
||||
# Read the man page for more info.
|
||||
#
|
||||
# -Don
|
||||
|
||||
set timeout -1
|
||||
spawn "/bin/shellbin"
|
||||
match_max 100000
|
||||
expect "# "
|
||||
send -- "ssh -o 'StrictHostKeyChecking no' shelluser@localhost\r"
|
||||
expect "password: "
|
||||
send -- "krava\r"
|
||||
sleep 1
|
||||
send -- "echo \$0 | tee ps3.log\r"
|
||||
send -- "\r"
|
||||
send -- "(bash /home/shelluser/tst.sh &)"
|
||||
expect -exact "(bash /home/shelluser/tst.sh &)"
|
||||
send -- "\r"
|
||||
send -- "\r"
|
||||
send -- "\r"
|
||||
send -- "fg\r"
|
||||
send -- "\r"
|
||||
send -- "\r"
|
||||
send -- "\r"
|
||||
send -- "ls\r"
|
||||
send -- "^D"
|
||||
expect "# "
|
||||
send -- "^D"
|
||||
expect eof
|
||||
4
login/tst.sh
Normal file
4
login/tst.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/shellbin
|
||||
|
||||
D=$(date)
|
||||
echo $D > /home/shelluser//tst.dat
|
||||
62
smoke/Makefile
Normal file
62
smoke/Makefile
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Makefile of /CoreOS/bash/Sanity/smoke
|
||||
# Description: Basic sanity smoke test
|
||||
# Author: Miroslav Hradilek <mhradile@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2012 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/.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
export TEST=/CoreOS/bash/Sanity/smoke
|
||||
export TESTVERSION=1.0
|
||||
|
||||
BUILT_FILES=
|
||||
|
||||
FILES=$(METADATA) runtest.sh Makefile PURPOSE t_alias t_conditionals t_variables
|
||||
|
||||
.PHONY: all install download clean
|
||||
|
||||
run: $(FILES) build
|
||||
./runtest.sh
|
||||
|
||||
build: $(BUILT_FILES)
|
||||
test -x runtest.sh || chmod a+x runtest.sh
|
||||
|
||||
clean:
|
||||
rm -f *~ $(BUILT_FILES)
|
||||
|
||||
|
||||
include /usr/share/rhts/lib/rhts-make.include
|
||||
|
||||
$(METADATA): Makefile
|
||||
@echo "Owner: Miroslav Hradilek <mhradile@redhat.com>" > $(METADATA)
|
||||
@echo "Name: $(TEST)" >> $(METADATA)
|
||||
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
|
||||
@echo "Path: $(TEST_DIR)" >> $(METADATA)
|
||||
@echo "Description: Basic sanity smoke test" >> $(METADATA)
|
||||
@echo "Type: Sanity" >> $(METADATA)
|
||||
@echo "TestTime: 5m" >> $(METADATA)
|
||||
@echo "RunFor: bash" >> $(METADATA)
|
||||
@echo "Requires: bash" >> $(METADATA)
|
||||
@echo "Priority: Normal" >> $(METADATA)
|
||||
@echo "License: GPLv2" >> $(METADATA)
|
||||
@echo "Confidential: no" >> $(METADATA)
|
||||
@echo "Destructive: no" >> $(METADATA)
|
||||
|
||||
rhts-lint $(METADATA)
|
||||
8
smoke/PURPOSE
Normal file
8
smoke/PURPOSE
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
PURPOSE of /CoreOS/bash/Sanity/smoke
|
||||
Description: Basic sanity smoke test
|
||||
Author: Miroslav Hradilek <mhradile@redhat.com>
|
||||
|
||||
Performs basic sanity smoke test. Tries to supply commands on a
|
||||
command line, variable assignment and substitution, file
|
||||
expansion, "test" builtin, redirection, pipeline and some control
|
||||
structures.
|
||||
81
smoke/runtest.sh
Normal file
81
smoke/runtest.sh
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/bash/Sanity/smoke
|
||||
# Description: Basic sanity smoke test
|
||||
# Author: Miroslav Hradilek <mhradile@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2012 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/bin/rhts-environment.sh || exit 1
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
PACKAGES=${PACKAGES:-"bash"}
|
||||
SH_BIN=${SH_BIN:-"bash"}
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlAssertRpm --all
|
||||
rlAssertBinaryOrigin $SH_BIN
|
||||
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
|
||||
rlRun "cp t_* $TmpDir/." 0 "Copying additional test files"
|
||||
rlRun "pushd $TmpDir"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest
|
||||
rlLog "Commandline options"
|
||||
rlRun "$SH_BIN -c 'echo OK' | grep OK" 0 "Testing -c option"
|
||||
|
||||
rlLog "Assorted tests"
|
||||
rlRun "$SH_BIN -c 'echo \`echo OK\`' | grep OK" 0 "Testing command substitution"
|
||||
[ "$SH_BIN" == "bash" ] && EXTRAPARAM="-i"
|
||||
rlRun "$SH_BIN $EXTRAPARAM t_alias | grep OK" 0 "Testing alias"
|
||||
rlRun "$SH_BIN -c 'echo \$((1+1))' | grep 2" 0 "Arithmetic expansion"
|
||||
rlRun "$SH_BIN -c 'writedown(){ echo \$1; }; writedown OK' | grep OK" 0 "Testing function"
|
||||
|
||||
rlLog "Variables"
|
||||
rlRun "$SH_BIN -c 'testvar1=\"OK\"; echo \"\$testvar1\"' | grep OK" 0 "Testing variable assignment"
|
||||
rlRun "$SH_BIN t_variables | grep 'default,OK'" 0 "Testing variable substitution"
|
||||
rlRun "$SH_BIN -c \"cat nonexistent; echo \$?\" | grep 1" 0 "Testing predefined variable \$?"
|
||||
|
||||
rlLog "File expansion"
|
||||
rlRun "touch testfile" 0 "Creating test file"
|
||||
rlRun "$SH_BIN -c 'echo test*' | grep testfile" 0 "Testing expansion to the test file name"
|
||||
|
||||
rlLog "Builtins"
|
||||
rlRun "$SH_BIN -c 'test -e testfile'" 0 "Testing test builtin"
|
||||
|
||||
rlLog "Redirection and pipeline"
|
||||
rlRun "$SH_BIN -c \"echo 'aBc' | grep B >redirection_out\"" 0 "Testing pipeline"
|
||||
rlRun "grep 'aBc' redirection_out" 0 "Testing redirection"
|
||||
|
||||
rlLog "Control structures"
|
||||
rlRun "$SH_BIN -c 'for i in 1 2 3; do echo -n \$i; done' | grep 123" 0 "Testing cycle for"
|
||||
rlRun "$SH_BIN t_conditionals | grep 'operator,if,else,test'" 0 "Testing if and it's && operator shorthand"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
|
||||
rlPhaseEnd
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
2
smoke/t_alias
Normal file
2
smoke/t_alias
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
alias writedown='echo'
|
||||
writedown OK
|
||||
6
smoke/t_conditionals
Normal file
6
smoke/t_conditionals
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
true && echo -n 'operator,'
|
||||
if true; then echo -n 'if,'; fi
|
||||
if ! true; then echo -n 'if,'; else echo -n 'else,'; fi
|
||||
if [ 'notnul' ]; then echo -n 'test'; fi
|
||||
|
||||
|
||||
4
smoke/t_variables
Normal file
4
smoke/t_variables
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
testvar2=${testvar1:-default}
|
||||
testvar3='OK'
|
||||
testvar4=${testvar3:-default}
|
||||
echo "$testvar2,$testvar4"
|
||||
Loading…
Add table
Add a link
Reference in a new issue