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 54A69A00C5; Thu, 7 May 2020 09:27:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C3E5B1DA52; Thu, 7 May 2020 09:27:18 +0200 (CEST) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by dpdk.org (Postfix) with ESMTP id ACFD01D617 for ; Thu, 7 May 2020 09:27:17 +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 1jWavW-0002kJ-CI; Thu, 07 May 2020 07:26:38 +0000 From: Christian Ehrhardt To: dev Cc: Luca Boccassi , Christian Ehrhardt Date: Thu, 7 May 2020 09:26:29 +0200 Message-Id: <20200507072629.2374881-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 for pure python3 environments 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" Without this fix in a pure python3 environment this will run into issues like: ModuleNotFoundError: No module named 'StringIO' or later string encoding issues on check_output. Signed-off-by: Christian Ehrhardt --- app/test/autotest_runner.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py index 95e74c760d..dfa5f2b2dd 100644 --- a/app/test/autotest_runner.py +++ b/app/test/autotest_runner.py @@ -4,7 +4,7 @@ # 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 @@ -45,11 +45,9 @@ def get_numa_nodes(): def first_cpu_on_node(node_nr): cpu_path = glob.glob("/sys/devices/system/node/node%d/cpu*" % node_nr) r = re.compile(r"cpu(\d+)") - cpu_name = filter(None, - map(r.match, - map(os.path.basename, cpu_path) - ) - ) + cpu_name = [_f for _f in map(r.match, + list(map(os.path.basename, cpu_path)) + ) if _f] # 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)) @@ -78,7 +76,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: @@ -138,7 +136,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,7 +208,7 @@ 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('utf-8') if not stripped: symbols = subprocess.check_output(['nm', binary]).decode('utf-8') self.avail_cmds = re.findall('test_register_(\w+)', symbols) -- 2.26.0