From: "Niklas Söderlund" <niklas.soderlund@corigine.com>
To: dts@dpdk.org
Cc: oss-drivers@corigine.com, "Qin Ke" <qin.ke@corigine.com>,
"Niklas Söderlund" <niklas.soderlund@corigine.com>
Subject: [PATCH 2/2] tests/speed_capabilities: optimize code sequence of test case
Date: Mon, 3 Jul 2023 21:25:42 +0200 [thread overview]
Message-ID: <20230703192542.36809-3-niklas.soderlund@corigine.com> (raw)
In-Reply-To: <20230703192542.36809-1-niklas.soderlund@corigine.com>
From: Qin Ke <qin.ke@corigine.com>
The verification code of interface_name and interface_speed can be
moved forward, it can reduce unnecessary code execution if the
verification failed.
Adjust the code sequence of related code.
Signed-off-by: Qin Ke <qin.ke@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
tests/TestSuite_speed_capabilities.py | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/TestSuite_speed_capabilities.py b/tests/TestSuite_speed_capabilities.py
index 3bda904e8a81..2b950a541e7c 100644
--- a/tests/TestSuite_speed_capabilities.py
+++ b/tests/TestSuite_speed_capabilities.py
@@ -39,15 +39,20 @@ class TestSpeedCapabilities(TestCase):
for port in self.ports:
interface_name = self.tester.get_interface(self.tester.get_local_port(port))
- # Gives the speed in Mb/s
- interface_speed = self.pmdout.get_port_link_speed(port)
-
self.verify(
interface_name in expected_speeds,
f"The interface {interface_name} does not have an expected "
f"speed associated with it.",
)
+ # Gives the speed in Mb/s
+ interface_speed = self.pmdout.get_port_link_speed(port)
+
+ self.verify(
+ len(interface_speed) > 0,
+ f"A valid speed could not be read for the interface {interface_name}.",
+ )
+
detected_interfaces.append(interface_name)
expected_speed = expected_speeds[interface_name]
@@ -58,11 +63,6 @@ class TestSpeedCapabilities(TestCase):
# Removes the unit from the speed
expected_speed = "".join(i for i in expected_speed if i.isdigit())
- self.verify(
- len(interface_speed) > 0,
- f"A valid speed could not be read for the interface {interface_name}.",
- )
-
# Converts Gb/s to Mb/s for consistent comparison
if expected_speed_unit == "G":
expected_speed += "000"
--
2.41.0
prev parent reply other threads:[~2023-07-03 19:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 19:25 [PATCH 0/2] tests/speed_capabilities: Document and convert to a common speed unit Niklas Söderlund
2023-07-03 19:25 ` [PATCH 1/2] framework/pmd_output: report link speed in Mbps Niklas Söderlund
2023-07-03 19:25 ` Niklas Söderlund [this message]
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=20230703192542.36809-3-niklas.soderlund@corigine.com \
--to=niklas.soderlund@corigine.com \
--cc=dts@dpdk.org \
--cc=oss-drivers@corigine.com \
--cc=qin.ke@corigine.com \
/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).