2 # Show fts fails on old-fashioned systems.
4 # Copyright (C) 2006 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # Show that fts (hence du, chmod, chgrp, chown) fails when all of the
23 # - `.' is not readable
24 # - operating on a hierarchy containing a relative name longer than PATH_MAX
25 # - run on a system where gnulib's openat emulation must resort to using
26 # save_cwd and restore_cwd (which fail if `.' is not readable).
27 # Thus, the following du invocation should succeed on newer Linux and
28 # Solaris systems, yet it must fail on systems lacking both openat and
29 # /proc support. However, before coreutils-6.0 this test would fail even
30 # on Linux+PROC_FS systems because its fts implementation would revert
31 # unnecessarily to using FTS_NOCHDIR mode in this corner case.
33 if test "$VERBOSE" = yes; then
38 . $srcdir/../envvar-check
40 proc_file=/proc/self/fd
41 if test ! -d $proc_file; then
43 $0: Skipping this test.
44 It would fail, since your system lacks /proc support.
50 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
51 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
52 trap '(exit $?); exit $?' 1 2 13 15
55 mkdir -p $tmp || framework_failure=1
56 cd $tmp || framework_failure=1
58 dir=`printf '%200s\n' ' '|tr ' ' x`
60 # Construct a hierarchy containing a relative file with a name
61 # longer than PATH_MAX.
62 # for i in `seq 52`; do
63 # mkdir $dir || framework_failure=1
64 # cd $dir || framework_failure=1
66 # cd $tmp || framework_failure=1
68 # Sheesh. Bash 3.1.5 can't create this hierarchy. I get
69 # cd: error retrieving current directory: getcwd: cannot access parent directories:
73 -e 'my $d = '$dir'; foreach my $i (1..52)' \
74 -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \
75 || framework_failure=1
77 mkdir inaccessible || framework_failure=1
78 cd inaccessible || framework_failure=1
79 chmod 0 . || framework_failure=1
81 if test $framework_failure = 1; then
82 echo "$0: failure in testing framework" 1>&2
87 du -s "$pwd/$tmp/$dir" > /dev/null || fail=1
89 (exit $fail); exit $fail