mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-13 09:17:07 +03:00
Merge pull request #125372 from Synthetica9/shell_interact
nixos/tests/test-driver: add shell_interact
This commit is contained in:
commit
f88be6e55c
@ -436,6 +436,18 @@ machine.systemctl("list-jobs --no-pager", "any-user") # spawns a shell for `any-
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<methodname>shell_interact</methodname>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Allows you to directly interact with the guest shell.
|
||||
This should only be used during test development, not in production tests.
|
||||
Killing the interactive session with <literal>Ctrl-d</literal> or <literal>Ctrl-c</literal> also ends the guest session.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
|
||||
|
@ -21,6 +21,7 @@ import shutil
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
import telnetlib
|
||||
import tempfile
|
||||
import time
|
||||
import traceback
|
||||
@ -455,6 +456,16 @@ class Machine:
|
||||
return (status_code, output)
|
||||
output += chunk
|
||||
|
||||
def shell_interact(self) -> None:
|
||||
"""Allows you to interact with the guest shell
|
||||
|
||||
Should only be used during test development, not in the production test."""
|
||||
self.connect()
|
||||
self.log("Terminal is ready (there is no prompt):")
|
||||
telnet = telnetlib.Telnet()
|
||||
telnet.sock = self.shell # type: ignore
|
||||
telnet.interact()
|
||||
|
||||
def succeed(self, *commands: str) -> str:
|
||||
"""Execute each command and check that it succeeds."""
|
||||
output = ""
|
||||
|
Loading…
Reference in New Issue
Block a user