From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: Re: [PATCH 1/9] KVM test: Introduce the prompt assist Date: Thu, 06 May 2010 12:18:50 -0300 Message-ID: <1273159130.15652.1.camel@freedom> References: <20100426095656.26268.50549.stgit@localhost.localdomain> <20100426100330.26268.68794.stgit@localhost.localdomain> <4BD81BEC.40106@redhat.com> <4BE22FB3.4000401@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: Jason Wang Return-path: In-Reply-To: <4BE22FB3.4000401@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org On Thu, 2010-05-06 at 10:55 +0800, Jason Wang wrote: > Michael Goldish wrote: > > On 04/26/2010 01:03 PM, Jason Wang wrote: > > > >> Sometimes we need to send an assist string to a session in order to > >> get the prompt especially when re-connecting to an already logged > >> serial session. This patch send the assist string before doing the > >> pattern matching of remote_login. > >> > > > > Can you give an example of a prompt assist string, and a typical usage > > example? What guests require prompt assist strings? > > > > > It was just used by serial console, consider when the first test case > have already connected to the serial console, so the second test must > send something in order to get the prompt string. But it may be better > to log out during when the session is closed. This has a upside of making things cleaner, I'd consider that. > >> Signed-off-by: Jason Wang > >> --- > >> client/tests/kvm/kvm_utils.py | 9 +++++++-- > >> 1 files changed, 7 insertions(+), 2 deletions(-) > >> > >> diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py > >> index 25f3c8c..9adbaee 100644 > >> --- a/client/tests/kvm/kvm_utils.py > >> +++ b/client/tests/kvm/kvm_utils.py > >> @@ -451,7 +451,8 @@ def check_kvm_source_dir(source_dir): > >> # The following are functions used for SSH, SCP and Telnet communication with > >> # guests. > >> > >> -def remote_login(command, password, prompt, linesep="\n", timeout=10): > >> +def remote_login(command, password, prompt, linesep="\n", timeout=10, > >> + prompt_assist = None): > >> > > ^ ^ > > These spaces do not conform with PEP 8. > > > Would change them. > > > >> """ > >> Log into a remote host (guest) using SSH or Telnet. Run the given command > >> using kvm_spawn and provide answers to the questions asked. If timeout > >> @@ -468,7 +469,8 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > >> @param timeout: The maximal time duration (in seconds) to wait for each > >> step of the login procedure (i.e. the "Are you sure" prompt, the > >> password prompt, the shell prompt, etc) > >> - > >> + @prarm prompt_assist: An assistant string sent before the pattern > >> > > > > Typo ^ > > > > > >> + matching in order to get the prompt for some kinds of shell_client. > >> @return Return the kvm_spawn object on success and None on failure. > >> """ > >> sub = kvm_subprocess.kvm_shell_session(command, > >> @@ -479,6 +481,9 @@ def remote_login(command, password, prompt, linesep="\n", timeout=10): > >> > >> logging.debug("Trying to login with command '%s'" % command) > >> > >> + if prompt_assist is not None: > >> + sub.sendline(prompt_assist) > >> + > >> while True: > >> (match, text) = sub.read_until_last_line_matches( > >> [r"[Aa]re you sure", r"[Pp]assword:\s*$", r"^\s*[Ll]ogin:\s*$", > >> > >> -- > >> To unsubscribe from this list: send the line "unsubscribe kvm" in > >> the body of a message to majordomo@vger.kernel.org > >> More majordomo info at http://vger.kernel.org/majordomo-info.html > >> > > > > > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html