All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Goldish <mgoldish@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Cc: Michael Goldish <mgoldish@redhat.com>
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	[thread overview]
Message-ID: <1253459790-17859-1-git-send-email-mgoldish@redhat.com> (raw)

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 <mgoldish@redhat.com>
---
 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_"
-- 
1.5.4.1


             reply	other threads:[~2009-09-20 15:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-20 15:16 Michael Goldish [this message]
2009-09-20 15:16 ` [KVM-AUTOTEST PATCH 2/4] KVM test: rss.cpp: send characters to the console window rather than directly to STDIN Michael Goldish
2009-09-20 15:16   ` [KVM-AUTOTEST PATCH 3/4] KVM test: WinXP-64-rss.steps: modify first barrier Michael Goldish
2009-09-20 15:16     ` [KVM-AUTOTEST PATCH 4/4] KVM test: kvm_subprocess: minimize the number of modules imported by the server Michael Goldish
2009-09-21  9:51   ` [Autotest] [KVM-AUTOTEST PATCH 2/4] KVM test: rss.cpp: send characters to the console window rather than directly to STDIN Yolkfull Chow
2009-10-05 19:25 ` [Autotest] [KVM-AUTOTEST PATCH 1/4] KVM test: allow setting shell line separator string in the config file Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1253459790-17859-1-git-send-email-mgoldish@redhat.com \
    --to=mgoldish@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.