[parted-devel] [PATCH v2] tests: skip tests requiring mkfs.hfs if it is not available

Jim Meyering jim at meyering.net
Tue Mar 2 10:57:32 UTC 2010


Petr Uzel wrote:

> Testsuite fails if mkfs.hfs is not installed on the system.
> * tests/t-lib.sh (require_hfs_): New function.
> * tests/t3000-resize-fs.sh: Use require_hfs_
> ---
>  tests/t-lib.sh           |    6 ++++++
>  tests/t3000-resize-fs.sh |    1 +
>  2 files changed, 7 insertions(+), 0 deletions(-)
>
> diff --git a/tests/t-lib.sh b/tests/t-lib.sh
> index 73454ce..50c7c91 100644
> --- a/tests/t-lib.sh
> +++ b/tests/t-lib.sh
> @@ -54,6 +54,12 @@ require_acl_()
>      || skip_test_ "This test requires a local user named bin."
>  }
>
> +require_hfs_()
> +{
> +  ( mkfs.hfs 2>&1 | grep '^usage:' ) > /dev/null \
> +    || skip_test_ "This test requires HFS support."
> +}
> +
>  # Skip this test if we're not in SELinux "enforcing" mode.
>  require_selinux_enforcing_()
>  {
> diff --git a/tests/t3000-resize-fs.sh b/tests/t3000-resize-fs.sh
> index d6af67d..4d0f5cb 100755
> --- a/tests/t3000-resize-fs.sh
> +++ b/tests/t3000-resize-fs.sh
> @@ -23,6 +23,7 @@ fi
>
>  : ${srcdir=.}
>  . $srcdir/t-lib.sh
> +require_hfs_
>
>  require_root_
>  require_scsi_debug_module_

Thank you.
I've applied that with a minor change:
There's no need to run the mkfs.hfs in a sub-shell
since all test-related output (except that generated
by e.g., skip_test_) merely ends up in the .log files.
Even allowing grep's output to reach the .log can be
considered a feature, since it shows us that part of what
mkfs.hfs actually printed.


diff --git a/tests/t-lib.sh b/tests/t-lib.sh
index 50c7c91..834a017 100644
--- a/tests/t-lib.sh
+++ b/tests/t-lib.sh
@@ -56,7 +56,7 @@ require_acl_()

 require_hfs_()
 {
-  ( mkfs.hfs 2>&1 | grep '^usage:' ) > /dev/null \
+  mkfs.hfs 2>&1 | grep '^usage:' \
     || skip_test_ "This test requires HFS support."
 }



More information about the parted-devel mailing list