scapy.contrib.automotive.scanner.executor

class scapy.contrib.automotive.scanner.executor.AutomotiveTestCaseExecutor(socket: SuperSocket | SingleConversationSocket, reset_handler: Callable[[], None] | None = None, reconnect_handler: Callable[[], SuperSocket | SingleConversationSocket] | None = None, test_cases: List[AutomotiveTestCaseABC | Type[AutomotiveTestCaseABC]] | None = None, **kwargs: Dict[str, Any] | None)[source]

Bases: object

Base class for different automotive scanners. This class handles the connection to a scan target, ensures the execution of all it’s test cases, and stores the system state machine

Parameters:
  • socket – A socket object to communicate with the scan target

  • reset_handler – A function to reset the scan target

  • reconnect_handler – In case the communication needs to be established after a reset, provide a reconnect function which returns a socket object

  • test_cases – A list of TestCase instances or classes

  • kwargs – Arguments for the internal AutomotiveTestCaseExecutorConfiguration instance

check_new_states(test_case: AutomotiveTestCaseABC) None[source]
check_new_testcases(test_case: AutomotiveTestCaseABC) None[source]
cleanup_state() None[source]

Executes all collected cleanup functions from a traversed path :return: None

abstract property default_test_case_clss: List[Type[AutomotiveTestCaseABC]]
enter_state(prev_state: EcuState, next_state: EcuState) bool[source]

Obtains a transition function from the system state graph and executes it. On success, the cleanup function is added for a later cleanup of the new state. :param prev_state: Current state :param next_state: Desired state :return: True, if state could be changed successful

enter_state_path(path: List[EcuState]) bool[source]

Resets and reconnects to a target and applies all transition functions to traversal a given path. :param path: Path to be applied to the scan target. :return: True, if all transition functions could be executed.

execute_test_case(test_case: AutomotiveTestCaseABC, kill_time: float | None = None) None[source]

This function ensures the correct execution of a testcase, including the pre_execute, execute and post_execute. Finally the testcase is asked if a new edge or a new testcase was generated.

Parameters:
  • test_case – A test case to be executed

  • kill_time – If set, this defines the maximum execution time for the current test_case

Returns:

None

property final_states: List[EcuState]

Returns a list with all final states. A final state is the last state of a path. :return:

get_test_cases_by_class(cls: Type[T]) List[T][source]
progress() float[source]
reconnect() None[source]
reset_target() None[source]
scan(timeout: int | None = None) None[source]

Executes all testcases for a given time. :param timeout: Time for execution. :return: None

property scan_completed: bool
show_testcases() None[source]
show_testcases_status() None[source]
property state_graph: Graph
property state_paths: List[List[EcuState]]

Returns all state paths. A path is represented by a list of EcuState objects. :return: A list of paths.

stop_scan() None[source]
property supported_responses: List[EcuResponse]

Returns a sorted list of supported responses, gathered from all enumerators. The sort is done in a way to provide the best possible results, if this list of supported responses is used to simulate an real world Ecu with the EcuAnsweringMachine object. :return: A sorted list of EcuResponse objects

validate_test_case_kwargs() None[source]