diff mbox series

selftests: net: Add on/off checks for network interface non fixed features

Message ID 20240606212714.27472-1-jain.abhinav177@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series selftests: net: Add on/off checks for network interface non fixed features | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-07--09-00 (tests: 1041)

Commit Message

Abhinav Jain June 6, 2024, 9:27 p.m. UTC
This patch addresses the present TODO in the file.
I have tested it manually on my system and added relevant filtering to
ensure that the correct feature list is being checked.

Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
---
 tools/testing/selftests/net/netdevice.sh | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Comments

Simon Horman June 7, 2024, 6:01 p.m. UTC | #1
On Thu, Jun 06, 2024 at 09:27:14PM +0000, Abhinav Jain wrote:
> This patch addresses the present TODO in the file.
> I have tested it manually on my system and added relevant filtering to
> ensure that the correct feature list is being checked.
> 
> Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
> ---
>  tools/testing/selftests/net/netdevice.sh | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
> index e3afcb424710..cbe2573c3827 100755
> --- a/tools/testing/selftests/net/netdevice.sh
> +++ b/tools/testing/selftests/net/netdevice.sh
> @@ -117,14 +117,31 @@ kci_netdev_ethtool()
>  		return 1
>  	fi
>  
> -	ethtool -k "$netdev" > "$TMP_ETHTOOL_FEATURES"
> +	ethtool -k "$netdev" | tail -n +2 > "$TMP_ETHTOOL_FEATURES"
>  	if [ $? -ne 0 ];then

Hi Abhinav,

I suspect this will now only report a failure if tail fails,
but ignore ethtool failures.

>  		echo "FAIL: $netdev: ethtool list features"
>  		rm "$TMP_ETHTOOL_FEATURES"
>  		return 1
>  	fi
>  	echo "PASS: $netdev: ethtool list features"
> -	#TODO for each non fixed features, try to turn them on/off
> +
> +	for feature in $(grep -v fixed "$TMP_ETHTOOL_FEATURES" | \
> +		awk '{print $1}' | sed 's/://'); do

Shellcheck warns that the above reads words rather than lines,
and recommends using read instead.

I think that is ok, because the construction reduces lines to single words.
But it does seem a bit awkward to call grep, awk and sed for this.

I wonder if the following construction nicer:

while read -r FEATURE VALUE FIXED; do
	[ "$FEAT" != "Features" ] || continue # Skip "Features" line
	[ "$FIXED" != "[fixed]" ] || continue # Skip fixed features
	feature="${FEATURE%:*}"
	...
done < "$TMP_ETHTOOL_FEATURES"


> +		ethtool --offload "$netdev" "$feature" off
> +		if [ $? -eq 0 ]; then
> +			echo "PASS: $netdev: Turned off feature: $feature"
> +		else
> +			echo "FAIL: $netdev: Failed to turn off feature: $feature"
> +		fi
> +
> +		ethtool --offload "$netdev" "$feature" on
> +		if [ $? -eq 0 ]; then
> +			echo "PASS: $netdev: Turned on feature: $feature"
> +		else
> +			echo "FAIL: $netdev: Failed to turn on feature: $feature"
> +		fi
> +	done
> +
>  	rm "$TMP_ETHTOOL_FEATURES"
>  
>  	kci_netdev_ethtool_test 74 'dump' "ethtool -d $netdev"
> -- 
> 2.34.1
> 
>
Abhinav Jain June 9, 2024, 1:28 p.m. UTC | #2
On Fri, 7 Jun 2024 19:01:27 +0100, Simon Horman wrote:

> Hi Abhinav,
>
> I suspect this will now only report a failure if tail fails,
> but ignore ethtool failures.

Hi Simon,

I agree, I missed this part earlier. After taking other suggestion
into account, we don't need this tail and I have removed it.

> Shellcheck warns that the above reads words rather than lines,
> and recommends using read instead.
>
> I think that is ok, because the construction reduces lines to single words.
> But it does seem a bit awkward to call grep, awk and sed for this.
>
> I wonder if the following construction nicer:
>
> while read -r FEATURE VALUE FIXED; do
> 	[ "$FEAT" != "Features" ] || continue # Skip "Features" line
> 	[ "$FIXED" != "[fixed]" ] || continue # Skip fixed features
> 	feature="${FEATURE%:*}"
> 	...
> done < "$TMP_ETHTOOL_FEATURES"

I have re-submitted a v2 of patch here keeping the above change:
https://lore.kernel.org/all/20240609132124.51683-1-jain.abhinav177@gmail.com/

Please review. Thank you.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
index e3afcb424710..cbe2573c3827 100755
--- a/tools/testing/selftests/net/netdevice.sh
+++ b/tools/testing/selftests/net/netdevice.sh
@@ -117,14 +117,31 @@  kci_netdev_ethtool()
 		return 1
 	fi
 
-	ethtool -k "$netdev" > "$TMP_ETHTOOL_FEATURES"
+	ethtool -k "$netdev" | tail -n +2 > "$TMP_ETHTOOL_FEATURES"
 	if [ $? -ne 0 ];then
 		echo "FAIL: $netdev: ethtool list features"
 		rm "$TMP_ETHTOOL_FEATURES"
 		return 1
 	fi
 	echo "PASS: $netdev: ethtool list features"
-	#TODO for each non fixed features, try to turn them on/off
+
+	for feature in $(grep -v fixed "$TMP_ETHTOOL_FEATURES" | \
+		awk '{print $1}' | sed 's/://'); do
+		ethtool --offload "$netdev" "$feature" off
+		if [ $? -eq 0 ]; then
+			echo "PASS: $netdev: Turned off feature: $feature"
+		else
+			echo "FAIL: $netdev: Failed to turn off feature: $feature"
+		fi
+
+		ethtool --offload "$netdev" "$feature" on
+		if [ $? -eq 0 ]; then
+			echo "PASS: $netdev: Turned on feature: $feature"
+		else
+			echo "FAIL: $netdev: Failed to turn on feature: $feature"
+		fi
+	done
+
 	rm "$TMP_ETHTOOL_FEATURES"
 
 	kci_netdev_ethtool_test 74 'dump' "ethtool -d $netdev"