2 # Ensure that hard-linked files are counted (and listed) only once.
3 # Likewise for excluded directories.
4 # Ensure that hard links _are_ listed twice when using --count-links.
6 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <https://www.gnu.org/licenses/>.
21 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
29 echo non-empty
> sub
/F
; } )
31 du
-a -L --exclude=sub
--count-links dir \
32 |
sed 's/^[0-9][0-9]* //' |
sort -r > out || fail
=1
34 # For these tests, transform f1 or f2 or f3 (whichever name is find
35 # first) to f_. That is necessary because, depending on the type of
36 # file system, du could encounter any of those linked files first,
37 # thus listing that one and not the others.
38 for args
in '-L' 'dir' '-L dir'
41 du
-a --exclude=sub
$args dir \
42 |
sed 's/^[0-9][0-9]* //' |
sed 's/f[123]/f_/' >> out || fail
=1
62 compare exp out || fail
=1