Blob Blame History Raw
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
#   runtest.sh of /CoreOS/cpio/Sanity/sanity-test-create-extract
#   Description: it creates archive in file and extract files then
#   Author: Jan Scotka <jscotka@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="cpio"

rlJournalStart
    rlPhaseStartSetup
        rlAssertRpm $PACKAGE
        tmp=`mktemp -d`
        cd $tmp
        mkdir arch
# creating thousand of files 
        rlRun 'for foo in `seq 1000`;do touch x.$foo;done'
# creating bigger files
        rlRun 'for foo in `seq 10`;do dd if=/dev/zero of=y.$foo bs=1k seek=$foo count=1;ls -sh y.$foo;done'
    rlPhaseEnd

    rlPhaseStartTest
        rlRun 'ls x.* | cpio -ov > arch/x.cpio'
        rlRun 'ls y.* | cpio -ov > arch/y.cpio'
        rlRun 'find . -type f -maxdepth 1 | cpio -ov > arch/z.cpio'

        cd arch
        
        
        rlRun 'cpio -i < x.cpio'
        rlRun 'cpio -i < y.cpio'
        rlLog "thereis `ls y.* |wc -w` words in y.*"
        rlLog "thereis `ls x.* |wc -w` words in x.*"  
        rlRun 'ls y.* |wc -w |grep 11'
        rlRun 'ls x.* |wc -w |grep 1001'

        rm x.* y.*
        rlRun 'cpio -i < z.cpio'
        rlRun 'ls * |wc -w |grep 1011'
        cd /
    rlPhaseEnd

    rlPhaseStartCleanup
        rlRun "rm -r $tmp" 0 "Removing tmp directory"
    rlPhaseEnd
rlJournalPrintText
rlJournalEnd