diff --git a/func/Makefile b/func/Makefile deleted file mode 100644 index 6acb07d..0000000 --- a/func/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# Makefile -# Author: Jan Scotka -# 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 " > $(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) diff --git a/func/PURPOSE b/func/PURPOSE deleted file mode 100644 index d641633..0000000 --- a/func/PURPOSE +++ /dev/null @@ -1 +0,0 @@ -Basic test of functions in Bourne-Again SHell, testing purpose for Test Container Project diff --git a/func/main.fmf b/func/main.fmf deleted file mode 100644 index 24c81bb..0000000 --- a/func/main.fmf +++ /dev/null @@ -1,3 +0,0 @@ -summary: Basic test of functions in Bourne-Again Shell -duration: 2h -component: [bash, ksh, mksh, zsh] diff --git a/func/runtest.sh b/func/runtest.sh deleted file mode 100755 index 82a7415..0000000 --- a/func/runtest.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/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/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" - # Without this there might be some issue when starting background - echo "unsetopt monitor" >> /etc/zshrc - else - ZSH_OPT="" - fi - rlPhaseEnd - - rlPhaseStartTest "Test of functions" - rlRun "${SH_BIN} -c 'true'" 0 "True action" - 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" - if [ $SH_BIN != "dash" ]; then - rlRun " ${SH_BIN} -c 'let a=1+1;echo \$a|grep -q 2'" 0 "Checking 'let' arithmetic operation 1+1" - fi - rlRun "${SH_BIN} $ZSH_OPT -c 'sleep 100 & jobs > jobs.out; WC=\$(cat jobs.out|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 - - rlPhaseStartCleanup "Cleaning up" - 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 diff --git a/login/Makefile b/login/Makefile deleted file mode 100644 index a8bca8f..0000000 --- a/login/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 " > $(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) diff --git a/login/PURPOSE b/login/PURPOSE deleted file mode 100644 index bac1cd2..0000000 --- a/login/PURPOSE +++ /dev/null @@ -1,3 +0,0 @@ -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 diff --git a/login/main.fmf b/login/main.fmf deleted file mode 100644 index e542d93..0000000 --- a/login/main.fmf +++ /dev/null @@ -1,5 +0,0 @@ -summary: Basic login shell test -description: > - The test creates user with bash as login shell and - verifies that the user can log into the system. -tags: [classic] diff --git a/login/runtest.sh b/login/runtest.sh deleted file mode 100755 index 16b9314..0000000 --- a/login/runtest.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/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 -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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/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 diff --git a/login/script.exp b/login/script.exp deleted file mode 100644 index 127e8e0..0000000 --- a/login/script.exp +++ /dev/null @@ -1,57 +0,0 @@ -#!/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 diff --git a/login/ssh.exp b/login/ssh.exp deleted file mode 100644 index 8807f79..0000000 --- a/login/ssh.exp +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 diff --git a/login/tst.sh b/login/tst.sh deleted file mode 100755 index b52ff72..0000000 --- a/login/tst.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/shellbin - -D=$(date) -echo $D > /home/shelluser//tst.dat diff --git a/main.fmf b/main.fmf deleted file mode 100644 index fccdf4a..0000000 --- a/main.fmf +++ /dev/null @@ -1,6 +0,0 @@ -contact: Jakub Heger -component: [bash, ksh, mksh, zsh, dash] -test: ./runtest.sh -duration: 5m -tier: 2 -tags: [classic, container, atomic] diff --git a/plans/bash.fmf b/plans/bash.fmf new file mode 100644 index 0000000..d3b5338 --- /dev/null +++ b/plans/bash.fmf @@ -0,0 +1,7 @@ +discover+: + filter: component:bash +prepare+: + package: bash +environment: + PACKAGES: bash + SH_BIN: bash diff --git a/plans/dash.fmf b/plans/dash.fmf new file mode 100644 index 0000000..216a4d0 --- /dev/null +++ b/plans/dash.fmf @@ -0,0 +1,7 @@ +discover+: + filter: component:dash +prepare+: + package: dash +environment: + PACKAGES: dash + SH_BIN: dash diff --git a/plans/ksh.fmf b/plans/ksh.fmf new file mode 100644 index 0000000..a4218fc --- /dev/null +++ b/plans/ksh.fmf @@ -0,0 +1,7 @@ +discover+: + filter: component:ksh +prepare+: + package: ksh +environment: + PACKAGES: ksh + SH_BIN: ksh diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 0000000..5449715 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,6 @@ +discover: + how: fmf +prepare: + how: install +execute: + how: tmt diff --git a/plans/mksh.fmf b/plans/mksh.fmf new file mode 100644 index 0000000..bb54e6e --- /dev/null +++ b/plans/mksh.fmf @@ -0,0 +1,7 @@ +discover+: + filter: component:mksh +prepare+: + package: mksh +environment: + PACKAGES: mksh + SH_BIN: mksh diff --git a/plans/zsh.fmf b/plans/zsh.fmf new file mode 100644 index 0000000..7c86e01 --- /dev/null +++ b/plans/zsh.fmf @@ -0,0 +1,7 @@ +discover+: + filter: component:zsh +prepare+: + package: zsh +environment: + PACKAGES: zsh + SH_BIN: zsh diff --git a/smoke/Makefile b/smoke/Makefile deleted file mode 100644 index 1e29977..0000000 --- a/smoke/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Makefile of /CoreOS/bash/Sanity/smoke -# Description: Basic sanity smoke test -# Author: Miroslav Hradilek -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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 " > $(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) diff --git a/smoke/PURPOSE b/smoke/PURPOSE deleted file mode 100644 index f393cb4..0000000 --- a/smoke/PURPOSE +++ /dev/null @@ -1,8 +0,0 @@ -PURPOSE of /CoreOS/bash/Sanity/smoke -Description: Basic sanity smoke test -Author: Miroslav Hradilek - -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. diff --git a/smoke/main.fmf b/smoke/main.fmf deleted file mode 100644 index 310e585..0000000 --- a/smoke/main.fmf +++ /dev/null @@ -1,6 +0,0 @@ -summary: Basic sanity smoke test -description: > - 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. -tier: 1 diff --git a/smoke/runtest.sh b/smoke/runtest.sh deleted file mode 100755 index fc735b4..0000000 --- a/smoke/runtest.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/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 -# -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# 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/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 diff --git a/smoke/t_alias b/smoke/t_alias deleted file mode 100644 index 3018bde..0000000 --- a/smoke/t_alias +++ /dev/null @@ -1,2 +0,0 @@ -alias writedown='echo' -writedown OK diff --git a/smoke/t_conditionals b/smoke/t_conditionals deleted file mode 100644 index a25dbec..0000000 --- a/smoke/t_conditionals +++ /dev/null @@ -1,6 +0,0 @@ -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 - - diff --git a/smoke/t_variables b/smoke/t_variables deleted file mode 100644 index 91d0ec9..0000000 --- a/smoke/t_variables +++ /dev/null @@ -1,4 +0,0 @@ -testvar2=${testvar1:-default} -testvar3='OK' -testvar4=${testvar3:-default} -echo "$testvar2,$testvar4" diff --git a/substitution/main.fmf b/substitution/main.fmf deleted file mode 100644 index d1b5edf..0000000 --- a/substitution/main.fmf +++ /dev/null @@ -1,8 +0,0 @@ -summary: Verify correct $$ parsing in command substitution -description: | - Parsing commands break when using $$ in command substitution $(..). - Test for https://bugzilla.redhat.com/show_bug.cgi?id=1727952 - -extra-nitrate: TC#0602870 -extra-summary: /CoreOS/bash/Regression/bz1727952-Parsing-commands-break-when-using-in-command -extra-task: /CoreOS/bash/Regression/bz1727952-Parsing-commands-break-when-using-in-command diff --git a/substitution/runtest.sh b/substitution/runtest.sh deleted file mode 100755 index b56c6d5..0000000 --- a/substitution/runtest.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# -# Author: Karel Volný -# Copyright (c) 2019 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/share/beakerlib/beakerlib.sh || exit 1 - -PACKAGES=${PACKAGES:-bash} - -rlJournalStart - rlPhaseStartSetup - rlAssertRpm --all - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" - rlRun "pushd $TmpDir" - rlPhaseEnd - - rlPhaseStartTest - rlRun "touch testfile" 0 "Creating the test file" - rlRun -s "A=\$(awk -v p=\$\$ '{print \$0}' > /etc/zshrc + else + ZSH_OPT="" + fi + rlPhaseEnd + + rlPhaseStartTest "Test of functions" + rlRun "${SH_BIN} -c 'true'" 0 "True action" + 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" + if [ $SH_BIN != "dash" ]; then + rlRun " ${SH_BIN} -c 'let a=1+1;echo \$a|grep -q 2'" 0 "Checking 'let' arithmetic operation 1+1" + fi + rlRun "${SH_BIN} $ZSH_OPT -c 'sleep 100 & jobs > jobs.out; WC=\$(cat jobs.out|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 + + rlPhaseStartCleanup "Cleaning up" + 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 diff --git a/tests/login/main.fmf b/tests/login/main.fmf new file mode 100644 index 0000000..cdb00bf --- /dev/null +++ b/tests/login/main.fmf @@ -0,0 +1,12 @@ +summary: Basic login shell test +description: > + The test creates user with bash as login shell and + verifies that the user can log into the system. + Does not run in a container, needs full virtualization. +tag: [virtual] +require: + - expect + - procps-ng + - passwd + - openssh-clients + - openssh-server diff --git a/tests/login/script.exp b/tests/login/script.exp new file mode 100644 index 0000000..127e8e0 --- /dev/null +++ b/tests/login/script.exp @@ -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 diff --git a/tests/login/ssh.exp b/tests/login/ssh.exp new file mode 100644 index 0000000..8807f79 --- /dev/null +++ b/tests/login/ssh.exp @@ -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 diff --git a/tests/login/test.sh b/tests/login/test.sh new file mode 100755 index 0000000..16b9314 --- /dev/null +++ b/tests/login/test.sh @@ -0,0 +1,93 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/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 diff --git a/tests/login/tst.sh b/tests/login/tst.sh new file mode 100755 index 0000000..b52ff72 --- /dev/null +++ b/tests/login/tst.sh @@ -0,0 +1,4 @@ +#!/bin/shellbin + +D=$(date) +echo $D > /home/shelluser//tst.dat diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..c998160 --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,7 @@ +contact: Jakub Heger +test: ./test.sh +framework: beakerlib +component: [bash, ksh, mksh, zsh, dash] +duration: 5m +tier: 2 +tag: [virtual, container] diff --git a/tests/smoke/main.fmf b/tests/smoke/main.fmf new file mode 100644 index 0000000..310e585 --- /dev/null +++ b/tests/smoke/main.fmf @@ -0,0 +1,6 @@ +summary: Basic sanity smoke test +description: > + 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. +tier: 1 diff --git a/tests/smoke/t_alias b/tests/smoke/t_alias new file mode 100644 index 0000000..3018bde --- /dev/null +++ b/tests/smoke/t_alias @@ -0,0 +1,2 @@ +alias writedown='echo' +writedown OK diff --git a/tests/smoke/t_conditionals b/tests/smoke/t_conditionals new file mode 100644 index 0000000..a25dbec --- /dev/null +++ b/tests/smoke/t_conditionals @@ -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 + + diff --git a/tests/smoke/t_variables b/tests/smoke/t_variables new file mode 100644 index 0000000..91d0ec9 --- /dev/null +++ b/tests/smoke/t_variables @@ -0,0 +1,4 @@ +testvar2=${testvar1:-default} +testvar3='OK' +testvar4=${testvar3:-default} +echo "$testvar2,$testvar4" diff --git a/tests/smoke/test.sh b/tests/smoke/test.sh new file mode 100755 index 0000000..fc735b4 --- /dev/null +++ b/tests/smoke/test.sh @@ -0,0 +1,80 @@ +#!/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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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/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 diff --git a/tests/substitution/main.fmf b/tests/substitution/main.fmf new file mode 100644 index 0000000..b7f8701 --- /dev/null +++ b/tests/substitution/main.fmf @@ -0,0 +1,9 @@ +summary: Verify correct $$ parsing in command substitution +description: | + Parsing commands break when using $$ in command substitution $(..). + Test for https://bugzilla.redhat.com/show_bug.cgi?id=1727952 +tier: 1 + +extra-nitrate: TC#0602870 +extra-summary: /CoreOS/bash/Regression/bz1727952-Parsing-commands-break-when-using-in-command +extra-task: /CoreOS/bash/Regression/bz1727952-Parsing-commands-break-when-using-in-command diff --git a/tests/substitution/test.sh b/tests/substitution/test.sh new file mode 100755 index 0000000..b56c6d5 --- /dev/null +++ b/tests/substitution/test.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Author: Karel Volný +# Copyright (c) 2019 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/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=${PACKAGES:-bash} + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm --all + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest + rlRun "touch testfile" 0 "Creating the test file" + rlRun -s "A=\$(awk -v p=\$\$ '{print \$0}'