+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
# 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
# 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