32a53f94168d5142b9fb3a7d7b2faeb988fb3970
[platform/upstream/coreutils.git] / tests / shred / remove
1 #!/bin/sh
2 # Exercise a bug that was fixed in shred-4.0l
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   shred --version
7 fi
8
9 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19
20 # The length of the basename is what matters.
21 # In this case, shred would try to rename the file 256^10 times
22 # before terminating.
23 file=0123456789
24 touch $file || framework_failure=1
25 chmod u-w $file || framework_failure=1
26
27 if test $framework_failure = 1; then
28   echo 'failure in testing framework'
29   exit 1
30 fi
31
32 fail=0
33
34 # This would take so long that it appears to infloop
35 # when using version from fileutils-4.0k.
36 # When the command completes, expect it to fail.
37 shred -u $file > /dev/null 2>&1 && fail=1 || :
38
39 exit $fail