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/Cannot-handle-file-names-with-integrated-spaces
e0e2de7
#   Description: Test for bz431887 (Cannot handle file names with integrated spaces)
e0e2de7
#   Author: Ondrej Moris <omoris@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
function apply_patch {
e0e2de7
expect <
e0e2de7
set timeout 5
e0e2de7
spawn patch -i spaces.patch
e0e2de7
expect "patching file 'f i r s t'" { expect timeout ; exit 0 }
e0e2de7
exit 1
e0e2de7
EOF
e0e2de7
return $?
e0e2de7
}
e0e2de7
e0e2de7
rlJournalStart
e0e2de7
e0e2de7
    rlPhaseStartSetup
e0e2de7
e0e2de7
        rlAssertRpm $PACKAGE
e0e2de7
e0e2de7
    rlPhaseEnd
e0e2de7
e0e2de7
    rlPhaseStartTest
e0e2de7
e0e2de7
        rlRun "echo \"1\" > \"f i r s t\"" 0
e0e2de7
        rlRun "echo \"2\" > \"s e c o n d\"" 0
e0e2de7
        rlAssertExists "f i r s t"
e0e2de7
        rlAssertExists "s e c o n d"
e0e2de7
        rlAssertDiffer "f i r s t" "s e c o n d"
e0e2de7
        rlRun "diff -u f\ i\ r\ s\ t s\ e\ c\ o\ n\ d > spaces.patch" 1
e0e2de7
        rlRun "apply_patch" 0 "Patching file with spaces in its name"
e0e2de7
        rlAssertExists "f i r s t"
e0e2de7
        rlAssertExists "s e c o n d"
e0e2de7
        rlAssertNotDiffer "f i r s t" "s e c o n d"
e0e2de7
e0e2de7
    rlPhaseEnd
e0e2de7
e0e2de7
    rlPhaseStartCleanup
e0e2de7
e0e2de7
        rlRun "rm -f f\ i\ r\ s\ t s\ e\ c\ o\ n\ d spaces.patch"
e0e2de7
e0e2de7
    rlPhaseEnd
e0e2de7
e0e2de7
rlJournalPrintText
e0e2de7
e0e2de7
rlJournalEnd