diff mbox series

[blktests,07/11] nvme/rc: introduce NVMET_BLKDEV_TYPES

Message ID 20240411111228.2290407-8-shinichiro.kawasaki@wdc.com (mailing list archive)
State New
Headers show
Series support test case repeat by different conditions | expand

Commit Message

Shin'ichiro Kawasaki April 11, 2024, 11:12 a.m. UTC
Some of the test cases in nvme test group do exact same test for two
blkdev types: deice type and file type. Except for this difference, the
test cases are pure duplication. It is desired to avoid the duplication.
When the duplication is avoided, still it is required to control which
condition to run the test.

To avoid the duplication and also to allow the blkdev type control,
introduce a new configuration parameter NVMET_BLKDEV_TYPES. This is an
array to hold default values (device file). Also add the helper function
_set_nvme_trtype_and_nvmet_blkdev_type(). It sets up nvmet_blkdev_type
variable for each test case run from NVMET_BLKDEV_TYPES. It also sets
nvme_trtype from NVMET_TR_TYPES.

When NVMET_BLKDEV_TYPES and NVMET_TR_TYPES are set as follows, the test
case with _set_nvme_trtype_and_nvmet_blkdev_type in set_condition() hook
is called 2 x 3 = 6 times.

  NVMET_BLKDEV_TYPES=(device file)
  NVMET_TR_TYPES=(loop rdma tcp)

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 Documentation/running-tests.md |  3 +++
 tests/nvme/rc                  | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

Comments

Daniel Wagner April 11, 2024, 6:44 p.m. UTC | #1
On Thu, Apr 11, 2024 at 08:12:24PM +0900, Shin'ichiro Kawasaki wrote:
> Some of the test cases in nvme test group do exact same test for two
> blkdev types: deice type and file type. Except for this difference, the
> test cases are pure duplication. It is desired to avoid the duplication.
> When the duplication is avoided, still it is required to control which
> condition to run the test.
> 
> To avoid the duplication and also to allow the blkdev type control,
> introduce a new configuration parameter NVMET_BLKDEV_TYPES. This is an
> array to hold default values (device file). Also add the helper function
> _set_nvme_trtype_and_nvmet_blkdev_type(). It sets up nvmet_blkdev_type
> variable for each test case run from NVMET_BLKDEV_TYPES. It also sets
> nvme_trtype from NVMET_TR_TYPES.
> 
> When NVMET_BLKDEV_TYPES and NVMET_TR_TYPES are set as follows, the test
> case with _set_nvme_trtype_and_nvmet_blkdev_type in set_condition() hook
> is called 2 x 3 = 6 times.
> 
>   NVMET_BLKDEV_TYPES=(device file)
>   NVMET_TR_TYPES=(loop rdma tcp)
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
>  Documentation/running-tests.md |  3 +++
>  tests/nvme/rc                  | 16 ++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
> index ede3a81..ca11f58 100644
> --- a/Documentation/running-tests.md
> +++ b/Documentation/running-tests.md
> @@ -108,6 +108,9 @@ The NVMe tests can be additionally parameterized via environment variables.
>  - nvme_trtype: 'loop' (default), 'tcp', 'rdma' and 'fc'
>    Run the tests with the given transport. This parameter is still usable but
>    replaced with NVMET_TR_TYPES. Use NVMET_TR_TYPES instead.
> +- NVMET_BLOCK_DEV_TYPES (array)

