Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / rm / ir-1
1 #!/bin/sh
2 # Test "rm -ir".
3
4 # Copyright (C) 1997, 1998, 2002, 2004, 2006 Free Software Foundation,
5 # Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 test=ir-1
23
24 if test "$VERBOSE" = yes; then
25   set -x
26   rm --version
27 fi
28
29 pwd=`pwd`
30 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
31 trap 'status=$?; cd "$pwd" && rm -rf $t0 && exit $status' 0
32 trap '(exit $?); exit' 1 2 13 15
33
34 test_failure=0
35 mkdir -p $tmp $tmp/a $tmp/b $tmp/c || test_failure=1
36 > $tmp/a/a || test_failure=1
37 > $tmp/b/bb || test_failure=1
38 > $tmp/c/cc || test_failure=1
39
40 if test $test_failure = 1; then
41   echo 'failure in testing framework'
42   exit 1
43 fi
44
45 cat <<EOF > $test.I
46 y
47 y
48 y
49 y
50 y
51 y
52 y
53 y
54 n
55 n
56 n
57 EOF
58
59 # Remove all but one of a, b, c -- I doubt that this test can portably
60 # determine which one was removed based on order of dir entries.
61 # This is a good argument for switching to a dejagnu-style test suite.
62 fail=0
63 rm --verbose -i -r $tmp < $test.I > /dev/null 2>&1 || fail=1
64
65 # $tmp should not have been removed.
66 test -d $tmp || fail=1
67
68 # There should be only one directory left.
69 case `echo $tmp/*` in
70   $tmp/[abc]) ;;
71   *) fail=1 ;;
72 esac
73
74 rm -rf $tmp $test.I
75
76 (exit $fail); exit $fail