diff mbox series

[blktests] nvmeof-mp/001: Set expected count properly

Message ID 20220518034443.46803-1-yangx.jy@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [blktests] nvmeof-mp/001: Set expected count properly | expand

Commit Message

Xiao Yang May 18, 2022, 3:44 a.m. UTC
The number of block devices will increase according
to the number of RDMA-capable NICs.
For example, nvmeof-mp/001 with two RDMA-capable NICs
got the following error:
-------------------------------------
    Configured NVMe target driver
    -count_devices(): 1 <> 1
    +count_devices(): 2 <> 1
    Passed
-------------------------------------

Set expected count properly by calculating the number
of RDMA-capable NICs.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 tests/nvmeof-mp/001     | 7 +++++--
 tests/nvmeof-mp/001.out | 1 -
 2 files changed, 5 insertions(+), 3 deletions(-)

Comments

Bart Van Assche May 18, 2022, 11:54 a.m. UTC | #1
On 5/18/22 05:44, Xiao Yang wrote:
> The number of block devices will increase according
> to the number of RDMA-capable NICs.
> For example, nvmeof-mp/001 with two RDMA-capable NICs
> got the following error:
> -------------------------------------
>      Configured NVMe target driver
>      -count_devices(): 1 <> 1
>      +count_devices(): 2 <> 1
>      Passed
> -------------------------------------
> 
> Set expected count properly by calculating the number
> of RDMA-capable NICs.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Yi Zhang May 18, 2022, 12:03 p.m. UTC | #2
I also met this failure during my previous testing, thanks.

Reviewed-by: Yi Zhang <yi.zhang@redhat.com>

