summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-07-28 00:19:45 +0100
committerPádraig Brady <P@draigBrady.com>2013-07-28 00:26:57 +0100
commit012fbb63719f4a683604c4917a34d2039e38c023 (patch)
tree98fc585abb6c69e06b204a0df994af2576681354
parent333dc83d52e014a0b532e316ea8cd93b048f1ac6 (diff)
downloadcoreutils-012fbb63719f4a683604c4917a34d2039e38c023.tar.xz
tests: fix intermittent failure in test/du/inodes.sh
Prompted by the continuous integration build failure at: http://hydra.nixos.org/build/5582213 * test/du/inodes.sh: Due to undefined order in returned directory entries, the expected output might not match, so sort both expected and actual output when returning --all directory entries. Also use a simpler test for ensuring no errors are output.
-rwxr-xr-xtests/du/inodes.sh44
1 files changed, 24 insertions, 20 deletions
diff --git a/tests/du/inodes.sh b/tests/du/inodes.sh
index 2069e2b2b..41186e40f 100755
--- a/tests/du/inodes.sh
+++ b/tests/du/inodes.sh
@@ -25,7 +25,7 @@ printf '1\td\n' > exp || framework_failure_
du --inodes d > out 2>err || fail=1
compare exp out || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
# Add a regular file: 2 inodes used.
touch d/f || framework_failure_
@@ -33,62 +33,66 @@ printf '2\td\n' > exp || framework_failure_
du --inodes d > out 2>err || fail=1
compare exp out || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
# Count all items: 1-1-3.
-printf '1\td/d\n1\td/h\n3\td\n' > exp || framework_failure_
-du --inodes -a d > out 2>err || fail=1
+# Sort output becaue the directory entry order is not defined.
+printf '1\td/d\n1\td/h\n3\td\n' | sort > exp || framework_failure_
+du --inodes -a d > out.tmp 2>err || fail=1
+sort <out.tmp >out || framework_failure_
compare exp out || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
# Count all items and hardlinks again: 1-1-1-4
-printf '1\td/d\n1\td/h\n1\td/f\n4\td\n' > exp || framework_failure_
-du --inodes -al d > out 2>err || fail=1
+# 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
# Ensure human output (-h, --si) works.
rm -rf d || framework_failure_
@@ -97,28 +101,28 @@ 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
printf '1.1k\td\n' > exp || framework_failure_
du --inodes --si d > out 2>err || fail=1
compare exp out || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s 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 || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
du --inodes --threshold=-1000 d > out 2>err || fail=1
compare /dev/null out || { cat out; fail=1; }
-compare /dev/null err || fail=1
+test -s err && fail=1
# Verify --inodes raises a warning for --apparent-size and -b.
du --inodes -b d > out 2>err || fail=1