The previous commit introduced the test_device_array() function which allows a test case to use multiple block devices. Describe how to implement it in the 'new' script. Also describe how to specify test target block devices in Documentation/running-tests.md. This reverts commit 5623805f5a07ea0be4c3916ec68301c469aee843. --- Documentation/running-tests.md | 14 ++++++++++++++ new | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index a42fc91..f037634 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -42,6 +42,20 @@ If `TEST_DEVS` is not defined or is empty, only tests which do not require a device will be run. If `TEST_DEVS` is defined as a normal variable instead of an array, it will be converted to an array by splitting on whitespace. +Some test cases require multiple block devices for single test run. These test +cases implement a special test function test_device_array(). TEST_CASE_DEV_ARRAY +is an associative array which defines test devices for such test cases. In this +array, each key represents a test case name or a regular expression to match +test case names. Each key's corresponding value is a list of devices associated +with the test case. The test cases run for all of the devices specified in the +list. Again, note that tests are destructive and will overwrite any data on +these devices. + +```sh +TEST_CASE_DEV_ARRAY[md/003]="/dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1" +TEST_CASE_DEV_ARRAY[meta/02*]="/dev/nvme0n1 /dev/nvme1n1" +``` + ### Excluding Tests diff --git a/new b/new index d84f01d..df4092c 100755 --- a/new +++ b/new @@ -245,6 +245,15 @@ DESCRIPTION="" # is a partition device (e.g., # /sys/block/sda/sda1). If the device is not a # partition, this is an empty string. +# +# Tests that require multiple test devices should rename test() to +# test_device_array(). These tests will be run with variables defined below +# instead of TEST_DEV and TEST_DEV_SYSFS: +# - \$TEST_DEV_ARRAY -- the block devices to run the test on. The devices are +# taken from TEST_CASE_DEV_ARRAY defined in the config. +# - \$TEST_DEV_ARRAY_SYSFS -- the sysfs directories of the devices in the +# form of an associative array. Use values in +# TEST_DEV_ARRAY as the keys. test() { echo "Running \${TEST_NAME}" -- 2.51.0