diff mbox series

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

Message ID 20240606212714.27472-1-jain.abhinav177@gmail.com
State New
Headers show
Series selftests: net: Add on/off checks for network interface non fixed features | expand

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(-)
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"