Skip to contentSkip to conversation

dts: add packet capture test suite

PATCH In review Thomas Wilks 4 participants 12 messages Mar 31, 2025 – Jun 3, 2025

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
new file mode 100644
index 0000000000..3d760d3ae4
@@ -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
Reviewed-by on v1 1/2
#2 lore raw
Quoted 12 lines · Thomas Wilks

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

<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.

#3 lore raw
In reply to Thomas Wilks

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.

#4 lore raw

PATCH 2/2 dts: import lldp package in scapy

In reply to Thomas Wilks

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
index 78a6ded74c..c7e8fc42e9 100644
@@ -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
#6 lore raw

v2 cover dts: add packet capture test suite

In reply to Thomas Wilks

Hi 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
#7 lore raw

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
index aed0b76108..76f8496bf8 100644
@@ -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
#8 lore raw

PATCH v2 2/3 dts: add facility to change file permissions

In reply to Luca Vizzarro

Add 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
index 354c607357..869d575f0e 100644
@@ -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
index 2d2701e1cf..fcd2faad6b 100644
@@ -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
#10 lore raw

PATCH v2 3/3 dts: add packet capture test suite

In reply to Luca Vizzarro

From: 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
new file mode 100644
index 0000000000..3d760d3ae4
@@ -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
Reviewed-by on v2 3/3
#11 lore raw
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.

<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: