summaryrefslogtreecommitdiff
path: root/tests/du
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:17:09 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:17:09 +0300
commitcc78bdc31749e9754120ae5a9d4849f4832b40a4 (patch)
tree4f9e3f2064e56651ed8d41ae9d8ce8b08fc5241b /tests/du
parent8425beb209e6fedf50bcdd934ced14dfa0d7b596 (diff)
parent71cd8e3a743046573744123777061b64881bf372 (diff)
downloadcoreutils-cc78bdc31749e9754120ae5a9d4849f4832b40a4.tar.gz
Merge tag 'upstream/8.24'
Upstream version 8.24 Conflicts: INSTALL Makefile.in aclocal.m4 build-aux/config.guess build-aux/config.rpath build-aux/config.sub build-aux/depcomp build-aux/missing build-aux/test-driver build-aux/texinfo.tex doc/coreutils.info doc/stamp-vti doc/version.texi gnulib-tests/Makefile.in po/Makefile.in.in
Diffstat (limited to 'tests/du')
-rwxr-xr-xtests/du/2g.sh29
-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-v2.sh38
-rwxr-xr-xtests/du/bind-mount-dir-cycle.sh2
-rwxr-xr-xtests/du/deref-args.sh2
-rwxr-xr-xtests/du/deref.sh4
-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.sh2
-rwxr-xr-xtests/du/long-from-unreadable.sh2
-rwxr-xr-xtests/du/long-sloop.sh2
-rwxr-xr-xtests/du/max-depth.sh2
-rwxr-xr-xtests/du/move-dir-while-traversing.sh9
-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-xtests/du/threshold.sh8
-rwxr-xr-xtests/du/trailing-slash.sh2
-rwxr-xr-xtests/du/two-args.sh2
29 files changed, 92 insertions, 44 deletions
diff --git a/tests/du/2g.sh b/tests/du/2g.sh
index f766d4d9..12c2eede 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2005-2015 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
@@ -24,7 +24,6 @@ print_ver_ du
# Creating a 2GB file counts as 'very expensive'.
very_expensive_
-
# Get number of free kilobytes on current partition, so we can
# skip this test if there is insufficient free space.
free_kb=$(df -k --output=avail . | tail -n1)
@@ -42,16 +41,22 @@ test $min_kb -lt $free_kb ||
}
big=big
-rm -f $big
-test -t 1 || printf 'creating a 2GB file...\n'
-for i in $(seq 100); do
- # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
- printf %21474836s x >> $big || fail=1
- # On the final iteration, append the remaining 48 bytes.
- test $i = 100 && { printf %48s x >> $big || fail=1; }
- test -t 1 && printf 'creating a 2GB file: %d%% complete\r' $i
-done
-echo
+
+if ! fallocate -l2G $big; then
+ rm -f $big
+ {
+ is_local_dir_ . || skip 'Not writing 2GB data to remote'
+ for i in $(seq 100); do
+ # Note: 2147483648 == 2^31. Print floor(2^31/100) per iteration.
+ printf %21474836s x || fail=1
+ done
+ # After the final iteration, append the remaining 48 bytes.
+ printf %48s x || fail=1
+ } > $big || fail=1
+fi
+
+# The allocation may be done asynchronously (BTRFS for example)
+sync $big || framework_failure_
du -k $big > out1 || fail=1
rm -f $big
diff --git a/tests/du/8gb.sh b/tests/du/8gb.sh
index 399fe7e5..696dd9f0 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 75bc9be1..b14a1b41 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 eebdeb04..ad484f81 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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-v2.sh b/tests/du/bind-mount-dir-cycle-v2.sh
new file mode 100755
index 00000000..f897098e
--- /dev/null
+++ b/tests/du/bind-mount-dir-cycle-v2.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Check that du can handle sub-bind-mounts cycles as well.
+
+# Copyright (C) 2014-2015 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
+require_root_
+
+cleanup_() { umount a/b/c; }
+
+mkdir -p a/b/c || framework_failure_
+mount --bind a a/b/c \
+ || skip_ 'This test requires mount with a working --bind option.'
+
+echo a/b/c > exp || framework_failure_
+echo a/b >> exp || framework_failure_
+
+du a/b > out 2> err || fail=1
+sed 's/^[0-9][0-9]* //' out > k && mv k out
+
+compare /dev/null err || fail=1
+compare exp out || fail=1
+
+Exit $fail
diff --git a/tests/du/bind-mount-dir-cycle.sh b/tests/du/bind-mount-dir-cycle.sh
index ac6bf2e2..88ae057a 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2012-2015 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-args.sh b/tests/du/deref-args.sh
index 50e525a1..d35fe5bb 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 543b7395..6c2a4724 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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
@@ -34,7 +34,7 @@ ln -s nowhere dangle || framework_failure_
du -sD slink b > /dev/null 2>&1 || fail=1
# This used to fail to report the dangling symlink.
-du -L dangle > /dev/null 2>&1 && fail=1
+returns_ 1 du -L dangle > /dev/null 2>&1 || fail=1
# du -L used to mess up, either by counting the symlink's disk space itself
# (-L should follow symlinks, not count their space)
diff --git a/tests/du/exclude.sh b/tests/du/exclude.sh
index 26ba598e..c738a7a0 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 ba8518e1..51eff9b4 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 67088434..2f55c4ed 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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 13c03c0c..3854059f 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2015 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 1d431e4c..66287aed 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 578237c3..749ad246 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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 4c053909..048fe774 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2007-2015 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 663e0401..e5a6549f 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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
index 6d2c28bb..384eaf69 100755
--- a/tests/du/inodes.sh
+++ b/tests/du/inodes.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# exercise du's --inodes option
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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/long-from-unreadable.sh b/tests/du/long-from-unreadable.sh
index e343bb56..4081eca2 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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/long-sloop.sh b/tests/du/long-sloop.sh
index 5168ac00..9c325b6d 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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 4d201095..25ad4689 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2015 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 046dad90..67bb3458 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2015 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
@@ -71,14 +71,17 @@ for i in $(seq 50); do
mkdir -p $t/3/a/b/c/$i/$long || framework_failure_
done
+# Terminate any background cp process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
# Prohibit suspension, which could otherwise cause a timeout-induced FP failure.
trap '' TSTP
-timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg &
+timeout 6 ./inotify-watch-for-dir-access.py $t/3/a/b > start-msg & pid=$!
# Wait for the watcher to start...
nonempty() { test -s start-msg || { sleep $1; return 1; }; }
-retry_delay_ nonempty .1 5
+retry_delay_ nonempty .1 5 || fail=1
# The above watches for an IN_OPEN event on $t/3/a/b,
# and when it triggers, moves the parent, $t/3/a, up one level
diff --git a/tests/du/no-deref.sh b/tests/du/no-deref.sh
index 0708bd35..1388f5d0 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 625eb96a..c035e3f2 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 db18d9b7..ab42286b 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 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 605399e4..aa05557b 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 3073cb1b..87e280b7 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2015 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 1985a6be..a4e488ae 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2013-2015 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
@@ -102,9 +102,11 @@ du --threshold= a > out 2>&1 && fail=1
compare exp out || fail=1
# Exercise a bad argument: no argument.
-du --threshold > out 2>&1 && fail=1
+du --threshold > out.tmp 2>&1 && fail=1
+sed 's/argument.*/argument/; s/option.*requires/option requires/' \
+ < out.tmp > out || framework_failure_
cat <<EOF > exp
-du: option '--threshold' requires an argument
+du: option requires an argument
Try 'du --help' for more information.
EOF
compare exp out || fail=1
diff --git a/tests/du/trailing-slash.sh b/tests/du/trailing-slash.sh
index d6a935ad..42eb9116 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 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 b5ec3024..999774f3 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-2014 Free Software Foundation, Inc.
+# Copyright (C) 2000-2015 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