[PATCH blktests 1/6] check, common/rc: save sysfs attribute path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 check     | 10 +++++-----
 common/rc | 12 +++++++-----
 2 files changed, 12 insertions(+), 10 deletions(-)

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() {
-- 
2.40.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux