sed/tests/sed-needs-to-support-c-copy-option/runtest.sh
2017-09-25 16:43:53 -05:00

62 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/sed/Regression/sed-needs-to-support-c-copy-option
# Description: Test for sed needs to support -c/--copy option
# Author: Karel Srot <ksrot@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2010 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# 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, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include rhts environment
. /usr/bin/rhts-environment.sh
. /usr/lib/beakerlib/beakerlib.sh
PACKAGE="sed"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlRun "echo 'test' > file1" 0 "Prepare test files"
rlRun "touch file2"
rlRun "mount -n --bind file1 file2"
rlRun "grep test file2" 0 "Verify tests files"
rlPhaseEnd
rlPhaseStartTest
rlRun "sed -i 's/test/passed/' file2 &> out1" 4 "Executing sed -i"
rlAssertGrep "cannot rename" out1
rlAssertGrep "test" file2
rlRun "sed -i -c 's/test/passed/' file2 &> out2" 0 "Executing sed -i -c"
rlAssertNotGrep "cannot rename" out2
rlAssertGrep "passed" file2
rlPhaseEnd
rlPhaseStartCleanup
rlRun "umount file2"
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd