summaryrefslogtreecommitdiff
path: root/tests/du
diff options
context:
space:
mode:
Diffstat (limited to 'tests/du')
-rwxr-xr-xtests/du/2g.sh7
-rwxr-xr-xtests/du/8gb.sh2
-rwxr-xr-xtests/du/basic.sh2
-rwxr-xr-xtests/du/bigtime.sh2
-rwxr-xr-xtests/du/bind-mount-dir-cycle.sh7
-rwxr-xr-xtests/du/deref-args.sh2
-rwxr-xr-xtests/du/deref.sh2
-rwxr-xr-xtests/du/exclude.sh2
-rwxr-xr-xtests/du/fd-leak.sh2
-rwxr-xr-xtests/du/files0-from-dir.sh2
-rwxr-xr-xtests/du/files0-from.pl2
-rwxr-xr-xtests/du/hard-link.sh2
-rwxr-xr-xtests/du/inacc-dest.sh2
-rwxr-xr-xtests/du/inacc-dir.sh2
-rwxr-xr-xtests/du/inaccessible-cwd.sh2
-rwxr-xr-xtests/du/inodes.sh140
-rwxr-xr-xtests/du/long-from-unreadable.sh7
-rwxr-xr-xtests/du/long-sloop.sh2
-rwxr-xr-xtests/du/max-depth.sh2
-rwxr-xr-xtests/du/move-dir-while-traversing.sh2
-rwxr-xr-xtests/du/no-deref.sh2
-rwxr-xr-xtests/du/no-x.sh2
-rwxr-xr-xtests/du/one-file-system.sh2
-rwxr-xr-xtests/du/restore-wd.sh2
-rwxr-xr-xtests/du/slash.sh2
-rwxr-xr-x[-rw-r--r--]tests/du/threshold.sh2
-rwxr-xr-xtests/du/trailing-slash.sh2
-rwxr-xr-xtests/du/two-args.sh2
28 files changed, 175 insertions, 34 deletions
diff --git a/tests/du/2g.sh b/tests/du/2g.sh
index 17ca13e1..f766d4d9 100755
--- a/tests/du/2g.sh
+++ b/tests/du/2g.sh
@@ -3,7 +3,7 @@
# Before coreutils-5.93, on systems with a signed, 32-bit stat.st_blocks
# one of du's computations would overflow.
-# Copyright (C) 2005-2013 Free Software Foundation, Inc.
+# Copyright (C) 2005-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,10 +27,7 @@ very_expensive_
# Get number of free kilobytes on current partition, so we can
# skip this test if there is insufficient free space.
-
-# This technique relies on the fact that the 'Available' kilobyte
-# count is the number just before the one with a trailing '%'.
-free_kb=$(df -kP .|tail -1|sed 's/ [0-9][0-9]*%.*//;s/ *$//;s/.* //')
+free_kb=$(df -k --output=avail . | tail -n1)
case "$free_kb" in
[0-9]*) ;;
*) skip_ "invalid size from df: $free_kb";;
diff --git a/tests/du/8gb.sh b/tests/du/8gb.sh
index 8c172397..399fe7e5 100755
--- a/tests/du/8gb.sh
+++ b/tests/du/8gb.sh
@@ -2,7 +2,7 @@
# Ensure that du does not rely on narrow types like size_t for
# file sizes or sums.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/basic.sh b/tests/du/basic.sh
index a97e08cc..75bc9be1 100755
--- a/tests/du/basic.sh
+++ b/tests/du/basic.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Compare actual numbers from du, assuming block size matches mine.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/bigtime.sh b/tests/du/bigtime.sh
index 64e68610..eebdeb04 100755
--- a/tests/du/bigtime.sh
+++ b/tests/du/bigtime.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise du on a file with a big time stamp.
-# Copyright (C) 2010-2013 Free Software Foundation, Inc.
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/bind-mount-dir-cycle.sh b/tests/du/bind-mount-dir-cycle.sh
index c70b41fb..ac6bf2e2 100755
--- a/tests/du/bind-mount-dir-cycle.sh
+++ b/tests/du/bind-mount-dir-cycle.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise du's new ability to handle bind-mount-induced dir cycles.
-# Copyright (C) 2012-2013 Free Software Foundation, Inc.
+# Copyright (C) 2012-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -27,12 +27,11 @@ mount --bind a a/b \
|| skip_ "This test requires mount with a working --bind option."
echo a > exp || framework_failure_
-echo "du: mount point 'a/b' already traversed" > exp-err || framework_failure_
-du a > out 2> err && fail=1
+du a > out 2> err || fail=1
sed 's/^[0-9][0-9]* //' out > k && mv k out
-compare exp-err err || fail=1
+compare /dev/null err || fail=1
compare exp out || fail=1
Exit $fail
diff --git a/tests/du/deref-args.sh b/tests/du/deref-args.sh
index c1c5a4d4..50e525a1 100755
--- a/tests/du/deref-args.sh
+++ b/tests/du/deref-args.sh
@@ -2,7 +2,7 @@
# Ensure that --dereference-args (-D) gives reasonable names.
# This test would fail for coreutils-5.0.91.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/deref.sh b/tests/du/deref.sh
index 7ac9aedb..543b7395 100755
--- a/tests/du/deref.sh
+++ b/tests/du/deref.sh
@@ -4,7 +4,7 @@
# Also, up to coreutils-8.5, du -L sometimes incorrectly
# counted the space of the followed symlinks.
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/exclude.sh b/tests/du/exclude.sh
index c9e0ef56..26ba598e 100755
--- a/tests/du/exclude.sh
+++ b/tests/du/exclude.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# make sure du's --exclude option works
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/fd-leak.sh b/tests/du/fd-leak.sh
index e278e70e..ba8518e1 100755
--- a/tests/du/fd-leak.sh
+++ b/tests/du/fd-leak.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# check for file descriptor leak
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/files0-from-dir.sh b/tests/du/files0-from-dir.sh
index d305fad0..67088434 100755
--- a/tests/du/files0-from-dir.sh
+++ b/tests/du/files0-from-dir.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# ensure that du and wc handle --files0-from=DIR
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/files0-from.pl b/tests/du/files0-from.pl
index 7bb82ab9..13c03c0c 100755
--- a/tests/du/files0-from.pl
+++ b/tests/du/files0-from.pl
@@ -2,7 +2,7 @@
# Exercise du's --files0-from option.
# FIXME: keep this file in sync with tests/misc/wc-files0-from.
-# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+# Copyright (C) 2004-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/hard-link.sh b/tests/du/hard-link.sh
index 052cb4e3..1d431e4c 100755
--- a/tests/du/hard-link.sh
+++ b/tests/du/hard-link.sh
@@ -3,7 +3,7 @@
# Likewise for excluded directories.
# Ensure that hard links _are_ listed twice when using --count-links.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/inacc-dest.sh b/tests/du/inacc-dest.sh
index 88e18945..578237c3 100755
--- a/tests/du/inacc-dest.sh
+++ b/tests/du/inacc-dest.sh
@@ -2,7 +2,7 @@
# Prior to coreutils-6.5, an inaccessible destination dir (chmod a-x)
# would cause du to exit prematurely on systems with native openat support.
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/inacc-dir.sh b/tests/du/inacc-dir.sh
index 911c04fc..4c053909 100755
--- a/tests/du/inacc-dir.sh
+++ b/tests/du/inacc-dir.sh
@@ -1,6 +1,6 @@
#!/bin/sh
# Ensure that du counts the size of an inaccessible directory.
-# Copyright (C) 2007-2013 Free Software Foundation, Inc.
+# Copyright (C) 2007-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/inaccessible-cwd.sh b/tests/du/inaccessible-cwd.sh
index cd00444b..663e0401 100755
--- a/tests/du/inaccessible-cwd.sh
+++ b/tests/du/inaccessible-cwd.sh
@@ -2,7 +2,7 @@
# Ensure that even when run from an inaccessible directory, du can still
# operate on accessible directories elsewhere.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/inodes.sh b/tests/du/inodes.sh
new file mode 100755
index 00000000..6d2c28bb
--- /dev/null
+++ b/tests/du/inodes.sh
@@ -0,0 +1,140 @@
+#!/bin/sh
+# exercise du's --inodes option
+
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ du
+
+# An empty directory uses only 1 inode.
+mkdir d || framework_failure_
+printf '1\td\n' > exp || framework_failure_
+
+du --inodes d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Add a regular file: 2 inodes used.
+touch d/f || framework_failure_
+printf '2\td\n' > exp || framework_failure_
+
+du --inodes d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Add a hardlink to the file: still only 2 inodes used.
+ln -v d/f d/h || framework_failure_
+du --inodes d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Now count also hardlinks (-l,--count-links): 3 inodes.
+printf '3\td\n' > exp || framework_failure_
+du --inodes -l d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Create a directory and summarize: 3 inodes.
+mkdir d/d || framework_failure_
+du --inodes -s d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Count inodes separated: 1-2.
+printf '1\td/d\n2\td\n' > exp || framework_failure_
+du --inodes -S d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Count inodes cumulative (default): 1-3.
+printf '1\td/d\n3\td\n' > exp || framework_failure_
+du --inodes d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Count all items: 1-1-3.
+# Sort output because the directory entry order is not defined.
+# Also replace the hardlink with the original file name because
+# the system may either return 'd/f' or 'd/h' first, and du(1)
+# will ignore the other one.
+printf '1\td/d\n1\td/f\n3\td\n' | sort > exp || framework_failure_
+du --inodes -a d > out.tmp 2>err || fail=1
+sed 's/h$/f/' out.tmp | sort >out || framework_failure_
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Count all items and hardlinks again: 1-1-1-4
+# Sort output because the directory entry order is not defined.
+printf '1\td/d\n1\td/h\n1\td/f\n4\td\n' | sort > exp || framework_failure_
+du --inodes -al d > out.tmp 2>err || fail=1
+sort <out.tmp >out || framework_failure_
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Run with total (-c) line: 1-3-3
+printf '1\td/d\n3\td\n3\ttotal\n' > exp || framework_failure_
+du --inodes -c d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Create another file in the subdirectory: 2-4
+touch d/d/f || framework_failure_
+printf '2\td/d\n4\td\n' > exp || framework_failure_
+du --inodes d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Ensure human output (-h, --si) works.
+rm -rf d || framework_failure_
+mkdir d || framework_failure_
+seq --format="d/file%g" 1023 | xargs touch || framework_failure_
+printf '1.0K\td\n' > exp || framework_failure_
+du --inodes -h d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+printf '1.1k\td\n' > exp || framework_failure_
+du --inodes --si d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Verify --inodes ignores -B.
+printf '1024\td\n' > exp || framework_failure_
+du --inodes -B10 d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+# Verify --inodes works with --threshold.
+printf '1024\td\n' > exp || framework_failure_
+du --inodes --threshold=1000 d > out 2>err || fail=1
+compare exp out || fail=1
+compare /dev/null err || fail=1
+
+du --inodes --threshold=-1000 d > out 2>err || fail=1
+compare /dev/null out || fail=1
+compare /dev/null err || fail=1
+
+# Verify --inodes raises a warning for --apparent-size and -b.
+du --inodes -b d > out 2>err || fail=1
+grep ' ineffective ' err >/dev/null || { fail=1; cat out err; }
+
+du --inodes --apparent-size d > out 2>err || fail=1
+grep ' ineffective ' err >/dev/null || { fail=1; cat out err; }
+
+# Ensure that --inodes is mentioned in the usage.
+du --help > out || fail=1
+grep ' --inodes ' out >/dev/null || { fail=1; cat out; }
+Exit $fail
diff --git a/tests/du/long-from-unreadable.sh b/tests/du/long-from-unreadable.sh
index 18bf384d..e343bb56 100755
--- a/tests/du/long-from-unreadable.sh
+++ b/tests/du/long-from-unreadable.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Show fts fails on old-fashioned systems.
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -31,6 +31,11 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ du
+# ecryptfs for example uses some of the file name space
+# for encrypting filenames, so we must check dynamically.
+name_max=$(stat -f -c %l .)
+test "$name_max" -ge '200' || skip_ "NAME_MAX=$name_max is not sufficient"
+
proc_file=/proc/self/fd
if test ! -d $proc_file; then
skip_ 'This test would fail, since your system lacks /proc support.'
diff --git a/tests/du/long-sloop.sh b/tests/du/long-sloop.sh
index faeabbf2..5168ac00 100755
--- a/tests/du/long-sloop.sh
+++ b/tests/du/long-sloop.sh
@@ -3,7 +3,7 @@
# Show that du fails with ELOOP (Too many levels of symbolic links)
# when it encounters that condition.
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/max-depth.sh b/tests/du/max-depth.sh
index 36167ff0..4d201095 100755
--- a/tests/du/max-depth.sh
+++ b/tests/du/max-depth.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise du's --max-depth=N option
-# Copyright (C) 2010-2013 Free Software Foundation, Inc.
+# Copyright (C) 2010-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/move-dir-while-traversing.sh b/tests/du/move-dir-while-traversing.sh
index ab670984..046dad90 100755
--- a/tests/du/move-dir-while-traversing.sh
+++ b/tests/du/move-dir-while-traversing.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Trigger a failed assertion in coreutils-8.9 and earlier.
-# Copyright (C) 2011-2013 Free Software Foundation, Inc.
+# Copyright (C) 2011-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/no-deref.sh b/tests/du/no-deref.sh
index 65e5e4ad..0708bd35 100755
--- a/tests/du/no-deref.sh
+++ b/tests/du/no-deref.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that by default, du doesn't dereference command-line symlinks.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/no-x.sh b/tests/du/no-x.sh
index 492bfa08..625eb96a 100755
--- a/tests/du/no-x.sh
+++ b/tests/du/no-x.sh
@@ -2,7 +2,7 @@
# Make sure du gives the right diagnostic for a readable,
# but inaccessible directory.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/one-file-system.sh b/tests/du/one-file-system.sh
index f53b8853..db18d9b7 100755
--- a/tests/du/one-file-system.sh
+++ b/tests/du/one-file-system.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Test for bugs in du's --one-file-system (-x) option.
-# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+# Copyright (C) 2006-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/restore-wd.sh b/tests/du/restore-wd.sh
index 5300554e..605399e4 100755
--- a/tests/du/restore-wd.sh
+++ b/tests/du/restore-wd.sh
@@ -2,7 +2,7 @@
# due to a bug in glibc's ftw.c, in some cases, nftw w/FTW_CHDIR
# would not restore the working directory.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/slash.sh b/tests/du/slash.sh
index f0222784..3073cb1b 100755
--- a/tests/du/slash.sh
+++ b/tests/du/slash.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# 'du /' would omit the '/' on the last line.
-# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+# Copyright (C) 2003-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/threshold.sh b/tests/du/threshold.sh
index ee5217db..1985a6be 100644..100755
--- a/tests/du/threshold.sh
+++ b/tests/du/threshold.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Exercise du's --threshold option.
-# Copyright (C) 2013 Free Software Foundation, Inc.
+# Copyright (C) 2013-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/trailing-slash.sh b/tests/du/trailing-slash.sh
index 9fc51237..d6a935ad 100755
--- a/tests/du/trailing-slash.sh
+++ b/tests/du/trailing-slash.sh
@@ -2,7 +2,7 @@
# Ensure that du works properly for an argument that refers to a
# symbolic link, and that is specified with a trailing slash.
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/tests/du/two-args.sh b/tests/du/two-args.sh
index f3dea761..b5ec3024 100755
--- a/tests/du/two-args.sh
+++ b/tests/du/two-args.sh
@@ -2,7 +2,7 @@
# Make sure 'du d/1 d/2' works.
# That command failed with du from fileutils-4.0q.
-# Copyright (C) 2000-2013 Free Software Foundation, Inc.
+# Copyright (C) 2000-2014 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by