common/rc: fix _require_xfs_io_command params check
authorAmir Goldstein <amir73il@gmail.com>
Wed, 23 Aug 2017 15:49:11 +0000 (18:49 +0300)
committerEryu Guan <eguan@redhat.com>
Thu, 31 Aug 2017 04:25:19 +0000 (12:25 +0800)
When _require_xfs_io_command is passed command parameters,
the resulting error from invalid parameters may be ignored.

For example, the following bogus params would not abort the test:
_require_xfs_io_command "falloc" "-X"
_require_xfs_io_command "fiemap" "-X"

Fix this by looking for the relevant error message.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc

index 9d7b78306b0df0f92fd96e95464e3bebdf102c5a..44b98f6f0445dd50530915388fb71cced371e7fb 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2212,9 +2212,14 @@ _require_xfs_io_command()
        echo $testio | grep -q "Function not implemented" && \
                _notrun "xfs_io $command support is missing (missing syscall?)"
 
-       if [ -n "$param" -a $param_checked -eq 0 ]; then
+       [ -n "$param" ] || return
+
+       if [ $param_checked -eq 0 ]; then
                $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
                        _notrun "xfs_io $command doesn't support $param"
+       else
+               echo $testio | grep -q "invalid option" && \
+                       _notrun "xfs_io $command doesn't support $param"
        fi
 }