Skip to content

Commit b4a3a24

Browse files
committed
throtl: support test with both null_blk and scsi_debug in a single run
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/" Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent d91fa93 commit b4a3a24

9 files changed

Lines changed: 61 additions & 0 deletions

File tree

Documentation/running-tests.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ USE_RXE=1 ./check srp/
167167
'USE_RXE' had the old name 'use_rxe'. The old name is still usable but not
168168
recommended.
169169

170+
### Blk-throttle tests
171+
172+
The blk-throttle tests has one environment variable below:
173+
174+
- THROTL_BLKDEV_TYPES: 'nullb' 'sdebug'
175+
Set up test target block device based on this environment variable value. To
176+
test with null_blk, set 'nullb'. To test with scsi_debug, set 'sdebug'. To
177+
test with both, set 'nullb sdebug'. Default value is 'nullb sdebug'.
178+
179+
```sh
180+
To run with scsi_debug:
181+
THROTL_BLKDEV_TYPES="sdebug" ./check throtl/
182+
183+
To run with both null_blk and scsi_debug:
184+
THROTL_BLKDEV_TYPES="nullb sdebug" ./check throtl/
185+
```
186+
170187
### Normal user
171188

172189
To run test cases which require normal user privilege, prepare a user and

tests/throtl/001

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
DESCRIPTION="basic functionality"
1010
QUICK=1
1111

12+
set_conditions() {
13+
_set_throtl_blkdev_type "$@"
14+
}
15+
1216
test() {
1317
echo "Running ${TEST_NAME}"
1418

tests/throtl/002

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
DESCRIPTION="iops limit over IO split"
1111
QUICK=1
1212

13+
set_conditions() {
14+
_set_throtl_blkdev_type "$@"
15+
}
16+
1317
test() {
1418
echo "Running ${TEST_NAME}"
1519

tests/throtl/003

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
DESCRIPTION="bps limit over IO split"
1111
QUICK=1
1212

13+
set_conditions() {
14+
_set_throtl_blkdev_type "$@"
15+
}
16+
1317
test() {
1418
echo "Running ${TEST_NAME}"
1519

tests/throtl/004

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
DESCRIPTION="delete disk while IO is throttled"
1212
QUICK=1
1313

14+
set_conditions() {
15+
_set_throtl_blkdev_type "$@"
16+
}
17+
1418
test() {
1519
echo "Running ${TEST_NAME}"
1620

tests/throtl/005

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
DESCRIPTION="change config with throttled IO"
1111
QUICK=1
1212

13+
set_conditions() {
14+
_set_throtl_blkdev_type "$@"
15+
}
16+
1317
test() {
1418
echo "Running ${TEST_NAME}"
1519

tests/throtl/006

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ requires() {
1515
_have_driver ext4
1616
}
1717

18+
set_conditions() {
19+
_set_throtl_blkdev_type "$@"
20+
}
21+
1822
test_meta_io() {
1923
local path="$1"
2024
local start_time

tests/throtl/007

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
DESCRIPTION="bps limit with iops limit over io split"
1212
QUICK=1
1313

14+
set_conditions() {
15+
_set_throtl_blkdev_type "$@"
16+
}
17+
1418
test() {
1519
echo "Running ${TEST_NAME}"
1620

tests/throtl/rc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
. common/cgroup
1111

1212
THROTL_DIR=$(echo "$TEST_NAME" | tr '/' '_')
13+
THROTL_BLKDEV_TYPES=${THROTL_BLKDEV_TYPES:-"nullb sdebug"}
1314
throtl_blkdev_type=${throtl_blkdev_type:-"nullb"}
1415
THROTL_NULL_DEV=dev_nullb
1516
declare THROTL_DEV
@@ -25,6 +26,21 @@ group_requires() {
2526
_have_program bc
2627
}
2728

29+
_set_throtl_blkdev_type() {
30+
local index=$1
31+
local -a types
32+
33+
read -r -a types <<< "${THROTL_BLKDEV_TYPES[@]}"
34+
35+
if [[ -z $index ]]; then
36+
echo ${#types[@]}
37+
return
38+
fi
39+
40+
throtl_blkdev_type=${types[index]}
41+
COND_DESC="${throtl_blkdev_type}"
42+
}
43+
2844
# Prepare null_blk or scsi_debug device to test, based on throtl_blkdev_type.
2945
_configure_throtl_blkdev() {
3046
local sector_size=0 memory_backed=0

0 commit comments

Comments
 (0)