From: Omar Sandoval Date: Tue, 18 Dec 2018 20:15:56 +0000 (-0800) Subject: scsi/006: allow changing cache_type to fail X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b0ef2aaa0f94ffe5a5f93bb2cb5e736eb757c8b4;p=users%2Fsagi%2Fblktests.git scsi/006: allow changing cache_type to fail Some devices don't support all cache types. Allow setting the cache type to fail with EINVAL. On success, make sure it was changed to the desired value. Signed-off-by: Omar Sandoval --- diff --git a/tests/scsi/006 b/tests/scsi/006 index bccb6d6..f220f61 100755 --- a/tests/scsi/006 +++ b/tests/scsi/006 @@ -9,7 +9,6 @@ . tests/scsi/rc DESCRIPTION="toggle SCSI cache type" - QUICK=1 device_requires() { @@ -25,15 +24,24 @@ test_device() { "write back" "write back, no read (daft)" ) - local cache_type + local cache_type_paths + local cache_type_path local original_cache_type + local cache_type - original_cache_type="$(cat "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type)" + cache_type_paths=("${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type) + cache_type_path="${cache_type_paths[0]}" + original_cache_type="$(cat "$cache_type_path")" for cache_type in "${cache_types[@]}"; do - echo "$cache_type" > "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type - cat "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type + echo "$cache_type" + ( echo "$cache_type" > "$cache_type_path" ) |& grep -v "Invalid argument" + if [[ ${PIPESTATUS[0]} -eq 0 ]]; then + # If setting the cache type succeeded, it should now + # contain the new cache type. + grep -Fxv "$cache_type" "$cache_type_path" + fi done - echo "$original_cache_type" > "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type + ( echo "$original_cache_type" > "$cache_type_path" ) |& grep -v "Invalid argument" echo "Test complete" }