From patchwork Sun Sep 20 15:16:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 48903 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8KFJPPP015064 for ; Sun, 20 Sep 2009 15:19:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbZITPTT (ORCPT ); Sun, 20 Sep 2009 11:19:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753645AbZITPTT (ORCPT ); Sun, 20 Sep 2009 11:19:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13716 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753435AbZITPTT (ORCPT ); Sun, 20 Sep 2009 11:19:19 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8KFJMD0002200; Sun, 20 Sep 2009 11:19:22 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8KFJLKj014377; Sun, 20 Sep 2009 11:19:21 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n8KFJJCX001335; Sun, 20 Sep 2009 11:19:20 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 1/4] KVM test: allow setting shell line separator string in the config file Date: Sun, 20 Sep 2009 18:16:27 +0300 Message-Id: <1253459790-17859-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The shell line separator string is appended to strings sent by sendline(). The string is controlled by the parameter shell_linesep. It defaults to "\n". Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.cfg.sample | 1 + client/tests/kvm/kvm_utils.py | 12 ++++++------ client/tests/kvm/kvm_vm.py | 7 ++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 38f5a5a..540d0a2 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -364,6 +364,7 @@ variants: shell_prompt = "^\w:\\.*>\s*$" username = Administrator password = 123456 + shell_linesep = "\r\n" shell_client = nc shell_port = 22 # File transfers are currently unsupported diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py index 88299be..53b664a 100644 --- a/client/tests/kvm/kvm_utils.py +++ b/client/tests/kvm/kvm_utils.py @@ -576,7 +576,7 @@ def scp_from_remote(host, port, username, password, remote_path, local_path, return remote_scp(command, password, timeout) -def ssh(host, port, username, password, prompt, timeout=10): +def ssh(host, port, username, password, prompt, linesep="\n", timeout=10): """ Log into a remote host (guest) using SSH. @@ -591,10 +591,10 @@ def ssh(host, port, username, password, prompt, timeout=10): """ command = ("ssh -o UserKnownHostsFile=/dev/null -p %s %s@%s" % (port, username, host)) - return remote_login(command, password, prompt, "\n", timeout) + return remote_login(command, password, prompt, linesep, timeout) -def telnet(host, port, username, password, prompt, timeout=10): +def telnet(host, port, username, password, prompt, linesep="\n", timeout=10): """ Log into a remote host (guest) using Telnet. @@ -608,10 +608,10 @@ def telnet(host, port, username, password, prompt, timeout=10): @return: kvm_spawn object on success and None on failure. """ command = "telnet -l %s %s %s" % (username, host, port) - return remote_login(command, password, prompt, "\r\n", timeout) + return remote_login(command, password, prompt, linesep, timeout) -def netcat(host, port, username, password, prompt, timeout=10): +def netcat(host, port, username, password, prompt, linesep="\n", timeout=10): """ Log into a remote host (guest) using Netcat. @@ -625,7 +625,7 @@ def netcat(host, port, username, password, prompt, timeout=10): @return: kvm_spawn object on success and None on failure. """ command = "nc %s %s" % (host, port) - return remote_login(command, password, prompt, "\n", timeout) + return remote_login(command, password, prompt, linesep, timeout) # The following are utility functions related to ports. diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 55220f9..07ceb6d 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -669,6 +669,7 @@ class VM: username = self.params.get("username", "") password = self.params.get("password", "") prompt = self.params.get("shell_prompt", "[\#\$]") + linesep = eval("'%s'" % self.params.get("shell_linesep", r"\n")) client = self.params.get("shell_client") address = self.get_address(nic_index) port = self.get_port(int(self.params.get("shell_port"))) @@ -679,13 +680,13 @@ class VM: if client == "ssh": session = kvm_utils.ssh(address, port, username, password, - prompt, timeout) + prompt, linesep, timeout) elif client == "telnet": session = kvm_utils.telnet(address, port, username, password, - prompt, timeout) + prompt, linesep, timeout) elif client == "nc": session = kvm_utils.netcat(address, port, username, password, - prompt, timeout) + prompt, linesep, timeout) if session: session.set_status_test_command(self.params.get("status_test_"