dts: add packet capture test suite
cover dts: add packet capture test suite
Hi,
Sending this new test suite that tests the packet capture framework.
Best regards,
Thomas
Depends-on: series-34865 ("dts: shell improvements")
Thomas Wilks (2):
dts: add packet capture test suite
dts: import lldp package in scapy
.../dts/tests.TestSuite_packet_capture.rst | 8 + .../testbed_model/traffic_generator/scapy.py | 1 + dts/tests/TestSuite_packet_capture.py | 357 ++++++++++++++++++ 3 files changed, 366 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_packet_capture.rst create mode 100644 dts/tests/TestSuite_packet_capture.py
Signature · 1 line
2.43.0
PATCH 1/2 dts: add packet capture test suite
Add a test suite that tests the packet capture framework through the use of dpdk-pdump.
--- .../dts/tests.TestSuite_packet_capture.rst | 8 + dts/tests/TestSuite_packet_capture.py | 358 ++++++++++++++++++ 2 files changed, 366 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_packet_capture.rst create mode 100644 dts/tests/TestSuite_packet_capture.py
doc/api/dts/tests.TestSuite_packet_capture.rst new file +8 -0
@@ -0,0 +1,8 @@ +.. SPDX-License-Identifier: BSD-3-Clause + +packet_capture Test Suite +========================= + +.. automodule:: tests.TestSuite_packet_capture + :members: + :show-inheritance:
dts/tests/TestSuite_packet_capture.py new file +358 -0
358 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 12 lines · Thomas Wilks
Add a test suite that tests the packet capture framework through the use of dpdk-pdump.
Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Luca Vizzarro <[email protected]>--- .../dts/tests.TestSuite_packet_capture.rst | 8 + dts/tests/TestSuite_packet_capture.py | 358 ++++++++++++++++++ 2 files changed, 366 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_packet_capture.rst create mode 100644 dts/tests/TestSuite_packet_capture.py
<snip>
dts/tests/TestSuite_packet_capture.py line 65
Quoted 8 lines
dts/tests/TestSuite_packet_capture.py new file +8
-0+ device_id: str | None = None + port: int | None = None + queue: Union[int, Literal["*"]] = "*" + tx_dev: PurePath | str | None = None + rx_dev: PurePath | str | None = None + ring_size: int | None = None + mbuf_size: int | None = None + total_num_mbufs: int | None = None
One small thing I noticed here is that you're using Union for the queue and pipes for the rest of the declarations. queue: int | Literal["*"] = "*" would be the same thing functionally, and it would save you an import.
dts/tests/TestSuite_packet_capture.py line 177
Quoted 11 lines · On Mon, 31 Mar 2025 16:57:59 +0100 Thomas Wilks <[email protected]> wrote:
dts/tests/TestSuite_packet_capture.py new file +11
-0+ def _start_pdump( + self, + pdump_params: list[PdumpParameters], + eal_params: EalParams | None = None, + ) -> BlockingDPDKApp: + if eal_params is None: + eal_params = EalParams() + + eal_params.append_str(" ".join([f'--pdump "{param}"' for param in pdump_params])) + + pdump = BlockingDPDKApp(PurePath("app/dpdk-pdump"), app_params=eal_params)
Please test dpdk-dumpcap not pdump. The old pdump is legacy, has too complex an options, can't work in many cases and is a general mess. Dpdk-dumpcap was built as a replacement and has way more features and will be supported.
I intend to deprecate pdump and remove it in 25.11.
PATCH 2/2 dts: import lldp package in scapy
In reply to Thomas WilksAdd import for lldp scapy package to enable lldp packet creation and handling.
--- dts/framework/testbed_model/traffic_generator/scapy.py | 1 + 1 file changed, 1 insertion(+)
dts/framework/testbed_model/traffic_generator/scapy.py +1 -0
@@ -95,6 +95,7 @@ def setup(self, ports: Iterable[Port]): self._tg_node.main_session.bring_up_link(ports) self._shell.start_application() self._shell.send_command("from scapy.all import *") + self._shell.send_command("from scapy.contrib.lldp import *") def close(self): """Close traffic generator."""
Signature · 1 line
2.43.0
Re: [PATCH 2/2] dts: import lldp package in scapy
Quoted 6 lines · Thomas Wilks
Add import for lldp scapy package to enable lldp packet creation and handling.
Signed-off-by Thomas Wilks <[email protected]>Reviewed-by Luca Vizzarro <[email protected]>
v2 cover dts: add packet capture test suite
In reply to Thomas WilksHi there,
sending in a v2 for the packet capture test suite.
v2:
- added a new command to change file permissions on remote
- changed test suite to use dpdk-dumpcap instead of dpdk-pdump
Best regards,
Luca
Luca Vizzarro (1):
dts: add facility to change file permissions
Thomas Wilks (2):
dts: import lldp package in scapy
dts: add packet capture test suite
.../dts/tests.TestSuite_packet_capture.rst | 8 + dts/framework/testbed_model/os_session.py | 34 +++ dts/framework/testbed_model/posix_session.py | 11 +- .../testbed_model/traffic_generator/scapy.py | 1 + dts/tests/TestSuite_packet_capture.py | 238 ++++++++++++++++++ 5 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 doc/api/dts/tests.TestSuite_packet_capture.rst create mode 100644 dts/tests/TestSuite_packet_capture.py
Signature · 1 line
2.43.0
PATCH v2 1/3 dts: import lldp package in scapy
From: Thomas Wilks <[email protected]>
Add import for lldp scapy package to enable lldp packet creation and handling.
--- dts/framework/testbed_model/traffic_generator/scapy.py | 1 + 1 file changed, 1 insertion(+)
dts/framework/testbed_model/traffic_generator/scapy.py +1 -0
@@ -328,6 +328,7 @@ def setup(self, ports: Iterable[Port], rx_port: Port): self._shell = PythonShell(self._tg_node, "scapy", privileged=True) self._shell.start_application() self._shell.send_command("from scapy.all import *") + self._shell.send_command("from scapy.contrib.lldp import *") def close(self): """Overrides :meth:`.traffic_generator.TrafficGenerator.close`.
Signature · 1 line
2.43.0
PATCH v2 2/3 dts: add facility to change file permissions
In reply to Luca VizzarroAdd an abstraction to handle file permissions for the remote.
--- dts/framework/testbed_model/os_session.py | 34 ++++++++++++++++++++ dts/framework/testbed_model/posix_session.py | 11 ++++++- 2 files changed, 44 insertions(+), 1 deletion(-)
dts/framework/testbed_model/os_session.py +34 -0
@@ -26,6 +26,7 @@ from abc import ABC, abstractmethod from collections.abc import Iterable from dataclasses import dataclass +from enum import Flag, auto from pathlib import Path, PurePath, PurePosixPath from framework.config.node import NodeConfiguration
@@ -44,6 +45,33 @@ from .port import Port +class FilePermissions(Flag): + """The permissions for a file and/or directory.""" + + #: + OTHERS_EXECUTE = auto() + #: + OTHERS_WRITE = auto() + #: + OTHERS_READ = auto() + #: + GROUP_EXECUTE = auto() + #: + GROUP_WRITE = auto() + #: + GROUP_READ = auto() + #: + OWNER_EXECUTE = auto() + #: + OWNER_WRITE = auto() + #: + OWNER_READ = auto() + + def to_octal(self) -> str: + """Convert this flag to an octal representation.""" + return format(self.value, "03o") + + @dataclass(slots=True, frozen=True) class OSSessionInfo: """Supplemental OS session information.
@@ -313,6 +341,12 @@ def copy_dir_to( These patterns are used with `fnmatch.fnmatch` to filter out files. """ + @abstractmethod + def change_permissions( + self, remote_path: PurePath, permissions: FilePermissions, recursive: bool = False + ) -> None: + """Change the permissions of the given path.""" + @abstractmethod def remove_remote_file(self, remote_file_path: str | PurePath, force: bool = True) -> None: """Remove remote file, by default remove forcefully.
dts/framework/testbed_model/posix_session.py +10 -1
@@ -26,7 +26,7 @@ ) from .cpu import Architecture -from .os_session import OSSession, OSSessionInfo +from .os_session import FilePermissions, OSSession, OSSessionInfo class PosixSession(OSSession):
@@ -146,6 +146,15 @@ def copy_dir_to( self.extract_remote_tarball(remote_tar_path) self.remove_remote_file(remote_tar_path) + def change_permissions( + self, remote_path: PurePath, permissions: FilePermissions, recursive: bool = False + ) -> None: + """Overrides :meth:`~.os_session.OSSession.change_permissions`.""" + self.send_command( + f"chmod {'-R ' if recursive else ''}{permissions.to_octal()} {remote_path}", + privileged=True, + ) + def remove_remote_file(self, remote_file_path: str | PurePath, force: bool = True) -> None: """Overrides :meth:`~.os_session.OSSession.remove_remote_dir`.""" opts = PosixSession.combine_short_options(f=force)
Signature · 1 line
2.43.0
Re: [PATCH v2 2/3] dts: add facility to change file permissions
PATCH v2 3/3 dts: add packet capture test suite
In reply to Luca VizzarroFrom: Thomas Wilks <[email protected]>
Add a test suite that tests the packet capture framework through the use of dpdk-dumpcap.
--- .../dts/tests.TestSuite_packet_capture.rst | 8 + dts/tests/TestSuite_packet_capture.py | 238 ++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_packet_capture.rst create mode 100644 dts/tests/TestSuite_packet_capture.py
doc/api/dts/tests.TestSuite_packet_capture.rst new file +8 -0
@@ -0,0 +1,8 @@ +.. SPDX-License-Identifier: BSD-3-Clause + +packet_capture Test Suite +========================= + +.. automodule:: tests.TestSuite_packet_capture + :members: + :show-inheritance:
dts/tests/TestSuite_packet_capture.py new file +238 -0
238 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 9 lines · Luca Vizzarro
From: Thomas Wilks <[email protected]>
Add a test suite that tests the packet capture framework through the use of dpdk-dumpcap.
Signed-off-by Thomas Wilks <[email protected]>Signed-off-by Luca Vizzarro <[email protected]>Reviewed-by Paul Szczepanek <[email protected]>
<snip>
dts/tests/TestSuite_packet_capture.py line 98
Quoted 8 lines
dts/tests/TestSuite_packet_capture.py new file +8
-0+ + def close(self) -> None: + """Close the application. + + Sends a SIGINT to close the application. + """ + self.send_command("\x03") + super().close()
I believe code x03 is for SIGQUIT, not SIGINT:
https://www.chromium.org/chromium-os/developer-library/reference/linux-constants/signals/
Otherwise: