All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Martincoski <ricardo.martincoski@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 4/9] support/testing: use pexpect.sendline directly
Date: Wed, 28 Jun 2017 23:45:44 -0300	[thread overview]
Message-ID: <20170629024549.30484-5-ricardo.martincoski@gmail.com> (raw)
In-Reply-To: <20170629024549.30484-1-ricardo.martincoski@gmail.com>

When using pexpect there is no need for a helper function. Just use
sendline() directly everywhere.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
 support/testing/infra/emulator.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py
index 55110db401..e488d8ac6c 100644
--- a/support/testing/infra/emulator.py
+++ b/support/testing/infra/emulator.py
@@ -80,9 +80,6 @@ class Emulator(object):
         # works as expected.
         return data.replace("\r\r", "\r")
 
-    def __write(self, wstr):
-        self.qemu.send(wstr)
-
     # Wait for the login prompt to appear, and then login as root with
     # the provided password, or no password if not specified.
     def login(self, password=None):
@@ -91,10 +88,10 @@ class Emulator(object):
             self.logfile.write("==> System does not boot")
             raise SystemError("System does not boot")
 
-        self.__write("root\n")
+        self.qemu.sendline("root")
         if password:
             self.__read_until("Password:")
-            self.__write(password + "\n")
+            self.qemu.sendline(password)
         self.__read_until("# ")
         if "# " not in self.log:
             raise SystemError("Cannot login")
@@ -103,12 +100,12 @@ class Emulator(object):
     # Run the given 'cmd' on the target
     # return a tuple (output, exit_code)
     def run(self, cmd):
-        self.__write(cmd + "\n")
+        self.qemu.sendline(cmd)
         output = self.__read_until("# ")
         output = output.strip().splitlines()
         output = output[1:len(output)-1]
 
-        self.__write("echo $?\n")
+        self.qemu.sendline("echo $?")
         exit_code = self.__read_until("# ")
         exit_code = exit_code.strip().splitlines()[1]
         exit_code = int(exit_code)
-- 
2.11.0

  parent reply	other threads:[~2017-06-29  2:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29  2:45 [Buildroot] [PATCH 0/9] support/testing: run tests in parallel Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 1/9] support/testing: use pexpect in emulator Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 2/9] support/testing: use qemu stdio " Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 3/9] support/testing: let pexpect write stdout to log Ricardo Martincoski
2017-06-29  2:45 ` Ricardo Martincoski [this message]
2017-06-29  2:45 ` [Buildroot] [PATCH 5/9] support/testing: use pexpect.expect directly Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 6/9] support/testing: fix code style in emulator Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 7/9] support/testing: allow to set BR2_JLEVEL Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 8/9] support/testing: run testcases in parallel Ricardo Martincoski
2017-06-29  2:45 ` [Buildroot] [PATCH 9/9] support/testing: large timeout for login prompt Ricardo Martincoski
2017-07-01 17:41 ` [Buildroot] [PATCH 0/9] support/testing: run tests in parallel Thomas Petazzoni

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=20170629024549.30484-5-ricardo.martincoski@gmail.com \
    --to=ricardo.martincoski@gmail.com \
    --cc=buildroot@busybox.net \
    /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.