DPDK patches and discussions
 help / color / mirror / Atom feed
From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
To: dev <dev@dpdk.org>
Cc: Luca Boccassi <bluca@debian.org>,
	Christian Ehrhardt <christian.ehrhardt@canonical.com>
Subject: [dpdk-dev] [PATCH] autotest: fix pexpect in python3
Date: Thu,  7 May 2020 14:38:07 +0200	[thread overview]
Message-ID: <20200507123807.2453227-1-christian.ehrhardt@canonical.com> (raw)

In python3 pexpect wants by default a BytesIO stream as log buffer.
Otherwise it will (silently masked since we just return false)
  File "/usr/share/dpdk/test/autotest_runner.py", line 22, in wait_prompt
    child.sendline()
  File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 555, in sendline
    return self.send(s + self.linesep)
  File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 543, in send
    self._log(s, 'send')
  File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 126, in _log
    self.logfile.write(s)

We have plenty of other code writing and using this buffer.
So instead of changing the type and modifying many more places we tell the
spawn [1] method to encode things right away - then the rest behaves as it
did with python2.

[1]: https://pexpect.readthedocs.io/en/stable/api/pexpect.html#spawn-class

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
---
 app/test/autotest_runner.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
index dfa5f2b2dd..92d4e6e41a 100644
--- a/app/test/autotest_runner.py
+++ b/app/test/autotest_runner.py
@@ -84,7 +84,7 @@ def pool_init(queue, result_queue):
         print("\n%s %s\n" % ("=" * 20, prefix), file=startuplog)
         print("\ncmdline=%s" % cmdline, file=startuplog)
 
-        pool_child = pexpect.spawn(cmdline, logfile=startuplog)
+        pool_child = pexpect.spawn(cmdline, logfile=startuplog, encoding='utf-8')
 
         # wait for target to boot
         if not wait_prompt(pool_child):
-- 
2.26.0


             reply	other threads:[~2020-05-07 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 12:38 Christian Ehrhardt [this message]
2020-05-07 13:17 ` Luca Boccassi

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=20200507123807.2453227-1-christian.ehrhardt@canonical.com \
    --to=christian.ehrhardt@canonical.com \
    --cc=bluca@debian.org \
    --cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).