e0e2de7
#!/bin/bash
e0e2de7
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
e0e2de7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e0e2de7
#
e0e2de7
#   runtest.sh of /CoreOS/patch/Regression/Regression-wrong-name-used-when-adding-new-file
e0e2de7
#   Description: Test for Regression: wrong name used when adding new file
e0e2de7
#   Author: Karel Srot <ksrot@redhat.com>
e0e2de7
#
e0e2de7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e0e2de7
#
e0e2de7
#   Copyright (c) 2010 Red Hat, Inc. All rights reserved.
e0e2de7
#
e0e2de7
#   This copyrighted material is made available to anyone wishing
e0e2de7
#   to use, modify, copy, or redistribute it subject to the terms
e0e2de7
#   and conditions of the GNU General Public License version 2.
e0e2de7
#
e0e2de7
#   This program is distributed in the hope that it will be
e0e2de7
#   useful, but WITHOUT ANY WARRANTY; without even the implied
e0e2de7
#   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
e0e2de7
#   PURPOSE. See the GNU General Public License for more details.
e0e2de7
#
e0e2de7
#   You should have received a copy of the GNU General Public
e0e2de7
#   License along with this program; if not, write to the Free
e0e2de7
#   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
e0e2de7
#   Boston, MA 02110-1301, USA.
e0e2de7
#
e0e2de7
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e0e2de7
e0e2de7
# Include rhts environment
e0e2de7
. /usr/bin/rhts-environment.sh || exit 1
e0e2de7
. /usr/share/beakerlib/beakerlib.sh || exit 1
e0e2de7
e0e2de7
PACKAGE="patch"
e0e2de7
e0e2de7
rlJournalStart
e0e2de7
    rlPhaseStartSetup
e0e2de7
        rlAssertRpm $PACKAGE
e0e2de7
        rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"
e0e2de7
        rlRun "pushd $TmpDir"
e0e2de7
	rlRun "mkdir a b && touch a/file && echo content > b/file.new" 0 "Preparing test environment"
e0e2de7
	rlRun "diff -u a/file b/file.new > test.patch" 1 "Preparing a patch"
e0e2de7
    rlPhaseEnd
e0e2de7
e0e2de7
    rlPhaseStartTest
e0e2de7
	rlRun "patch -p1 -b -z .backup -i test.patch" 0 "Patching the test file"
e0e2de7
	rlAssertExists file
e0e2de7
	rlAssertExists file.backup
e0e2de7
	rlAssertNotExists file.new
e0e2de7
	rlAssertNotExists file.new.backup
e0e2de7
    rlPhaseEnd
e0e2de7
e0e2de7
    rlPhaseStartCleanup
e0e2de7
        rlRun "popd"
e0e2de7
        rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
e0e2de7
    rlPhaseEnd
e0e2de7
rlJournalPrintText
e0e2de7
rlJournalEnd