NVMET_BLKDEV_TYPES ?
Shin'ichiro Kawasaki April 12, 2024, 10:56 a.m. UTC | #2
On Apr 11, 2024 / 20:44, Daniel Wagner wrote:
> On Thu, Apr 11, 2024 at 08:12:24PM +0900, Shin'ichiro Kawasaki wrote:
> > Some of the test cases in nvme test group do exact same test for two
> > blkdev types: deice type and file type. Except for this difference, the
> > test cases are pure duplication. It is desired to avoid the duplication.
> > When the duplication is avoided, still it is required to control which
> > condition to run the test.
> > 
> > To avoid the duplication and also to allow the blkdev type control,
> > introduce a new configuration parameter NVMET_BLKDEV_TYPES. This is an
> > array to hold default values (device file). Also add the helper function
> > _set_nvme_trtype_and_nvmet_blkdev_type(). It sets up nvmet_blkdev_type
> > variable for each test case run from NVMET_BLKDEV_TYPES. It also sets
> > nvme_trtype from NVMET_TR_TYPES.
> > 
> > When NVMET_BLKDEV_TYPES and NVMET_TR_TYPES are set as follows, the test
> > case with _set_nvme_trtype_and_nvmet_blkdev_type in set_condition() hook
> > is called 2 x 3 = 6 times.
> > 
> >   NVMET_BLKDEV_TYPES=(device file)
> >   NVMET_TR_TYPES=(loop rdma tcp)
> > 
> > Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> > ---
> >  Documentation/running-tests.md |  3 +++
> >  tests/nvme/rc                  | 16 ++++++++++++++++
> >  2 files changed, 19 insertions(+)
> > 
> > diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
> > index ede3a81..ca11f58 100644
> > --- a/Documentation/running-tests.md
> > +++ b/Documentation/running-tests.md
> > @@ -108,6 +108,9 @@ The NVMe tests can be additionally parameterized via environment variables.
> >  - nvme_trtype: 'loop' (default), 'tcp', 'rdma' and 'fc'
> >    Run the tests with the given transport. This parameter is still usable but
> >    replaced with NVMET_TR_TYPES. Use NVMET_TR_TYPES instead.
> > +- NVMET_BLOCK_DEV_TYPES (array)
> 
> NVMET_BLKDEV_TYPES ?

That sounds better. Will rename to it.
diff mbox series

Patch

diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md
index ede3a81..ca11f58 100644
--- a/Documentation/running-tests.md
+++ b/Documentation/running-tests.md
@@ -108,6 +108,9 @@  The NVMe tests can be additionally parameterized via environment variables.
 - nvme_trtype: 'loop' (default), 'tcp', 'rdma' and 'fc'
   Run the tests with the given transport. This parameter is still usable but
   replaced with NVMET_TR_TYPES. Use NVMET_TR_TYPES instead.
+- NVMET_BLOCK_DEV_TYPES (array)
+  Set up NVME target backends with the specified block device type.
+  Valid elements are 'device' and 'file'. Default value is '(device file)'.
 - nvme_img_size: '1G' (default)
   Run the tests with given image size in bytes. 'm', 'M', 'g'
 	and 'G' postfix are supported.
diff --git a/tests/nvme/rc b/tests/nvme/rc
index d51f623..c1a14a1 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -21,6 +21,7 @@  export def_subsys_uuid="91fdba0d-f87b-4c25-b80f-db7be1418b9e"
 nvme_img_size=${nvme_img_size:-"1G"}
 nvme_num_iter=${nvme_num_iter:-"1000"}
 nvmet_blkdev_type=${nvmet_blkdev_type:-"device"}
+[[ -z $NVMET_BLKDEV_TYPES ]] && NVMET_BLKDEV_TYPES=(device file)
 
 # Check consistency of NVMET_TR_TYPES and nvme_trtype configurations.
 # If neither is configured, set the default value.
@@ -51,6 +52,21 @@  _set_nvme_trtype() {
 	COND_DESC="nvmet tr=${nvme_trtype}"
 }
 
+_set_nvme_trtype_and_nvmet_blkdev_type() {
+	local index=$1
+	local bd_index=$((index / ${#NVMET_TR_TYPES[@]}))
+	local tr_index=$((index % ${#NVMET_TR_TYPES[@]}))
+
+	if [[ -z $index ]]; then
+		echo $(( ${#NVMET_BLKDEV_TYPES[@]} * ${#NVMET_TR_TYPES[@]} ))
+		return
+	fi
+
+	nvmet_blkdev_type=${NVMET_BLKDEV_TYPES[bd_index]}
+	nvme_trtype=${NVMET_TR_TYPES[tr_index]}
+	COND_DESC="nvmet bd=${nvmet_blkdev_type} tr=${nvme_trtype}"
+}
+
 # TMPDIR can not be referred out of test() or test_device() context. Instead of
 # global variable def_flie_path, use this getter function.
 _nvme_def_file_path() {