scapy.contrib.automotive.scanner.executor

class scapy.contrib.automotive.scanner.executor.AutomotiveTestCaseExecutor(socket: Union[SuperSocket, SingleConversationSocket], reset_handler: Optional[Callable[[], None]] = None, reconnect_handler: Optional[Callable[[], Union[SuperSocket, SingleConversationSocket]]] = None, test_cases: Optional[List[Union[AutomotiveTestCaseABC, Type[AutomotiveTestCaseABC]]]] = None, **kwargs: Optional[Dict[str, Any]])[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
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: Optional[float] = 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

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

progress() float[source]
reconnect() None[source]
reset_target() None[source]
scan(timeout: Optional[int] = None) None[source]

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

property scan_completed
show_testcases() None[source]
show_testcases_status() None[source]
property state_graph
property state_paths

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

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]