patch 'dts: strip whitespaces from stdout and stderr' has been queued to stable release 23.11.1

Xueming Li xuemingl at nvidia.com
Sat Apr 13 14:50:04 CEST 2024


Hi,

FYI, your patch has been queued to stable release 23.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 04/15/24. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=23.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=23.11-staging&id=a20a3c1129aff09b2058b37d3f463e4879e46b74

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From a20a3c1129aff09b2058b37d3f463e4879e46b74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juraj=20Linke=C5=A1?= <juraj.linkes at pantheon.tech>
Date: Tue, 13 Feb 2024 12:14:39 +0100
Subject: [PATCH] dts: strip whitespaces from stdout and stderr
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: Xueming Li <xuemingl at nvidia.com>

There could be a newline at the end of stdout or stderr of a remotely
executed command. These cause issues when used later, such as when
joining paths from such commands - a newline in the middle of a path is
not valid.

Fixes: ad80f550dbc5 ("dts: add SSH command verification")
Cc: stable at dpdk.org

Signed-off-by: Juraj Linkeš <juraj.linkes at pantheon.tech>
Reviewed-by: Jeremy Spewock <jspewock at iol.unh.edu>
Acked-by: Patrick Robb <probb at iol.unh.edu>
---
 .../remote_session/remote/remote_session.py   | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/dts/framework/remote_session/remote/remote_session.py b/dts/framework/remote_session/remote/remote_session.py
index 719f7d1ef7..68894a9686 100644
--- a/dts/framework/remote_session/remote/remote_session.py
+++ b/dts/framework/remote_session/remote/remote_session.py
@@ -3,8 +3,8 @@
 # Copyright(c) 2022-2023 PANTHEON.tech s.r.o.
 # Copyright(c) 2022-2023 University of New Hampshire
 
-import dataclasses
 from abc import ABC, abstractmethod
+from dataclasses import InitVar, dataclass, field
 from pathlib import PurePath
 
 from framework.config import NodeConfiguration
@@ -13,7 +13,7 @@ from framework.logger import DTSLOG
 from framework.settings import SETTINGS
 
 
- at dataclasses.dataclass(slots=True, frozen=True)
+ at dataclass(slots=True, frozen=True)
 class CommandResult:
     """
     The result of remote execution of a command.
@@ -21,9 +21,25 @@ class CommandResult:
 
     name: str
     command: str
-    stdout: str
-    stderr: str
+    init_stdout: InitVar[str]
+    init_stderr: InitVar[str]
     return_code: int
+    stdout: str = field(init=False)
+    stderr: str = field(init=False)
+
+    def __post_init__(self, init_stdout: str, init_stderr: str) -> None:
+        """Strip the whitespaces from stdout and stderr.
+
+        The generated __init__ method uses object.__setattr__() when the dataclass is frozen,
+        so that's what we use here as well.
+
+        In order to get access to dataclass fields in the __post_init__ method,
+        we have to type them as InitVars. These InitVars are included in the __init__ method's
+        signature, so we have to exclude the actual stdout and stderr fields
+        from the __init__ method's signature, so that we have the proper number of arguments.
+        """
+        object.__setattr__(self, "stdout", init_stdout.strip())
+        object.__setattr__(self, "stderr", init_stderr.strip())
 
     def __str__(self) -> str:
         return (
-- 
2.34.1



More information about the stable mailing list