From: Shin'ichiro Kawasaki Date: Tue, 18 Jul 2023 06:01:41 +0000 (+0900) Subject: common/dm: add script file for device-mapper functions X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a9f55a20b328692743edf4c909de246ba4fad472;p=users%2Fsagi%2Fblktests.git common/dm: add script file for device-mapper functions 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 --- 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() {