[PATCH v2] sefltests: net: Add on/off checks for network interface non fixed features

From: Abhinav Jain
Date: Sun Jun 09 2024 - 09:21:43 EST


This patch addresses the TODO (add non fixed feature on/off check).
I have tested it manually on my system and made changes as suggested in v1

Signed-off-by: Abhinav Jain <jain.abhinav177@xxxxxxxxx>
---

PATCH v1:
https://lore.kernel.org/all/20240606212714.27472-1-jain.abhinav177@xxxxxxxxx/

Changes since v1:
- Removed the addition of tail command as it was not required after
below change
- Used read to parse the temp features file rather than using for loop
and took out awk/grep/sed from v1
---
tools/testing/selftests/net/netdevice.sh | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
index e3afcb424710..196b7f985db4 100755
--- a/tools/testing/selftests/net/netdevice.sh
+++ b/tools/testing/selftests/net/netdevice.sh
@@ -124,7 +124,27 @@ kci_netdev_ethtool()
return 1
fi
echo "PASS: $netdev: ethtool list features"
- #TODO for each non fixed features, try to turn them on/off
+
+ while read -r FEATURE VALUE FIXED; do
+ [ "$FEATURE" != "Features" ] || continue # Skip "Features" line
+ [ "$FIXED" != "[fixed]" ] || continue # Skip fixed features
+ feature = "${FEATURE%:*}"
+
+ 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 < "$TMP_ETHTOOL_FEATURES"
+
rm "$TMP_ETHTOOL_FEATURES"

kci_netdev_ethtool_test 74 'dump' "ethtool -d $netdev"
--
2.34.1