cksum: ensure appropriate "binary" mode with --untagged
[coreutils.git] / tests / du / long-from-unreadable.sh
blob6e57649e27a80089fa7b350613f0f8a282fd98ea
1 #!/bin/sh
2 # Show fts fails on old-fashioned systems.
4 # Copyright (C) 2006-2024 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 <https://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=.}/tests/init.sh"; path_prepend_ ./src
32 print_ver_ du
34 require_perl_
36 # ecryptfs for example uses some of the file name space
37 # for encrypting filenames, so we must check dynamically.
38 name_max=$(stat -f -c %l .)
39 test "$name_max" -ge '200' || skip_ "NAME_MAX=$name_max is not sufficient"
41 proc_file=/proc/self/fd
42 if test ! -d $proc_file; then
43 skip_ 'This test would fail, since your system lacks /proc support.'
46 dir=$(printf '%200s\n' ' '|tr ' ' x)
48 # Construct a hierarchy containing a relative file with a name
49 # longer than PATH_MAX.
50 # for i in $(seq 52); do
51 # mkdir $dir || framework_failure_
52 # cd $dir || framework_failure_
53 # done
54 # cd $tmp || framework_failure_
56 # Sheesh. Bash 3.1.5 can't create this hierarchy. I get
57 # cd: error retrieving current directory: getcwd:
58 # cannot access parent directories:
59 # (all on one line).
61 cwd=$(pwd)
62 # Use perl instead:
63 $PERL \
64 -e 'my $d = '$dir'; foreach my $i (1..52)' \
65 -e ' { mkdir ($d, 0700) && chdir $d or die "$!" }' \
66 || framework_failure_
68 mkdir inaccessible || framework_failure_
69 cd inaccessible || framework_failure_
70 chmod 0 . || framework_failure_
72 du -s "$cwd/$dir" > /dev/null || fail=1
74 Exit $fail