From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D836CA00C5; Thu, 7 May 2020 14:38:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4FCAD1DC60; Thu, 7 May 2020 14:38:11 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id 755901DBFD for ; Thu, 7 May 2020 14:38:09 +0200 (CEST) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jWfmz-0006V5-72; Thu, 07 May 2020 12:38:09 +0000 From: Christian Ehrhardt To: dev Cc: Luca Boccassi , Christian Ehrhardt Date: Thu, 7 May 2020 14:38:07 +0200 Message-Id: <20200507123807.2453227-1-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] autotest: fix pexpect in python3 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- 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