2 ################################################################################
4 ## Copyright (c) International Business Machines Corp., 2001 ##
6 ## This program is free software; you can redistribute it and#or modify ##
7 ## it under the terms of the GNU General Public License as published by ##
8 ## the Free Software Foundation; either version 2 of the License, or ##
9 ## (at your option) any later version. ##
11 ## This program is distributed in the hope that it will be useful, but ##
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
14 ## for more details. ##
16 ## You should have received a copy of the GNU General Public License ##
17 ## along with this program; if not, write to the Free Software ##
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
20 ################################################################################
25 # Description: Test basic functionality of cpio command
26 # - Test #1: cpio -o can create an archive.
28 # Author: Manoj Iyer, manjo@mail.utexas.edu
30 # History: Jan 30 2003 - Created - Manoj Iyer.
34 # Description: - Check if command cpio is available.
35 # - Create temprary directory, and temporary files.
36 # - Initialize environment variables.
38 # Return - zero on success
39 # - non zero on failure. return value from commands ($RC)
43 RC
=0 # Return code from commands.
44 export TST_TOTAL
=1 # total numner of tests in this file.
45 export TCID
=cpio # this is the init function.
46 export TST_COUNT
=0 # init identifier,
48 if [ -z "$LTPTMP" -a -z "$TMPBASE" ]
57 $LTPBIN/tst_resm TINFO
"INIT: Inititalizing tests."
59 which cpio > $LTPTMP/tst_cpio.err
2>&1 || RC
=$?
62 $LTPBIN/tst_brk TBROK
$LTPTMP/tst_cpio.err NULL \
63 "Test #1: cpio command does not exist. Reason:"
67 mkdir
-p $LTPTMP/tst_cpio.tmp
> $LTPTMP/tst_cpio.err
2>&1 || RC
=$?
70 $LTPBIN/tst_brk TBROK
$LTPTMP/tst_cpio.err NULL \
71 "Test #1: failed creating temp directory. Reason:"
75 for i
in a b c d e f g h i j k l m n o p q r s t u v w x y z
77 touch $LTPTMP/tst_cpio.tmp
/$i > $LTPTMP/tst_cpio.err
2>&1 || RC
=$?
80 $LTPBIN/tst_brk TBROK
$LTPTMP/tst_cpio.err NULL \
81 "Test #1: failed creating temp directory. Reason:"
90 # Description - Remove all temorary directories and file.s
95 export TCID
=cpio # this is the init function.
96 export TST_COUNT
=0 # init identifier,
98 $LTPBIN/tst_resm TINFO
"CLEAN cleaning up before return"
99 rm -fr $LTPTMP/tst_cpio
* > /dev
/null
2>&1
106 # Description - Test #1: Test that cpio -o will create a cpio archive.
108 # Return - zero on success
109 # - non zero on failure. return value from commands ($RC)
113 RC
=0 # Return value from commands.
114 export TCID
=cpio01
# Name of the test case.
115 export TST_COUNT
=1 # Test number.
117 $LTPBIN/tst_resm TINFO
"Test #1: cpio -o will create an archive."
119 find $LTPTMP/tst_cpio.tmp
/ -type f |
cpio -o > $LTPTMP/tst_cpio.out \
120 2>$LTPTMP/tst_cpio.err || RC
=$?
123 $LTPBIN/tst_res TFAIL
$LTPTMP/tst_cpio.err \
124 "Test #1: creating cpio archive failed. Reason:"
127 if [ -f $LTPTMP/tst_cpio.out
]
129 file $LTPTMP/tst_cpio.out
> $LTPTMP/tst_cpio.err
2>&1 || RC
=$?
132 $LTPBIN/tst_res TFAIL
$LTPTMP/tst_cpio.err \
133 "Test #1: bad output, not cpio format. Reason:"
137 $LTPBIN/tst_resm TFAIL
"Test #1: did not create cpio file."
147 # Description: - Execute all tests, report results.
149 # Exit: - zero on success
150 # - non-zero on failure.
153 TFAILCNT
=0 # Set TFAILCNT to 0, increment on failure.
154 RC
=0 # Return code from tests.
156 init ||
exit $RC # Exit if initializing testcases fails.
158 test01 || RC
=$?
# Test #1
161 $LTPBIN/tst_resm TPASS
"Test #1: cpio created an archive"
163 TFAILCNT
=$
(( $TFAILCNT+1 ))
166 clean
# clean up before returning