summaryrefslogtreecommitdiff
path: root/tests/rm/deep-1
blob: 3ed0f3cc6d00380e658b447e910dd052a622cac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh

# This is a bit of a torture test for mkdir -p, too.
# Also make sure du can process this tree without using too much stack space.
# GNU rm performs *much* better on systems that have a d_type member
# in the directory structure because then it does only one stat per
# command line argument.

# If this test takes too long on your system, blame the OS.

if test "$VERBOSE" = yes; then
  set -x
  rm --version
fi

pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
trap '(exit $?); exit' 1 2 13 15

umask 022

fail=0

k20=/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k/k
k200=$k20$k20$k20$k20$k20$k20$k20$k20$k20$k20

# Be careful not to exceed max file name length (usu 512?).
# Doing so wouldn't affect GNU mkdir or GNU rm, but any tool that
# operates on the full pathname (like `test') would choke.
k_deep=$k200$k200

# Create a directory in $tmp with lots of `k' components.
deep=$tmp$k_deep
mkdir -p $deep || fail=1

# Make sure the deep dir was created.
test -d $deep || fail=1

# Make sure du can handle it without using lots of stack.
# Before switching to the non-recursive, fts-based version of du,
# this invocation of du would require a stack of at least 115KB
# on an x86 linux-2.4.22 system.  The fts-based version needs
# only 8KB on that same system.
( ulimit -s 50; du -s $tmp > /dev/null ) || fail=1

rm -r $tmp || fail=1
echo done

# Make sure all of $tmp was deleted.
test -d $tmp && fail=1

(exit $fail); exit