]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
common/dm: add script file for device-mapper functions
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 18 Jul 2023 06:01:41 +0000 (15:01 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 19 Jul 2023 06:28:02 +0000 (15:28 +0900)
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 [new file with mode: 0644]
tests/zbd/rc

diff --git a/common/dm b/common/dm
new file mode 100644 (file)
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
+}
index 2e370f056ea20209cdd14f594b87f38e59088e7e..ffe3f6cb8a74c4e8b2cfd3c43459489f259ee675 100644 (file)
@@ -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() {