File: machine_interface.py

package info (click to toggle)
intel-gpu-tools 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,360 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (65 lines) | stat: -rw-r--r-- 1,691 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# SPDX-License-Identifier: MIT
# Copyright © 2024 Intel Corporation

import abc
import enum
import signal
import typing

from bench.configurators.vmtb_config import VmtbIgtConfig

DEFAULT_TIMEOUT: int = 1200 # Default machine execution wait timeout in seconds


class ProcessResult(typing.NamedTuple):
    exited: bool = False
    exit_code: typing.Optional[int] = None
    stdout: str = ''
    stderr: str = ''


class SuspendMode(str, enum.Enum):
    ACPI_S3 = 'mem'    # Suspend to RAM aka sleep
    ACPI_S4 = 'disk'   # Suspend to disk aka hibernation

    def __str__(self) -> str:
        return str.__str__(self)


class MachineInterface(metaclass=abc.ABCMeta):

    @abc.abstractmethod
    def execute(self, command: str) -> int:
        raise NotImplementedError

    @abc.abstractmethod
    def execute_status(self, pid: int) -> ProcessResult:
        raise NotImplementedError

    @abc.abstractmethod
    def execute_wait(self, pid: int, timeout: int) -> ProcessResult:
        raise NotImplementedError

    @abc.abstractmethod
    def execute_signal(self, pid: int, sig: signal.Signals) -> None:
        raise NotImplementedError

    @abc.abstractmethod
    def read_file_content(self, path: str) -> str:
        raise NotImplementedError

    @abc.abstractmethod
    def write_file_content(self, path: str, content: str) -> int:
        raise NotImplementedError

    @abc.abstractmethod
    def dir_exists(self, path: str) -> bool:
        raise NotImplementedError

    @abc.abstractmethod
    def get_drm_driver_name(self) -> str:
        raise NotImplementedError

    @abc.abstractmethod
    def get_igt_config(self) -> VmtbIgtConfig:
        raise NotImplementedError