tests: add test for locale decimal processing
[coreutils.git] / tests / du / inacc-dest.sh
blob877d13906cc9f52217b6dab877833fc5ba8b4779
1 #!/bin/sh
2 # Prior to coreutils-6.5, an inaccessible destination dir (chmod a-x)
3 # would cause du to exit prematurely on systems with native openat support.
5 # Copyright (C) 2006-2019 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
21 print_ver_ du
22 skip_if_root_
24 mkdir f && cd f && mkdir a b c d e && touch c/j && chmod a-x c \
25 || framework_failure_
27 du > ../t 2>&1 && fail=1
29 # Accept either of the following outputs.
30 # You get the first from a system with openat _emulation_ (via /proc),
31 # the second from a system with native openat support.
32 # FIXME: there may well be a third output, for systems with neither
33 # /proc support, nor native openat support.
35 sed 's/^[0-9][0-9]* //' ../t | sort -u > out
36 cat <<\EOF > exp || framework_failure_
38 ./a
39 ./b
40 ./c
41 ./d
42 ./e
43 du: cannot read directory './c': Permission denied
44 EOF
46 # Map a diagnostic like this
47 # du: cannot access './c/j': Permission denied
48 # to this:
49 # du: cannot access './c': Permission denied
50 # And accept "cannot read directory" in place of "cannot access"
51 sed "s,/c/j': ,/c': ," out > t && mv t out
52 sed 's,cannot access,cannot read directory,' out > t && mv t out
54 compare exp out || fail=1
56 Exit $fail