common/rc: Enhance _exclude_scratch_mount_option to handle multiple options
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 8 Sep 2016 02:52:21 +0000 (10:52 +0800)
committerEryu Guan <eguan@redhat.com>
Thu, 8 Sep 2016 06:10:57 +0000 (14:10 +0800)
Enhance _exclude_scratch_mount_option() function to normalize mount
options. Now it can understand and extract real mount option from
string like "-o opt1,opt2 -oopt3".

And now we do word grep to handle mount options like noinode_cache
and inode_cache.

Finally, allow it to accept multiple options at the same time. No
need for multiple _exclude_scratch_mount_option lines now

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc
tests/ext4/271
tests/xfs/134

index 899bef49c61e346c503027737b855aff758df8d3..505e82395b74f3547535a9586ccefdb88e747105 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3192,12 +3192,25 @@ _require_cloner()
                _notrun "cloner binary not present at $CLONER_PROG"
 }
 
-# skip test if MKFS_OPTIONS contains the given string
+# Normalize mount options from global $MOUNT_OPTIONS
+# Convert options like "-o opt1,opt2 -oopt3" to
+# "opt1 opt2 opt3"
+_normalize_mount_options()
+{
+       echo $MOUNT_OPTIONS | sed -n 's/-o\s*\(\S*\)/\1/gp'| sed 's/,/ /g'
+}
+
+# skip test if MOUNT_OPTIONS contains the given strings
 _exclude_scratch_mount_option()
 {
-       if echo $MOUNT_OPTIONS | grep -q "$1"; then
-               _notrun "mount option \"$1\" not allowed in this test"
-       fi
+       local mnt_opts=$(_normalize_mount_options)
+
+       while [ $# -gt 0 ]; do
+               if echo $mnt_opts | grep -qw "$1"; then
+                       _notrun "mount option \"$1\" not allowed in this test"
+               fi
+               shift
+       done
 }
 
 _require_atime()
index 8674090ed815efe5339d5868c93f99c3eaf77c1f..6f61e51e865fd15a2680ec6ad01e6685058a0c04 100755 (executable)
@@ -41,10 +41,8 @@ _supported_os Linux
 _require_scratch
 # this test needs no journal to be loaded, skip on journal related mount
 # options, otherwise mount would fail with "-o noload" mount option
-_exclude_scratch_mount_option "data="
-_exclude_scratch_mount_option "commit="
-_exclude_scratch_mount_option "journal_checksum"
-_exclude_scratch_mount_option "journal_async_commit"
+_exclude_scratch_mount_option "data" "commit" "journal_checksum" \
+                             "journal_async_commit"
 
 rm -f $seqres.full
 _scratch_mkfs_sized $((128 * 1024 * 1024)) >> $seqres.full 2>&1
index b3a110732dd49aa9869eba910dae1fb0568c33ed..21fe1edd988920be87af3fe7ed43d449fdb4bc02 100755 (executable)
@@ -51,8 +51,7 @@ _supported_os Linux IRIX
 _require_test
 _require_xfs_quota
 # we can't run with group quotas
-_exclude_scratch_mount_option "gquota"
-_exclude_scratch_mount_option "grpquota"
+_exclude_scratch_mount_option "gquota" "grpquota"
 
 dir=$SCRATCH_MNT/project