summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-08-02 18:52:40 +0200
committerJim Meyering <jim@meyering.net>2007-08-02 18:52:40 +0200
commitdf03463679a32c5f7cde99e6dea0acc8579a0cf6 (patch)
tree59f04d986ab589d3e889e72d6c1c26af55b7f017
parentfd9a6e860b7f196728a975599947a09a316be260 (diff)
downloadcoreutils-df03463679a32c5f7cde99e6dea0acc8579a0cf6.tar.xz
Adapt du's no-x test not to fail on older Linux systems.
* tests/du/no-x: Accept a third variant of the diagnostic.
-rw-r--r--ChangeLog5
-rwxr-xr-xtests/du/no-x29
2 files changed, 18 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d19371b1..40cf00bb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-02 Jim Meyering <jim@meyering.net>
+
+ Adapt du's no-x test not to fail on older Linux systems.
+ * tests/du/no-x: Accept a third variant of the diagnostic.
+
2007-07-31 Jim Meyering <jim@meyering.net>
du: print size (probably incomplete) of each inaccessible directory
diff --git a/tests/du/no-x b/tests/du/no-x
index 00aea6a34..f6b59974a 100755
--- a/tests/du/no-x
+++ b/tests/du/no-x
@@ -2,7 +2,7 @@
# Make sure du gives the right diagnostic for a readable,
# but inaccessible directory.
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2007 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
@@ -46,25 +46,22 @@ fail=0
# This must exit nonzero.
du d >/dev/null 2>out && fail=1
+# Depending on whether du/fts is using native fdopendir, we see one
+# of the following diagnostics (note also the /y suffix in one case):
+# du: `d/no-x': Permission denied
+# du: cannot access `d/no-x/y': Permission denied
+# du: cannot read directory `d/no-x': Permission denied
+# Convert either of the latter two to the first one.
+
+sed 's/^du: cannot access /du: /' out > t && mv t out
+sed 's/^du: cannot read directory /du: /' out > t && mv t out
+sed 's,d/no-x/y,d/no-x,' out > t && mv t out
+
cat <<\EOF > exp
du: `d/no-x': Permission denied
EOF
-# With native fdopendir, du uses a different code path.
-cat <<\EOF > exp-native-fdopendir
-du: cannot access `d/no-x/y': Permission denied
-EOF
-
-if cmp out exp >/dev/null 2>&1; then
- :
-else
- if cmp out exp-native-fdopendir; then
- :
- else
- fail=1
- fi
-fi
-
+cmp out exp || fail=1
test $fail = 1 && diff out exp 2> /dev/null
(exit $fail); exit $fail