tests: convert nearly all `...` expressions to $(...)
[coreutils.git] / tests / du / long-from-unreadable
blob7fc129c170b2f9ef6eeafbf5fa7a4bac21f6400c
1 #!/bin/sh
2 # Show fts fails on old-fashioned systems.
4 # Copyright (C) 2006-2012 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 3 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, see <http://www.gnu.org/licenses/>.
19 # Show that fts (hence du, chmod, chgrp, chown) fails when all of the
20 # following are true:
21 # - '.' is not readable
22 # - operating on a hierarchy containing a relative name longer than PATH_MAX
23 # - run on a system where gnulib's openat emulation must resort to using
24 # save_cwd and restore_cwd (which fail if '.' is not readable).
25 # Thus, the following du invocation should succeed on newer Linux and
26 # Solaris systems, yet it must fail on systems lacking both openat and
27 # /proc support. However, before coreutils-6.0 this test would fail even
28 # on Linux+PROC_FS systems because its fts implementation would revert
29 # unnecessarily to using FTS_NOCHDIR mode in this corner case.
31 . "${srcdir=.}/init.sh"; path_prepend_ ../src
32 print_ver_ du
34 proc_file=/proc/self/fd
35 if test ! -d $proc_file; then
36 skip_ 'This test would fail, since your system lacks /proc support.'
39 dir=$(printf '%200s\n' ' '|tr ' ' x)
41 # Construct a hierarchy containing a relative file with a name
42 # longer than PATH_MAX.
43 # for i in $(seq 52); do
44 # mkdir $dir || framework_failure_
45 # cd $dir || framework_failure_
46 # done
47 # cd $tmp || framework_failure_
49 # Sheesh. Bash 3.1.5 can't create this hierarchy. I get
50 # cd: error retrieving current directory: getcwd:
51 # cannot access parent directories:
52 # (all on one line).
54 cwd=$(pwd)
55 # Use perl instead:
56 : ${PERL=perl}
57 $PERL \
58 -e 'my $d = '$dir'; foreach my $i (1..52)' \
59 -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \
60 || framework_failure_
62 mkdir inaccessible || framework_failure_
63 cd inaccessible || framework_failure_
64 chmod 0 . || framework_failure_
66 du -s "$cwd/$dir" > /dev/null || fail=1
68 Exit $fail