The previous commit introduced the global variable throtl_blkdev_type to specify the type of block device for the throtl group. However, users need to run tests twice modifying the variable's value each time to test against both device types null_blk and scsi_debug. This workflow is cumbersome. To run the throtl group for both null_blk and scsi_debug in a single run, introduce the global variable THROTL_BLKDEV_TYPES instead of throtl_blkdev_type. When THROTL_BLKDEV_TYPES is set to 'nullb sdebug', the blktests framework executes each test case in the throtl group for both null_blk and scsi_debug sequentially. For this purpose, introduce the helper function _set_throtl_blkdev_type() and call it in set_conditions() hooks of the test cases. Each of the two command lines below runs the throtl group with both null_blk and scsi_debug. Please note that the default value of THROTL_BLKDEV_TYPES is 'nullb sdebug'. $ sudo bash -c "./check throtl/" $ sudo bash -c "THROTL_BLKDEV_TYPES='nullb sdebug' ./check throtl/" Each of the command lines below runs the throtl group only for null_blk or scsi_debug, respectively. $ sudo bash -c "THROTL_BLKDEV_TYPES='nullb' ./check throtl/" $ sudo bash -c "THROTL_BLKDEV_TYPES='sdebug' ./check throtl/" Signed-off-by: Shin'ichiro Kawasaki --- Documentation/running-tests.md | 17 +++++++++++++++++ tests/throtl/001 | 4 ++++ tests/throtl/002 | 4 ++++ tests/throtl/003 | 4 ++++ tests/throtl/004 | 4 ++++ tests/throtl/005 | 4 ++++ tests/throtl/006 | 4 ++++ tests/throtl/007 | 4 ++++ tests/throtl/rc | 16 ++++++++++++++++ 9 files changed, 61 insertions(+) diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index 8ccd739..4cf1a3a 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -167,6 +167,23 @@ USE_RXE=1 ./check srp/ 'USE_RXE' had the old name 'use_rxe'. The old name is still usable but not recommended. +### Blk-throttle tests + +The blk-throttle tests has one environment variable below: + +- THROTL_BLKDEV_TYPES: 'nullb' 'sdebug' + Set up test target block device based on this environment variable value. To + test with null_blk, set 'nullb'. To test with scsi_debug, set 'sdebug'. To + test with both, set 'nullb sdebug'. Default value is 'nullb sdebug'. + +```sh +To run with scsi_debug: +THROTL_BLKDEV_TYPES="sdebug" ./check throtl/ + +To run with both null_blk and scsi_debug: +THROTL_BLKDEV_TYPES="nullb sdebug" ./check throtl/ +``` + ### Normal user To run test cases which require normal user privilege, prepare a user and diff --git a/tests/throtl/001 b/tests/throtl/001 index 835cac2..89a5892 100755 --- a/tests/throtl/001 +++ b/tests/throtl/001 @@ -9,6 +9,10 @@ DESCRIPTION="basic functionality" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/002 b/tests/throtl/002 index 87b9f91..08e685f 100755 --- a/tests/throtl/002 +++ b/tests/throtl/002 @@ -10,6 +10,10 @@ DESCRIPTION="iops limit over IO split" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/003 b/tests/throtl/003 index d76a0d5..700e9e6 100755 --- a/tests/throtl/003 +++ b/tests/throtl/003 @@ -10,6 +10,10 @@ DESCRIPTION="bps limit over IO split" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/004 b/tests/throtl/004 index 777afcf..b1f6110 100755 --- a/tests/throtl/004 +++ b/tests/throtl/004 @@ -11,6 +11,10 @@ DESCRIPTION="delete disk while IO is throttled" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/005 b/tests/throtl/005 index 86e52b3..7691ad1 100755 --- a/tests/throtl/005 +++ b/tests/throtl/005 @@ -10,6 +10,10 @@ DESCRIPTION="change config with throttled IO" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/006 b/tests/throtl/006 index 263415f..2dcf3a3 100755 --- a/tests/throtl/006 +++ b/tests/throtl/006 @@ -15,6 +15,10 @@ requires() { _have_driver ext4 } +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test_meta_io() { local path="$1" local start_time diff --git a/tests/throtl/007 b/tests/throtl/007 index 83d8dc7..97dece6 100755 --- a/tests/throtl/007 +++ b/tests/throtl/007 @@ -11,6 +11,10 @@ DESCRIPTION="bps limit with iops limit over io split" QUICK=1 +set_conditions() { + _set_throtl_blkdev_type "$@" +} + test() { echo "Running ${TEST_NAME}" diff --git a/tests/throtl/rc b/tests/throtl/rc index f5eb84e..d1afefd 100644 --- a/tests/throtl/rc +++ b/tests/throtl/rc @@ -10,6 +10,7 @@ . common/cgroup THROTL_DIR=$(echo "$TEST_NAME" | tr '/' '_') +THROTL_BLKDEV_TYPES=${THROTL_BLKDEV_TYPES:-"nullb sdebug"} throtl_blkdev_type=${throtl_blkdev_type:-"nullb"} THROTL_NULL_DEV=dev_nullb declare THROTL_DEV @@ -25,6 +26,21 @@ group_requires() { _have_program bc } +_set_throtl_blkdev_type() { + local index=$1 + local -a types + + read -r -a types <<< "${THROTL_BLKDEV_TYPES[@]}" + + if [[ -z $index ]]; then + echo ${#types[@]} + return + fi + + throtl_blkdev_type=${types[index]} + COND_DESC="${throtl_blkdev_type}" +} + # Prepare null_blk or scsi_debug device to test, based on throtl_blkdev_type. _configure_throtl_blkdev() { local sector_size=0 memory_backed=0 -- 2.51.0