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
1.1.3.1.1.1.1.2. Classes
Manage multiple telnet sessions for exposed telnet ports of FVP. |
1.1.3.1.1.1.1.3. Module Contents
- class test_automation.targets.fvp.autofvpnetworking.TelnetSessionManager(config=None, platform=None, **options)[source]
Manage multiple telnet sessions for exposed telnet ports of FVP.
Read FVP boot log to get terminal-port mappings
Spawn pexpect based telnet session for each terminal
Continuously log for each telnet session’s output
Check for login and shell prompts, send commands and redirect outputs.
- Parameters:
platform (Optional[str])
- 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
- 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