summaryrefslogtreecommitdiff
path: root/tests/du/hard-link
diff options
context:
space:
mode:
authorPaul Eggert <eggert@CS.UCLA.EDU>2010-07-02 23:41:08 -0700
committerJim Meyering <meyering@redhat.com>2010-07-03 10:28:08 +0200
commitefe53cc72b599979ea292754ecfe8abf7c839d22 (patch)
tree4041993405c58203ccad79280dd9aed419e06ec2 /tests/du/hard-link
parentd27d6d371f3f7ede14b6bde79ddd45307d30fa47 (diff)
downloadcoreutils-efe53cc72b599979ea292754ecfe8abf7c839d22.tar.xz
du: don't miscount duplicate directories or link-count-1 files
* NEWS: Mention this. * src/du.c (hash_all): New static var. (process_file): Use it. (main): Set it. * tests/du/hard-link: Add a couple of test cases to help make sure this bug stays squashed. * tests/du/files0-from: Adjust existing tests to reflect change in semantics with duplicate arguments.
Diffstat (limited to 'tests/du/hard-link')
-rwxr-xr-xtests/du/hard-link44
1 files changed, 30 insertions, 14 deletions
diff --git a/tests/du/hard-link b/tests/du/hard-link
index 7e4f51aee..e22320b56 100755
--- a/tests/du/hard-link
+++ b/tests/du/hard-link
@@ -26,24 +26,40 @@ fi
. $srcdir/test-lib.sh
mkdir -p dir/sub
-( cd dir && { echo non-empty > f1; ln f1 f2; echo non-empty > sub/F; } )
-
-
-# Note that for this first test, we transform f1 or f2
-# (whichever name we find first) to f_. That is necessary because,
-# depending on the type of file system, du could encounter either of those
-# two hard-linked files first, thus listing that one and not the other.
-du -a --exclude=sub dir \
- | sed 's/^[0-9][0-9]* //' | sed 's/f[12]/f_/' > out || fail=1
-echo === >> out
-du -a --exclude=sub --count-links dir \
- | sed 's/^[0-9][0-9]* //' | sort -r >> out || fail=1
+( cd dir &&
+ { echo non-empty > f1
+ ln f1 f2
+ ln -s f1 f3
+ echo non-empty > sub/F; } )
+
+du -a -L --exclude=sub --count-links dir \
+ | sed 's/^[0-9][0-9]* //' | sort -r > out || fail=1
+
+# For these tests, transform f1 or f2 or f3 (whichever name is find
+# first) to f_. That is necessary because, depending on the type of
+# file system, du could encounter any of those linked files first,
+# thus listing that one and not the others.
+for args in '-L' 'dir' '-L dir'
+do
+ echo === >> out
+ du -a --exclude=sub $args dir \
+ | sed 's/^[0-9][0-9]* //' | sed 's/f[123]/f_/' >> out || fail=1
+done
+
cat <<\EOF > exp
+dir/f3
+dir/f2
+dir/f1
+dir
+===
dir/f_
dir
===
-dir/f2
-dir/f1
+dir/f_
+dir/f_
+dir
+===
+dir/f_
dir
EOF