Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit b179ecd

Browse files
committed
Start adding API for parallel execution
Added run_multiple_commands method inside the SUT parent class. This API is needed to start working on parallel execution.
1 parent aa296ac commit b179ecd

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

ltp/sut.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def stop(self, timeout: float = 30, iobuffer: IOBuffer = None) -> None:
134134
"""
135135
raise NotImplementedError()
136136

137-
def force_stop(self, timeout: float = 30, iobuffer: IOBuffer = None) -> None:
137+
def force_stop(self,
138+
timeout: float = 30,
139+
iobuffer: IOBuffer = None) -> None:
138140
"""
139141
Force stopping the current SUT session.
140142
:param timeout: timeout to complete in seconds
@@ -151,6 +153,7 @@ def run_command(self,
151153
"""
152154
Run command on target.
153155
:param command: command to execute
156+
:type command: str
154157
:param timeout: timeout before stopping execution. Default is 3600
155158
:type timeout: float
156159
:param iobuffer: buffer used to write SUT stdout
@@ -169,6 +172,39 @@ def run_command(self,
169172
"""
170173
raise NotImplementedError()
171174

175+
def run_multiple_commands(self,
176+
commands: list,
177+
timeout: float = 3600,
178+
command_completed: callable = None) -> list:
179+
"""
180+
Run multiple commands in parallel on target.
181+
:param commands: commands to execute
182+
:type commands: list(str)
183+
:param timeout: timeout before stopping execution. Default is 3600
184+
:type timeout: float
185+
:param command_completed: function called when a test has completed.
186+
Its definition is `command_completed(ret: set)` where ret has the
187+
same definition of data returned by `run_multiple_commands` inside
188+
the list.
189+
:type command_completed: callable
190+
:returns: list of (dict, Exception) containing command execution
191+
information and exception.
192+
193+
[
194+
({
195+
"command": <str>,
196+
"timeout": <float>,
197+
"returncode": <int>,
198+
"stdout": <str>,
199+
"exec_time": <float>,
200+
}, None)
201+
...
202+
]
203+
204+
If None is returned, then callback failed.
205+
"""
206+
raise NotImplementedError()
207+
172208
def fetch_file(
173209
self,
174210
target_path: str,

0 commit comments

Comments
 (0)