From: Ales Nezbeda <anezbeda@redhat.com>
To: netdev@vger.kernel.org
Cc: sdf@fomichev.me, sd@queasysnail.net, davem@davemloft.net,
Ales Nezbeda <anezbeda@redhat.com>
Subject: [PATCH net v2] selftests: rtnetlink: add 'ethtool' as a dependency
Date: Mon, 9 Sep 2024 10:34:10 +0200 [thread overview]
Message-ID: <20240909083410.60121-1-anezbeda@redhat.com> (raw)
Introduction of `kci_test_macsec_offload()` in `rtnetlink.sh` created
a new dependency `ethtool` for the test suite. This dependency is not
reflected in checks that run before all the tests, so if the `ethtool`
is not present, all tests will start, but `macsec_offload` test will
fail with a misleading message. Message would say that MACsec offload is
not supported, yet it never actually managed to check this, since it
needs the `ethtool` to do so.
Use `require_command` in `rtnetlink.sh` to allow single check command
for all the dependencies. This also requires adding the `require_command`
to the `lib.sh` used by the test.
Fixes: 3b5222e2ac57 ("selftests: rtnetlink: add MACsec offload tests")
Signed-off-by: Ales Nezbeda <anezbeda@redhat.com>
---
v2
- Add `require_command` to the `lib.sh` and use that instead
- v1 ref: https://lore.kernel.org/netdev/20240903151524.586614-1-anezbeda@redhat.com
---
tools/testing/selftests/net/lib.sh | 13 +++++++++++++
tools/testing/selftests/net/rtnetlink.sh | 9 +++------
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
index 8ee4489238ca..890c579674be 100644
--- a/tools/testing/selftests/net/lib.sh
+++ b/tools/testing/selftests/net/lib.sh
@@ -218,3 +218,16 @@ tc_rule_handle_stats_get()
| jq ".[] | select(.options.handle == $handle) | \
.options.actions[0].stats$selector"
}
+
+##############################################################################
+# Sanity checks
+
+require_command()
+{
+ local cmd=$1; shift
+
+ if [[ ! -x "$(command -v "$cmd")" ]]; then
+ echo "SKIP: $cmd not installed"
+ exit $ksft_skip
+ fi
+}
\ No newline at end of file
diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index bdf6f10d0558..4a9ffd06990b 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -1306,12 +1306,9 @@ if [ "$(id -u)" -ne 0 ];then
exit $ksft_skip
fi
-for x in ip tc;do
- $x -Version 2>/dev/null >/dev/null
- if [ $? -ne 0 ];then
- end_test "SKIP: Could not run test without the $x tool"
- exit $ksft_skip
- fi
+#check for dependencies
+for x in ip tc ethtool;do
+ require_command $x
done
while getopts t:hvpP o; do
--
2.46.0
next reply other threads:[~2024-09-09 8:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 8:34 Ales Nezbeda [this message]
2024-09-10 0:07 ` [PATCH net v2] selftests: rtnetlink: add 'ethtool' as a dependency Jakub Kicinski
2024-09-16 9:18 ` Ales Nezbeda
2024-10-15 11:47 ` Sabrina Dubroca
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=20240909083410.60121-1-anezbeda@redhat.com \
--to=anezbeda@redhat.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
--cc=sdf@fomichev.me \
/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).