On Wed, May 18, 2022 at 11:44 AM Xiao Yang <yangx.jy@fujitsu.com> wrote:
>
> The number of block devices will increase according
> to the number of RDMA-capable NICs.
> For example, nvmeof-mp/001 with two RDMA-capable NICs
> got the following error:
> -------------------------------------
>     Configured NVMe target driver
>     -count_devices(): 1 <> 1
>     +count_devices(): 2 <> 1
>     Passed
> -------------------------------------
>
> Set expected count properly by calculating the number
> of RDMA-capable NICs.
>
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  tests/nvmeof-mp/001     | 7 +++++--
>  tests/nvmeof-mp/001.out | 1 -
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tests/nvmeof-mp/001 b/tests/nvmeof-mp/001
> index f3e6394..82cb298 100755
> --- a/tests/nvmeof-mp/001
> +++ b/tests/nvmeof-mp/001
> @@ -18,7 +18,11 @@ count_devices() {
>  }
>
>  wait_for_devices() {
> -       local expected=1 i devices
> +       local expected=0 i devices
> +
> +       for i in $(rdma_network_interfaces); do
> +               ((expected++))
> +       done
>
>         use_blk_mq y || return $?
>         for ((i=0;i<100;i++)); do
> @@ -27,7 +31,6 @@ wait_for_devices() {
>                 sleep .1
>         done
>         echo "count_devices(): $devices <> $expected" >>"$FULL"
> -       echo "count_devices(): $devices <> $expected"
>         [ "$devices" -ge $expected ]
>  }
>
> diff --git a/tests/nvmeof-mp/001.out b/tests/nvmeof-mp/001.out
> index 2ce8d17..a7d4cb9 100644
> --- a/tests/nvmeof-mp/001.out
> +++ b/tests/nvmeof-mp/001.out
> @@ -1,3 +1,2 @@
>  Configured NVMe target driver
> -count_devices(): 1 <> 1
>  Passed
> --
> 2.34.1
>
>
>
Shin'ichiro Kawasaki May 20, 2022, 9:37 a.m. UTC | #3
On May 18, 2022 / 11:44, Xiao Yang wrote:
> The number of block devices will increase according
> to the number of RDMA-capable NICs.
> For example, nvmeof-mp/001 with two RDMA-capable NICs
> got the following error:
> -------------------------------------
>     Configured NVMe target driver
>     -count_devices(): 1 <> 1
>     +count_devices(): 2 <> 1
>     Passed
> -------------------------------------
> 
> Set expected count properly by calculating the number
> of RDMA-capable NICs.
> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  tests/nvmeof-mp/001     | 7 +++++--
>  tests/nvmeof-mp/001.out | 1 -
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/nvmeof-mp/001 b/tests/nvmeof-mp/001
> index f3e6394..82cb298 100755
> --- a/tests/nvmeof-mp/001
> +++ b/tests/nvmeof-mp/001
> @@ -18,7 +18,11 @@ count_devices() {
>  }
>  
>  wait_for_devices() {
> -	local expected=1 i devices
> +	local expected=0 i devices
> +
> +	for i in $(rdma_network_interfaces); do
> +		((expected++))
> +	done
>  
>  	use_blk_mq y || return $?
>  	for ((i=0;i<100;i++)); do
> @@ -27,7 +31,6 @@ wait_for_devices() {
>  		sleep .1
>  	done
>  	echo "count_devices(): $devices <> $expected" >>"$FULL"
> -	echo "count_devices(): $devices <> $expected"
>  	[ "$devices" -ge $expected ]

The change looks good for me other than a nit: after applying this patch,
shellcheck complains:

$ make check
shellcheck -x -e SC2119 -f gcc check new common/* \
        tests/*/rc tests/*/[0-9]*[0-9]
tests/nvmeof-mp/001:30:20: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvmeof-mp/001:34:19: note: Double quote to prevent globbing and word splitting. [SC2086]

As the commit changes value of the variable $expected, its references need
double quotes:

diff --git a/tests/nvmeof-mp/001 b/tests/nvmeof-mp/001
index 82cb298..70a4455 100755
--- a/tests/nvmeof-mp/001
+++ b/tests/nvmeof-mp/001
@@ -27,11 +27,11 @@ wait_for_devices() {
        use_blk_mq y || return $?
        for ((i=0;i<100;i++)); do
                devices=$(count_devices)
-               [ "$devices" -ge $expected ] && break
+               [ "$devices" -ge "$expected" ] && break
                sleep .1
        done
        echo "count_devices(): $devices <> $expected" >>"$FULL"
-       [ "$devices" -ge $expected ]
+       [ "$devices" -ge "$expected" ]
 }

 test() {
Xiao Yang May 21, 2022, 12:27 p.m. UTC | #4
On 2022/5/20 17:37, Shinichiro Kawasaki wrote:
> The change looks good for me other than a nit: after applying this patch,
> shellcheck complains:
> 
> $ make check
> shellcheck -x -e SC2119 -f gcc check new common/* \
>          tests/*/rc tests/*/[0-9]*[0-9]
> tests/nvmeof-mp/001:30:20: note: Double quote to prevent globbing and word splitting. [SC2086]
> tests/nvmeof-mp/001:34:19: note: Double quote to prevent globbing and word splitting. [SC2086]
> 
> As the commit changes value of the variable $expected, its references need
> double quotes:

Hi Shinichiro,

Good catch. I will fix it as you suggested.

Best Regards,
Xiao Yang
diff mbox series

Patch

diff --git a/tests/nvmeof-mp/001 b/tests/nvmeof-mp/001
index f3e6394..82cb298 100755
--- a/tests/nvmeof-mp/001
+++ b/tests/nvmeof-mp/001
@@ -18,7 +18,11 @@  count_devices() {
 }
 
 wait_for_devices() {
-	local expected=1 i devices
+	local expected=0 i devices
+
+	for i in $(rdma_network_interfaces); do
+		((expected++))
+	done
 
 	use_blk_mq y || return $?
 	for ((i=0;i<100;i++)); do
@@ -27,7 +31,6 @@  wait_for_devices() {
 		sleep .1
 	done
 	echo "count_devices(): $devices <> $expected" >>"$FULL"
-	echo "count_devices(): $devices <> $expected"
 	[ "$devices" -ge $expected ]
 }
 
diff --git a/tests/nvmeof-mp/001.out b/tests/nvmeof-mp/001.out
index 2ce8d17..a7d4cb9 100644
--- a/tests/nvmeof-mp/001.out
+++ b/tests/nvmeof-mp/001.out
@@ -1,3 +1,2 @@ 
 Configured NVMe target driver
-count_devices(): 1 <> 1
 Passed