diff mbox

[v2,2/4] common/rc: support checking the version of dm-target in _require_dm_target()

Message ID 20171108080250.5662-3-houtao1@huawei.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Hou Tao Nov. 8, 2017, 8:02 a.m. UTC
Some features of dm-target are not available on the old linux kernel,
and we can use the version of dm-target to check the availability.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
 common/rc | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

Comments

Eryu Guan Nov. 8, 2017, 9:49 a.m. UTC | #1
On Wed, Nov 08, 2017 at 04:02:48PM +0800, Hou Tao wrote:
> Some features of dm-target are not available on the old linux kernel,
> and we can use the version of dm-target to check the availability.

We don't check version numbers in fstests, but actually try what is
requested and _notrun if the test run failed.

I think we can keep _require_dm_target unchanged and add a new
_require_dmflakey_error_writes in common/dmflakey, e.g.

_require_dmflakey_error_writes()
{
	_require_dm_targets flakey

	<try creating flakey table with error_writes option here and
	_notrun if failed>
}

And call this new _require rule in the test.

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hou Tao Nov. 8, 2017, 1:39 p.m. UTC | #2
Hi,

On 2017/11/8 17:49, Eryu Guan wrote:
> On Wed, Nov 08, 2017 at 04:02:48PM +0800, Hou Tao wrote:
>> Some features of dm-target are not available on the old linux kernel,
>> and we can use the version of dm-target to check the availability.
> 
> We don't check version numbers in fstests, but actually try what is
> requested and _notrun if the test run failed.

OK.

> I think we can keep _require_dm_target unchanged and add a new
> _require_dmflakey_error_writes in common/dmflakey, e.g.
> 
> _require_dmflakey_error_writes()
> {
> 	_require_dm_targets flakey
> 
> 	<try creating flakey table with error_writes option here and
> 	_notrun if failed>
> }
> 
> And call this new _require rule in the test.

Will do it.

Thanks.
Tao

> Thanks,
> Eryu
> 
> .
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/common/rc b/common/rc
index e2a8229..9ea84ba 100644
--- a/common/rc
+++ b/common/rc
@@ -1779,10 +1779,12 @@  _require_sane_bdev_flush()
 	fi
 }
 
-# this test requires a specific device mapper target
+# this test requires a specific device mapper target and
+# an optional version number (e.g., 1.4.0)
 _require_dm_target()
 {
-	_target=$1
+	local target=$1
+	local version=$2
 
 	# require SCRATCH_DEV to be a valid block device with sane BLKFLSBUF
 	# behaviour
@@ -1790,11 +1792,38 @@  _require_dm_target()
 	_require_sane_bdev_flush $SCRATCH_DEV
 	_require_command "$DMSETUP_PROG" dmsetup
 
-	modprobe dm-$_target >/dev/null 2>&1
+	modprobe dm-$target >/dev/null 2>&1
 
-	$DMSETUP_PROG targets 2>&1 | grep -q ^$_target
+	$DMSETUP_PROG targets 2>&1 | grep -q ^$target
 	if [ $? -ne 0 ]; then
-		_notrun "This test requires dm $_target support"
+		_notrun "This test requires dm $target support"
+	fi
+
+	if [ -n "$version" ]; then
+		local got
+
+		got=$($DMSETUP_PROG targets 2>&1 | \
+				awk -v tgt=$target '$0 ~ tgt {sub("v", "", $2); print $2}')
+		if [ -z "$got" ]; then
+			_notrun "This test requires dm $target $version at least (got unknown)"
+		fi
+
+		awk -v min=$version -v got=$got '
+		BEGIN \
+		{
+			cmin = split(min, amin, ".");
+			cgot = split(got, agot, ".");
+			for (i = 1; i <= cgot && i <= cmin; i++) {
+				if (agot[i] != amin[i]) {
+					exit(agot[i] < amin[i]);
+				}
+			}
+			exit(cgot < cmin);
+		}
+		'
+		if [ $? -ne 0 ]; then
+			_notrun "This test requires dm $target $version at least (got $got)"
+		fi
 	fi
 }