|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2026 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | +from typing import Tuple |
| 14 | +from pathlib import Path |
| 15 | +from abc import ABC, abstractmethod |
| 16 | + |
| 17 | + |
| 18 | +class ControlInterface(ABC): |
| 19 | + """Platform independent interface to execute commands on the target""" |
| 20 | + |
| 21 | + @abstractmethod |
| 22 | + def exec_command_blocking( |
| 23 | + *args: str, timeout=1, **env: str |
| 24 | + ) -> Tuple[int, str, str]: |
| 25 | + """Execute a command on the target |
| 26 | +
|
| 27 | + Args: |
| 28 | + *args (str): Command to run with arguments |
| 29 | + timeout (int): Time in seconds to exit after, returning status -1 |
| 30 | + **env (str): Environment vars to set |
| 31 | +
|
| 32 | + Returns: |
| 33 | + (int, str, str): exit_status, stdout, stderr |
| 34 | + """ |
| 35 | + raise NotImplementedError() |
| 36 | + |
| 37 | + @abstractmethod |
| 38 | + def run_until_file_deployed( |
| 39 | + *args, |
| 40 | + timeout=1, |
| 41 | + file_path=Path("tests/integration/test_end"), |
| 42 | + poll_interval=0.05, |
| 43 | + **env, |
| 44 | + ) -> Tuple[int, str, str]: |
| 45 | + """Launch a process and terminate it once a given file has been deployed |
| 46 | +
|
| 47 | + Args: |
| 48 | +
|
| 49 | + *args (str): Command to run with arguments |
| 50 | + timeout (int): Time in seconds to exit after, returning status -1 |
| 51 | + file_path (Path): File to wait for |
| 52 | + poll_interval (float): How often, in seconds, to check if we should terminate the process |
| 53 | + **env (str): Environment vars to set |
| 54 | +
|
| 55 | + Returns: |
| 56 | + (int, str, str): exit_status, stdout, stderr |
| 57 | + """ |
| 58 | + raise NotImplementedError() |
0 commit comments