From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 4750FA053A;
	Tue,  4 Aug 2020 16:09:29 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id F2C401C0CD;
	Tue,  4 Aug 2020 16:08:10 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id 7933B1C0B6
 for <dev@dpdk.org>; Tue,  4 Aug 2020 16:08:08 +0200 (CEST)
IronPort-SDR: 4PZj2uP2fj7cDQfKMrnlDTcNSwqS8pT2mwXmJ4dmCQKcB5TcqLap28BmglMW8AdWOfGOF3gPdo
 5+PB3JguwaIA==
X-IronPort-AV: E=McAfee;i="6000,8403,9702"; a="237173556"
X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="237173556"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga006.jf.intel.com ([10.7.209.51])
 by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 04 Aug 2020 07:08:08 -0700
IronPort-SDR: QD9ZCRga0Am8q5UF8EqoF6G5YNxz/Zf+uKtP+/es/lrhXNONeJj2V7AYEXwObydhq6DyZKwFDn
 ri1Razxxmdsg==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="292578232"
Received: from silpixa00389033.ir.intel.com (HELO
 silpixa00389033.ger.corp.intel.com) ([10.237.223.171])
 by orsmga006.jf.intel.com with ESMTP; 04 Aug 2020 07:08:06 -0700
From: Louise Kilheeney <louise.kilheeney@intel.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, bruce.richardson@intel.com,
 robin.jarry@6wind.com, Louise Kilheeney <louise.kilheeney@intel.com>
Date: Tue,  4 Aug 2020 15:07:35 +0100
Message-Id: <20200804140738.35317-7-louise.kilheeney@intel.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20200804140738.35317-1-louise.kilheeney@intel.com>
References: <20200522132320.26373-1-louise.kilheeney@intel.com>
 <20200804140738.35317-1-louise.kilheeney@intel.com>
Subject: [dpdk-dev] [PATCH v4 6/9] app/test: support python3 only
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Changed script to explicitly use python3 only to avoid
maintaining python 2 and removed deprecation notice.

Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
---
 app/test/autotest.py            |  7 +------
 app/test/autotest_data.py       |  1 +
 app/test/autotest_runner.py     | 21 ++++++++-------------
 app/test/autotest_test_funcs.py |  1 +
 mk/rte.sdktest.mk               |  4 ++--
 5 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/app/test/autotest.py b/app/test/autotest.py
index cf7584ccd7..9eef1efbe5 100644
--- a/app/test/autotest.py
+++ b/app/test/autotest.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2014 Intel Corporation
 
 # Script that uses either test app or qemu controlled by python-pexpect
-from __future__ import print_function
 import autotest_data
 import autotest_runner
 import sys
@@ -17,10 +16,6 @@ def usage():
     usage()
     sys.exit(1)
 
-if sys.version_info.major < 3:
-    print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
-    print("Please use Python 3 instead", file=sys.stderr)
-
 target = sys.argv[2]
 
 test_whitelist = None
diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 4b7da45e09..097638941f 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2014 Intel Corporation
 
diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
index 95e74c760d..998fe57a55 100644
--- a/app/test/autotest_runner.py
+++ b/app/test/autotest_runner.py
@@ -1,10 +1,10 @@
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2014 Intel Corporation
 
 # The main logic behind running autotests in parallel
 
-from __future__ import print_function
-import StringIO
+import io
 import csv
 from multiprocessing import Pool, Queue
 import pexpect
@@ -50,11 +50,7 @@ def first_cpu_on_node(node_nr):
                 map(os.path.basename, cpu_path)
             )
     )
-    # for compatibility between python 3 and 2 we need to make interable out
-    # of filter return as it returns list in python 2 and a generator in 3
-    m = next(iter(cpu_name))
-    return int(m.group(1))
-
+    return int(next(cpu_name).group(1))
 
 pool_child = None  # per-process child
 
@@ -78,7 +74,7 @@ def pool_init(queue, result_queue):
     cmdline = "%s %s" % (cmdline, prefix_cmdline)
 
     # prepare logging of init
-    startuplog = StringIO.StringIO()
+    startuplog = io.StringIO()
 
     # run test app
     try:
@@ -86,8 +82,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):
             pool_child.close()
@@ -138,7 +133,7 @@ def run_test(target, test):
     # create log buffer for each test
     # in multiprocessing environment, the logging would be
     # interleaved and will create a mess, hence the buffering
-    logfile = StringIO.StringIO()
+    logfile = io.StringIO()
     pool_child.logfile = logfile
 
     # make a note when the test started
@@ -210,9 +205,9 @@ def __init__(self, cmdline, target, blacklist, whitelist, n_processes):
         # parse the binary for available test commands
         binary = cmdline.split()[0]
         stripped = 'not stripped' not in \
-                   subprocess.check_output(['file', binary])
+                   subprocess.check_output(['file', binary]).decode()
         if not stripped:
-            symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
+            symbols = subprocess.check_output(['nm', binary]).decode()
             self.avail_cmds = re.findall('test_register_(\w+)', symbols)
         else:
             self.avail_cmds = None
diff --git a/app/test/autotest_test_funcs.py b/app/test/autotest_test_funcs.py
index 26688b7132..775dfd1dc5 100644
--- a/app/test/autotest_test_funcs.py
+++ b/app/test/autotest_test_funcs.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2010-2014 Intel Corporation
 
diff --git a/mk/rte.sdktest.mk b/mk/rte.sdktest.mk
index ad7ef138f0..81eff0c08f 100644
--- a/mk/rte.sdktest.mk
+++ b/mk/rte.sdktest.mk
@@ -49,7 +49,7 @@ test test-fast test-perf test-drivers test-dump:
 	@mkdir -p $(AUTOTEST_DIR) ; \
 	cd $(AUTOTEST_DIR) ; \
 	if [ -f $(RTE_OUTPUT)/app/test ]; then \
-		python $(RTE_SDK)/app/test/autotest.py \
+		python3 $(RTE_SDK)/app/test/autotest.py \
 			$(RTE_OUTPUT)/app/test \
 			$(RTE_TARGET) \
 			$(BLACKLIST) $(WHITELIST); \
@@ -66,7 +66,7 @@ coverage:
 		python3 $(RTE_SDK)/test/cmdline_test/cmdline_test.py \
 			$(RTE_OUTPUT)/app/cmdline_test; \
 		ulimit -S -n 100 ; \
-		python $(RTE_SDK)/app/test/autotest.py \
+		python3 $(RTE_SDK)/app/test/autotest.py \
 			$(RTE_OUTPUT)/app/test \
 			$(RTE_TARGET) \
 			$(BLACKLIST) $(WHITELIST) ; \
-- 
2.17.1