On 08/08/2012 05:07 PM, Jim Meyering wrote:
> Bernhard Voelker wrote:
>
>> On 08/08/2012 05:43 PM, Pádraig Brady wrote:
>>
>>> +require_mount_list_()
>>> +{
>>> + df >/dev/null 2>&1 ||
>>> + skip_ "Unable to read the list of mounted file systems."
>>> +}
>>> +
>>
>> Hmm, I think this is not enough: df can also fail due to other reasons,
>> e.g. when a mount point is not reachable by the user:
>>
>> $ src/df > /dev/null ; echo $?
>> src/df: ‘/root/backup’: Permission denied
>> 1
>
> Good point.
>
> "df ." or "df /" should be more reliable.
But then it won't fail. It's tricky :)
Updated version that explicitly matches the error is attached.
cheers,
Pádraig.
From e436551ee34fd7efd59d3fce21378161dea2e404 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Wed, 8 Aug 2012 16:38:38 +0100
Subject: [PATCH] tests: fix validation of local file systems
* tests/init.cfg (require_mount_list_): A new function
to ensure we can read the list of file systems.
(require_local_dir_): Call the above function as otherwise
the check is invalid.
* tests/df/total-unprocessed: Ensure df can read the
list of mounted file systems so that --local can be honored.
---
tests/df/total-unprocessed | 3 ++-
tests/init.cfg | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/tests/df/total-unprocessed b/tests/df/total-unprocessed
index 9742591..aa49836 100755
--- a/tests/df/total-unprocessed
+++ b/tests/df/total-unprocessed
@@ -19,6 +19,7 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ df
+require_mount_list_
cat <<\EOF > exp || framework_failure_
df: no file systems processed
@@ -27,7 +28,7 @@ EOF
# The following simply finds no match for the combination
# of the options --local and FS-type nfs together with the
# argument ".". It must exit non-Zero nonetheless.
-df --local -t nfs --total "." 2>out && fail=1
+df --local -t nfs --total '.' 2>out && fail=1
compare exp out || fail=1
cat <<\EOF > exp || framework_failure_
diff --git a/tests/init.cfg b/tests/init.cfg
index 506c9b3..2568e14 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -77,8 +77,16 @@ is_local_dir_()
df --local "$1" >/dev/null 2>&1
}
+require_mount_list_()
+{
+ mount_list_fail='cannot read table of mounted file systems'
+ df 2>&1 | grep -F "$mount_list_fail" >/dev/null &&
+ skip_ "$mount_list_fail"
+}
+
require_local_dir_()
{
+ require_mount_list_
is_local_dir_ . ||
skip_ "This test must be run on a local file system."
}
--
1.7.6.4