]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
check, common/rc: save sysfs attribute path
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 18 Jul 2023 07:19:03 +0000 (16:19 +0900)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 19 Jul 2023 06:26:43 +0000 (15:26 +0900)
Current implementation saves sysfs attributes under queue/ directory
in the associative array TEST_DEV_QUEUE_SAVED using attribute file names
as keys. The saved attributes are restored after each test case run.
When TEST_DEV is a device-mapper, this attribute restore does not cover
attributes of device-mapper destination devices. As a preparation to
cover the destination devices, use path of the attributes as keys
instead of file names. Also rename the associative array
TEST_DEV_QUEUE_SAVED to SYSFS_QUEUE_SAVED.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
check
common/rc

diff --git a/check b/check
index 8eaf5c65167cbd2107decda4e7716a8ffc7b083a..e5697c63417091947ca659e583da1673a69ecf5f 100755 (executable)
--- a/check
+++ b/check
@@ -314,10 +314,10 @@ _cleanup() {
        fi
 
        local key value
-       for key in "${!TEST_DEV_QUEUE_SAVED[@]}"; do
-               value="${TEST_DEV_QUEUE_SAVED["$key"]}"
-               echo "$value" >"${TEST_DEV_SYSFS}/queue/${key}"
-               unset "TEST_DEV_QUEUE_SAVED[$key]"
+       for key in "${!SYSFS_QUEUE_SAVED[@]}"; do
+               value="${SYSFS_QUEUE_SAVED["$key"]}"
+               echo "$value" >"${key}"
+               unset "SYSFS_QUEUE_SAVED[$key]"
        done
 
        if [[ "${RESTORE_CPUS_ONLINE:-}" ]]; then
@@ -336,7 +336,7 @@ _call_test() {
        local seqres="${RESULTS_DIR}/${TEST_NAME}"
        # shellcheck disable=SC2034
        FULL="${seqres}.full"
-       declare -A TEST_DEV_QUEUE_SAVED
+       declare -A SYSFS_QUEUE_SAVED
 
        declare -A LAST_TEST_RUN
        _read_last_test_run
index 90122c034d332fbf438c40ee654dbeef5cb8af74..4984100108402ffbcee16094904261b6183233de 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -284,12 +284,14 @@ _test_dev_queue_get() {
 }
 
 _test_dev_queue_set() {
-       # For bash >=4.3 we'd write if [[ ! -v TEST_DEV_QUEUE_SAVED["$1"] ]].
-       if [[ -z ${TEST_DEV_QUEUE_SAVED["$1"]} &&
-             ${TEST_DEV_QUEUE_SAVED["$1"]-unset} == unset ]]; then
-               TEST_DEV_QUEUE_SAVED["$1"]="$(_test_dev_queue_get "$1")"
+       local path="${TEST_DEV_SYSFS}/queue/$1"
+
+       # For bash >=4.3 we'd write if [[ ! -v SYSFS_QUEUE_SAVED["$path"] ]].
+       if [[ -z ${SYSFS_QUEUE_SAVED["$path"]} &&
+             ${SYSFS_QUEUE_SAVED["$path"]-unset} == unset ]]; then
+               SYSFS_QUEUE_SAVED["$path"]="$(_test_dev_queue_get "$1")"
        fi
-       echo "$2" >"${TEST_DEV_SYSFS}/queue/$1"
+       echo "$2" >"$path"
 }
 
 _require_test_dev_is_pci() {