summaryrefslogtreecommitdiff
path: root/tests/rm/r-2
blob: 596581cd3253a79cf225981b60b88db7df49c581 (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

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

pwd=`pwd`
tmp=r2-$$
trap 'status=$?; cd $pwd; rm -rf $tmp || exit $?; exit $status' 0
trap 'exit $?' 1 2 13 15

framework_failure=0
mkdir $tmp || framework_failure=1
cd $tmp

mkdir t t/a t/a/b || framework_failure=1
> t/a/f || framework_failure=1
> t/a/b/g || framework_failure=1

LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL

# FIXME: if this fails, it's a framework failure
cat <<EOF | sort > t/$test.E || framework_failure=1
removing all entries of directory t/a
removing all entries of directory t/a/b
removing t/a/b/g
removing the directory itself: t/a/b
removing t/a/f
removing the directory itself: t/a
EOF

if test $framework_failure = 1; then
  echo 'failure in testing framework'
  exit 1
fi

# Note that both the expected output (above) and the actual output lines
# are sorted, because directory entries may be processed in arbitrary order.
fail=0
rm --verbose -r t/a | sort > t/$test.O || fail=1

if test -d t/a; then
  fail=1
fi

# Compare expected and actual output.
cmp t/$test.E t/$test.O || fail=1

exit $fail