netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Abhinav Jain <jain.abhinav177@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, shuah@kernel.org, netdev@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com
Subject: Re: [PATCH v7 net-next 2/3] selftests: net: Add on/off checks for non-fixed features of interface
Date: Thu, 15 Aug 2024 14:03:53 +0100	[thread overview]
Message-ID: <20240815130353.GB632411@kernel.org> (raw)
In-Reply-To: <20240815105924.1389290-3-jain.abhinav177@gmail.com>

On Thu, Aug 15, 2024 at 04:29:23PM +0530, Abhinav Jain wrote:
> Implement on/off testing for all non-fixed features via while loop.
> Save the initial state so that it can be restored after on/off checks.
> 
> Signed-off-by: Abhinav Jain <jain.abhinav177@gmail.com>
> ---
>  tools/testing/selftests/net/netdevice.sh | 37 +++++++++++++++++++++++-
>  1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/selftests/net/netdevice.sh
> index 0c32950fdd17..50f7b9d1163d 100755
> --- a/tools/testing/selftests/net/netdevice.sh
> +++ b/tools/testing/selftests/net/netdevice.sh
> @@ -124,7 +124,42 @@ 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"
> +		[ "$FIXED" != "[fixed]" ] || continue # Skip fixed features
> +		feature="${FEATURE%:*}"
> +
> +		initial_state=$(ethtool -k "$netdev" | grep "$feature:" \
> +			| awk '{print $2}')

Hi Abhinav,

Isn't the value being read into $initial_state here already present in $VALUE?

> +		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
> +
> +		#restore the feature to its initial state
> +		ethtool --offload "$netdev" "$feature" "$initial_state"
> +		if [ $? -eq 0 ]; then
> +			echo "PASS: $netdev: Restore feature $feature" \
> +				"to initial state $initial_state"
> +		else
> +			echo "FAIL: $netdev: Failed to restore feature" \
> +				"$feature to default $initial_state"
> +		fi
> +
> +	done < "$TMP_ETHTOOL_FEATURES"
> +
>  	rm "$TMP_ETHTOOL_FEATURES"
>  
>  	kci_netdev_ethtool_test 74 'dump' "ethtool -d $netdev"
> -- 
> 2.34.1
> 
> 

  reply	other threads:[~2024-08-15 13:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15 10:59 [PATCH v7 net-next 0/3] Enhance network interface feature testing Abhinav Jain
2024-08-15 10:59 ` [PATCH v7 net-next 1/3] selftests: net: Create veth pair for testing in networkless kernel Abhinav Jain
2024-08-15 10:59 ` [PATCH v7 net-next 2/3] selftests: net: Add on/off checks for non-fixed features of interface Abhinav Jain
2024-08-15 13:03   ` Simon Horman [this message]
2024-08-15 16:46     ` Abhinav Jain
2024-08-15 10:59 ` [PATCH v7 net-next 3/3] selftests: net: Use XFAIL for operations not supported by the driver Abhinav Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240815130353.GB632411@kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jain.abhinav177@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).