From: Shin'ichiro Kawasaki Date: Tue, 18 Jul 2023 07:19:03 +0000 (+0900) Subject: check, common/rc: save sysfs attribute path X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aaf5a4bc453c9faf6e6714e23c9c6b4972507488;p=users%2Fsagi%2Fblktests.git check, common/rc: save sysfs attribute path 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 --- diff --git a/check b/check index 8eaf5c6..e5697c6 100755 --- 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 diff --git a/common/rc b/common/rc index 90122c0..4984100 100644 --- 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() {