From patchwork Tue May 11 09:03:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 98648 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4B8wn0v015391 for ; Tue, 11 May 2010 08:58:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932300Ab0EKI63 (ORCPT ); Tue, 11 May 2010 04:58:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9113 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932311Ab0EKI61 (ORCPT ); Tue, 11 May 2010 04:58:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4B8wQmk018909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 May 2010 04:58:27 -0400 Received: from localhost.localdomain ([10.66.91.25]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4B8wOIK023329; Tue, 11 May 2010 04:58:25 -0400 Subject: [PATCH v2 01/10] KVM test: Introduce prompt assist To: lmr@redhat.com, autotest@test.kernel.org From: Jason Wang Cc: kvm@vger.kernel.org Date: Tue, 11 May 2010 17:03:18 +0800 Message-ID: <20100511090318.19914.90598.stgit@localhost.localdomain> In-Reply-To: <20100511083338.19914.7719.stgit@localhost.localdomain> References: <20100511083338.19914.7719.stgit@localhost.localdomain> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 11 May 2010 08:58:49 +0000 (UTC) diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 25f3c8c..11f2b1a 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): """ 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) - + @param prompt_assist: An assistant string sent before the pattern + 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*$",