1.1.3.1.1.1.1. test_automation.targets.fvp.autofvpnetworking

Module to manage telnet sessions

1.1.3.1.1.1.1.1. Attributes

logger

1.1.3.1.1.1.1.2. Classes

TelnetSessionManager

Manage multiple telnet sessions for exposed telnet ports of FVP.

1.1.3.1.1.1.1.3. Module Contents

test_automation.targets.fvp.autofvpnetworking.logger[source]
class test_automation.targets.fvp.autofvpnetworking.TelnetSessionManager(config=None, platform=None, **options)[source]

Manage multiple telnet sessions for exposed telnet ports of FVP.

  1. Read FVP boot log to get terminal-port mappings

  2. Spawn pexpect based telnet session for each terminal

  3. Continuously log for each telnet session’s output

  4. Check for login and shell prompts, send commands and redirect outputs.

Parameters:

platform (Optional[str])

test_name: str | None[source]
login_prompt_map[source]
shell_prompt_map[source]
required_terminals[source]
port_map[source]
base_log_dir = ''[source]
timeout[source]
encoding[source]
sessions: Dict[int, pexpect.spawn][source]
logfiles: Dict[int, any][source]
threads: Dict[int, threading.Thread][source]
expected_prompts: Dict[int, str][source]
terminal_to_port: Dict[str, int][source]
running = True[source]
cmd_output_path[source]
create_and_start_session(port, terminal_name=None)[source]

Spawn a telnet session and start logging simultaneously.

Parameters:
  • port (int) – Telnet port of the telnet session.

  • terminal_name (Optional[str]) – Optional name for prompt mapping.

Return type:

None

get_port(terminal_name)[source]

Return the port number for a terminal name, or None if not registered.

Parameters:

terminal_name (str) – Terminal name to query.

Returns:

Port number if known, else None.

Return type:

Optional[int]

_log_telnet_session(port, session)[source]

Continuously log data from the session into its logfile, logs errors and exits cleanly when the session or logfile is closed.

Parameters:
  • port (int) – Port number of the telnet session.

  • session (pexpect.spawn) – Active pexpect telnet session instance.

Return type:

None

wait_for_prompt_in_log(port, prompt, timeout=120)[source]

Wait until the specified prompt appears in telnet_<port>.log. Checks periodically until found or timeout expires.

Parameters:
  • port (int) – Port number of the session.

  • prompt (str) – Regex or literal string prompt to wait for.

  • timeout (int) – Seconds to wait before timing out.

Returns:

True if prompt is found, False otherwise.

Return type:

bool

login_if_needed(port, login_prompt=None, shell_prompt=None)[source]

If console is at a login prompt, send ‘root’ and wait for shell_prompt. If no login prompt appears, wait for shell_prompt directly.

Parameters:
  • port (int) – Port to use.

  • login_prompt (Optional[str]) – Expected login prompt string.

  • shell_prompt (Optional[str]) – Expected shell prompt string.

Returns:

True if shell prompt is seen, False otherwise.

Return type:

bool

execute_command_with_prompt_capture(port, command, timeout=None)[source]

Execute a command with a completion marker to capture exit code and output.

Parameters:
  • port (int) – Port number for the telnet session.

  • command (str) – Shell command to run.

  • timeout (Optional[int]) – Timeout for waiting on shell prompt and marker.

Returns:

(exit_code, output) tuple.

Return type:

Tuple[int, str]

_check_prompt(term, port)[source]

Attempt to log in on required port, then wait for its shell prompt.

Parameters:
  • term (str) – Terminal name.

  • port (int) – Port number.

Return type:

None

_normalize_term(raw)[source]
Parameters:

raw (str)

Return type:

str

start_telnet_sessions_after_fvp_ready(fvp_driver, log_file_path='')[source]

With LocalFVP: poll get_ports() briefly so multiple terminals can appear, then spawn Telnet sessions for required terminals; if none match, fall back to all.

Parameters:
  • fvp_driver – Controller exposing terminal ports.

  • log_file_path (str) – Path to FVP boot log.

Return type:

None

close_sessions()[source]

Gracefully terminate all active Telnet sessions and close log files.

Return type:

None

set_log_dir(path)[source]

Force all telnet logs under this directory.

Parameters:

path (str)

Return type:

None