From: jspewock@iol.unh.edu
To: wathsala.vithanage@arm.com, thomas@monjalon.net,
probb@iol.unh.edu, juraj.linkes@pantheon.tech,
paul.szczepanek@arm.com, yoan.picchi@foss.arm.com,
Honnappa.Nagarahalli@arm.com, npratte@iol.unh.edu,
alex.chapman@arm.com, Luca.Vizzarro@arm.com
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [PATCH v1 2/2] dts: add port control testing suite
Date: Wed, 14 Aug 2024 14:20:05 -0400 [thread overview]
Message-ID: <20240814182005.12251-3-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240814182005.12251-1-jspewock@iol.unh.edu>
From: Jeremy Spewock <jspewock@iol.unh.edu>
This patch ports over the port_control test suite from the Old DTS
framework and adapts the functionality to fit with the current testing
framework. The test suite provides validation of basic port control
functions such as starting, stopping, and closing ports. It should
be noted that this test suite is not completely 1-to-1 with the one
from Old DTS as it does exclude test cases that use QEMU for testing as
this is not something we are looking to add to the framework in the
near future. It also excludes test cases for resetting ports as this
feature is something that is not supported by all devices and does not
expose a capability regarding if it is through testpmd.
Depends-on: patch-142949 ("dts: add ability to send/receive multiple
packets")
Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
dts/framework/config/conf_yaml_schema.json | 3 +-
dts/tests/TestSuite_port_control.py | 80 ++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 dts/tests/TestSuite_port_control.py
diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index f02a310bb5..78cbd17dad 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
"enum": [
"hello_world",
"os_udp",
- "pmd_buffer_scatter"
+ "pmd_buffer_scatter",
+ "port_control"
]
},
"test_target": {
diff --git a/dts/tests/TestSuite_port_control.py b/dts/tests/TestSuite_port_control.py
new file mode 100644
index 0000000000..9e843512ab
--- /dev/null
+++ b/dts/tests/TestSuite_port_control.py
@@ -0,0 +1,80 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+"""Port Control Testing Suite.
+
+This test suite serves to show that ports within testpmd support basic configuration functions.
+Things such as starting a port, stopping a port, and closing a port should all be supported by the
+device. Additionally, after each of these configuration steps (outside of closing the port) it
+should still be possible to start the port again and verify that the port is able to forward a
+large amount of packets (1000 are sent in the test cases).
+"""
+from scapy.layers.l2 import Ether # type: ignore[import-untyped]
+from scapy.packet import Packet, Raw # type: ignore[import-untyped]
+
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite
+
+
+class TestPortControl(TestSuite):
+ """DPDK Port Control Testing Suite."""
+
+ def send_packets_and_verify(self) -> None:
+ """Send 1000 packets and verify that all packets were forwarded back.
+
+ Packets sent are identical and are all ethernet frames with a payload of 30 "X" characters.
+ This payload is used to differentiate noise on the wire from packets sent by this
+ framework.
+ """
+ payload = "X" * 30
+ num_pakts = 1000
+ send_p = Ether() / Raw(payload)
+ recv_pakts: list[Packet] = []
+ # The scapy sniffer can only handle a little under 200 packets per 1000 at a time, so this
+ # is limited to 100 per burst.
+ for _ in range(int(num_pakts / 100)):
+ recv_pakts += self.send_packets_and_capture([send_p] * 100)
+ recv_pakts += self.send_packets_and_capture([send_p] * (num_pakts % 100))
+ recv_pakts = [
+ p
+ for p in recv_pakts
+ if (
+ # Remove padding from the bytes.
+ hasattr(p, "load")
+ and p.load.decode("utf-8").replace("\x00", "") == payload
+ )
+ ]
+ self.verify(
+ len(recv_pakts) == num_pakts,
+ f"Received {len(recv_pakts)} packets when {num_pakts} were expected.",
+ )
+
+ def test_start_ports(self) -> None:
+ """Ensure that the port can receive traffic after explicitly being started."""
+ with TestPmdShell(self.sut_node, forward_mode=SimpleForwardingModes.mac) as testpmd:
+ testpmd.start_all_ports()
+ testpmd.start()
+ self.send_packets_and_verify()
+
+ def test_stop_ports(self) -> None:
+ """Verify that the link goes down after stopping ports.
+
+ This case also verifies that the port can be started again and properly forward traffic
+ after being stopped.
+ """
+ with TestPmdShell(self.sut_node, forward_mode=SimpleForwardingModes.mac) as testpmd:
+ testpmd.stop_all_ports()
+ self.verify(
+ all(not p.is_link_up for p in testpmd.show_port_info_all()),
+ "Failed to stop all ports.",
+ )
+ testpmd.start()
+ self.send_packets_and_verify()
+
+ def test_close_ports(self) -> None:
+ """Verify that ports can be closed and no longer appear in testpmd when they are."""
+ with TestPmdShell(self.sut_node) as testpmd:
+ testpmd.close_all_ports()
+ self.verify(
+ len(testpmd.show_port_info_all()) == 0, "Failed to close all ports in testpmd."
+ )
--
2.45.2
next prev parent reply other threads:[~2024-08-14 18:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 18:20 [PATCH v1 0/2] dts: port over port_control " jspewock
2024-08-14 18:20 ` [PATCH v1 1/2] dts: add methods for closing ports to testpmd jspewock
2024-08-14 18:20 ` jspewock [this message]
2024-09-23 16:44 ` [PATCH v2 0/2] dts: port over port_control testing suite jspewock
2024-09-23 16:44 ` [PATCH v2 1/2] dts: add method for closing ports to testpmd jspewock
2024-09-23 16:44 ` [PATCH v2 2/2] dts: add port control testing suite jspewock
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=20240814182005.12251-3-jspewock@iol.unh.edu \
--to=jspewock@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=juraj.linkes@pantheon.tech \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=thomas@monjalon.net \
--cc=wathsala.vithanage@arm.com \
--cc=yoan.picchi@foss.arm.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).