[dpdk-dev,v2,02/15] devargs: fix unittest

Message ID 20170714211213.34436-3-jblunck@infradead.org (mailing list archive)
State Rejected, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jan Blunck July 14, 2017, 9:12 p.m. UTC
  Since the scan-mode of the bus is now based on the bus configuration it
isn't possible to have blacklisted and whitelisted devices existing for
the same bus. This fixes the unittest to reflect that.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
---
 test/test/test_devargs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Comments

Ferruh Yigit Sept. 4, 2017, 4:05 p.m. UTC | #1
On 7/14/2017 10:12 PM, Jan Blunck wrote:
> Since the scan-mode of the bus is now based on the bus configuration it
> isn't possible to have blacklisted and whitelisted devices existing for
> the same bus. This fixes the unittest to reflect that.
> 
> Signed-off-by: Jan Blunck <jblunck@infradead.org>
> ---
>  test/test/test_devargs.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
> index 18f54edc1..02fec8b1f 100644
> --- a/test/test/test_devargs.c
> +++ b/test/test/test_devargs.c
> @@ -68,13 +68,15 @@ test_devargs(void)
>  		goto fail;
>  	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)

[1] see below.

>  		goto fail;
> -	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
> +	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val")
> +		== 0)

Although as comment said, bus scan policy only can be whitelist or
blacklist, and previous call sets it to whitelist [1], this API call
doesn't return error. So changing its return type will fail the unittest.

Fix can be changing type to whitelist, and update count to 4 in below
check [2]. And keep blacklist count 0 [3].

>  		goto fail;
> -	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
> +	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1")
> +		== 0)
>  		goto fail;
>  	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
>  		goto fail;

[2]

> -	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
> +	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0)
>  		goto fail;

[3]

>  	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
>  		goto fail;
>
  

Patch

diff --git a/test/test/test_devargs.c b/test/test/test_devargs.c
index 18f54edc1..02fec8b1f 100644
--- a/test/test/test_devargs.c
+++ b/test/test/test_devargs.c
@@ -68,13 +68,15 @@  test_devargs(void)
 		goto fail;
 	if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, "0000:5:00.0") < 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "04:00.0,arg=val")
+		== 0)
 		goto fail;
-	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1") < 0)
+	if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, "0000:01:00.1")
+		== 0)
 		goto fail;
 	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 2)
 		goto fail;
-	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 2)
+	if (rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0)
 		goto fail;
 	if (rte_eal_devargs_type_count(RTE_DEVTYPE_VIRTUAL) != 0)
 		goto fail;