diff mbox series

[net-next,v5,3/5] selftests: forwarding: add check_driver() helper

Message ID 20240422153303.3860947-3-jiri@resnulli.us (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series None | expand

Commit Message

Jiri Pirko April 22, 2024, 3:32 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

Add a helper to be used to check if the netdevice is backed by specified
driver.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
 tools/testing/selftests/net/forwarding/lib.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Benjamin Poirier April 22, 2024, 6:47 p.m. UTC | #1
On 2024-04-22 17:32 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Add a helper to be used to check if the netdevice is backed by specified
> driver.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> ---
>  tools/testing/selftests/net/forwarding/lib.sh | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 9d6802c6c023..00e089dd951d 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -278,10 +278,17 @@ check_port_mab_support()
>  	fi
>  }
>  
> -if [[ "$(id -u)" -ne 0 ]]; then
> -	echo "SKIP: need root privileges"
> -	exit $ksft_skip
> -fi

Why is the check being removed entirely? This change was not in v4 of
this patch. Did it happen unintentionally when removing "selftests:
forwarding: move initial root check to the beginning"?

> +check_driver()
> +{
> +	local dev=$1; shift
> +	local expected=$1; shift
> +	local driver_name=`driver_name_get $dev`
> +
> +	if [[ $driver_name != $expected ]]; then
> +		echo "SKIP: expected driver $expected for $dev, got $driver_name instead"
> +		exit $ksft_skip
> +	fi
> +}
>  
>  if [[ "$CHECK_TC" = "yes" ]]; then
>  	check_tc_version
> -- 
> 2.44.0
> 
>
Jiri Pirko April 23, 2024, 10:59 a.m. UTC | #2
Mon, Apr 22, 2024 at 08:47:39PM CEST, benjamin.poirier@gmail.com wrote:
>On 2024-04-22 17:32 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> Add a helper to be used to check if the netdevice is backed by specified
>> driver.
>> 
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>> Reviewed-by: Petr Machata <petrm@nvidia.com>
>> ---
>>  tools/testing/selftests/net/forwarding/lib.sh | 15 +++++++++++----
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>> 
>> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>> index 9d6802c6c023..00e089dd951d 100644
>> --- a/tools/testing/selftests/net/forwarding/lib.sh
>> +++ b/tools/testing/selftests/net/forwarding/lib.sh
>> @@ -278,10 +278,17 @@ check_port_mab_support()
>>  	fi
>>  }
>>  
>> -if [[ "$(id -u)" -ne 0 ]]; then
>> -	echo "SKIP: need root privileges"
>> -	exit $ksft_skip
>> -fi
>
>Why is the check being removed entirely? This change was not in v4 of
>this patch. Did it happen unintentionally when removing "selftests:
>forwarding: move initial root check to the beginning"?

Oh, a mistake.

I messed up the v5 submission, repost couple minutes ago but I missed
this comment. I will send v6 tomorrow.

Sorry!

>
>> +check_driver()
>> +{
>> +	local dev=$1; shift
>> +	local expected=$1; shift
>> +	local driver_name=`driver_name_get $dev`
>> +
>> +	if [[ $driver_name != $expected ]]; then
>> +		echo "SKIP: expected driver $expected for $dev, got $driver_name instead"
>> +		exit $ksft_skip
>> +	fi
>> +}
>>  
>>  if [[ "$CHECK_TC" = "yes" ]]; then
>>  	check_tc_version
>> -- 
>> 2.44.0
>> 
>>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 9d6802c6c023..00e089dd951d 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -278,10 +278,17 @@  check_port_mab_support()
 	fi
 }
 
-if [[ "$(id -u)" -ne 0 ]]; then
-	echo "SKIP: need root privileges"
-	exit $ksft_skip
-fi
+check_driver()
+{
+	local dev=$1; shift
+	local expected=$1; shift
+	local driver_name=`driver_name_get $dev`
+
+	if [[ $driver_name != $expected ]]; then
+		echo "SKIP: expected driver $expected for $dev, got $driver_name instead"
+		exit $ksft_skip
+	fi
+}
 
 if [[ "$CHECK_TC" = "yes" ]]; then
 	check_tc_version