diff mbox series

[blktests,2/6] common/dm: add script file for device-mapper functions

Message ID 20230719071510.530623-3-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series fix failures with bio based device-mapper | expand

Commit Message

Shin'ichiro Kawasaki July 19, 2023, 7:15 a.m. UTC
Create a new script file common/dm and move two helper functions for
device-mapper from tests/zbd/rc.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/dm    | 23 +++++++++++++++++++++++
 tests/zbd/rc | 19 +------------------
 2 files changed, 24 insertions(+), 18 deletions(-)
 create mode 100644 common/dm
diff mbox series

Patch

diff --git a/common/dm b/common/dm
new file mode 100644
index 0000000..85e1ed9
--- /dev/null
+++ b/common/dm
@@ -0,0 +1,23 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2023 Western Digital Corporation or its affiliates.
+#
+# scsi_debug helper functions.
+
+_test_dev_is_dm() {
+	[[ -r "${TEST_DEV_SYSFS}/dm/name" ]]
+}
+
+# Get device file path from the device ID "major:minor".
+_get_dev_path_by_id() {
+	for d in /sys/block/* /sys/block/*/*; do
+		if [[ ! -r "${d}/dev" ]]; then
+			continue
+		fi
+		if [[ "${1}" == "$(<"${d}/dev")" ]]; then
+			echo "/dev/${d##*/}"
+			return 0
+		fi
+	done
+	return 1
+}
diff --git a/tests/zbd/rc b/tests/zbd/rc
index 2e370f0..ffe3f6c 100644
--- a/tests/zbd/rc
+++ b/tests/zbd/rc
@@ -6,6 +6,7 @@ 
 
 . common/rc
 . common/null_blk
+. common/dm
 
 #
 # Test requirement check functions
@@ -281,10 +282,6 @@  _find_two_contiguous_seq_zones() {
 	return 1
 }
 
-_test_dev_is_dm() {
-	[[ -r "${TEST_DEV_SYSFS}/dm/name" ]]
-}
-
 _require_test_dev_is_logical() {
 	if ! _test_dev_is_partition && ! _test_dev_is_dm; then
 		SKIP_REASONS+=("$TEST_DEV is not a logical device")
@@ -307,20 +304,6 @@  _test_dev_has_dm_map() {
 	return 0
 }
 
-# Get device file path from the device ID "major:minor".
-_get_dev_path_by_id() {
-	for d in /sys/block/* /sys/block/*/*; do
-		if [[ ! -r "${d}/dev" ]]; then
-			continue
-		fi
-		if [[ "${1}" == "$(<"${d}/dev")" ]]; then
-			echo "/dev/${d##*/}"
-			return 0
-		fi
-	done
-	return 1
-}
-
 # Given sector of TEST_DEV, return the device which contain the sector and
 # corresponding sector of the container device.
 _get_dev_container_and_sector() {