8e7f8ce86f1edfab26a8724359b41a419dbb2b36
[platform/upstream/coreutils.git] / tests / rm / hash
1 #!/bin/sh
2 # Exercise a bug that was fixed in 4.0s.
3 # Before then, rm would fail occasionally, sometimes via
4 # a failed assertion, others with a seg fault.
5
6 . $srcdir/../expensive
7
8 if test "$VERBOSE" = yes; then
9   set -x
10   rm --version
11 fi
12
13 pwd=`pwd`
14 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
15 trap 'status=$?; cd $pwd; rm -rf $t0 || exit $?; exit $status' 0
16 trap 'exit $?' 1 2 13 15
17
18 framework_failure=0
19 mkdir -p $tmp || framework_failure=1
20 cd $tmp
21
22 # Create a hierarchy with 3*26 leaf directories, each at depth 153.
23 echo "$0: creating 78 trees, each of depth 153; this will take a while..." >&2
24 y=`seq 1 150|tr -sc '\n' y|tr '\n' /`
25 for i in 1 2 3; do
26   for j 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; do
27     mkdir -p t/$i/$j/$y || framework_failure=1
28   done
29 done
30
31 if test $framework_failure = 1; then
32   echo 'failure in testing framework'
33   exit 1
34 fi
35
36 fail=0
37
38 rm -r t || fail=1
39
40 (exit $fail); exit $fail