From patchwork Thu Sep 14 20:06:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Burton X-Patchwork-Id: 813930 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xtV2B0vP0z9s7f for ; Fri, 15 Sep 2017 06:07:46 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BAF66C21E68; Thu, 14 Sep 2017 20:07:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 67B8DC21E26; Thu, 14 Sep 2017 20:07:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5EF22C21DA4; Thu, 14 Sep 2017 20:07:18 +0000 (UTC) Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by lists.denx.de (Postfix) with ESMTP id 18102C21DA4 for ; Thu, 14 Sep 2017 20:07:17 +0000 (UTC) Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id F1E6C78475BEC; Thu, 14 Sep 2017 21:07:10 +0100 (IST) Received: from localhost (10.20.1.88) by hhmail02.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Thu, 14 Sep 2017 21:07:15 +0100 From: Paul Burton To: Date: Thu, 14 Sep 2017 13:06:27 -0700 Message-ID: <20170914200634.17818-2-paul.burton@imgtec.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170914200634.17818-1-paul.burton@imgtec.com> References: <20170914200634.17818-1-paul.burton@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [10.20.1.88] Cc: Stephen Warren , =?utf-8?q?Stefan_Br=C3=BCns?= Subject: [U-Boot] [PATCH 1/8] test/py: Make print statements python 3.x safe X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In python 3.x print must be called as a function rather than used as a statement. Update uses of print to the function call syntax in order to be python 3.x safe. Signed-off-by: Paul Burton --- test/py/conftest.py | 2 +- test/py/test.py | 6 ++++-- test/py/tests/test_fit.py | 12 +++++++----- test/py/u_boot_console_sandbox.py | 2 +- test/py/u_boot_spawn.py | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/py/conftest.py b/test/py/conftest.py index 65e1d75626..ced96f1006 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -545,7 +545,7 @@ def pytest_runtest_protocol(item, nextitem): # is fixed, if this exception still exists, it will then be logged as # part of the test's stdout. import traceback - print 'Exception occurred while logging runtest status:' + print('Exception occurred while logging runtest status:') traceback.print_exc() # FIXME: Can we force a test failure here? diff --git a/test/py/test.py b/test/py/test.py index 74e560a4d3..215f2651a7 100755 --- a/test/py/test.py +++ b/test/py/test.py @@ -8,6 +8,8 @@ # Wrapper script to invoke pytest with the directory name that contains the # U-Boot tests. +from __future__ import print_function + import os import os.path import sys @@ -27,7 +29,7 @@ except: traceback.print_exc() # Hint to the user that they likely simply haven't installed the required # dependencies. - print >>sys.stderr, ''' + print(''' exec(py.test) failed; perhaps you are missing some dependencies? -See test/py/README.md for the list.''' +See test/py/README.md for the list.''', file=sys.stderr) sys.exit(1) diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 7e6b96dae4..29b2491f89 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -4,6 +4,8 @@ # # Sanity check of the FIT handling in U-Boot +from __future__ import print_function + import os import pytest import struct @@ -153,7 +155,7 @@ def test_fit(u_boot_console): src = make_fname('u-boot.dts') dtb = make_fname('u-boot.dtb') with open(src, 'w') as fd: - print >> fd, base_fdt + print(base_fdt, file=fd) util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb]) return dtb @@ -167,7 +169,7 @@ def test_fit(u_boot_console): """ its = make_fname('test.its') with open(its, 'w') as fd: - print >> fd, base_its % params + print(base_its % params, file=fd) return its def make_fit(mkimage, params): @@ -186,7 +188,7 @@ def test_fit(u_boot_console): its = make_its(params) util.run_and_log(cons, [mkimage, '-f', its, fit]) with open(make_fname('u-boot.dts'), 'w') as fd: - print >> fd, base_fdt + print(base_fdt, file=fd) return fit def make_kernel(filename, text): @@ -202,7 +204,7 @@ def test_fit(u_boot_console): for i in range(100): data += 'this %s %d is unlikely to boot\n' % (text, i) with open(fname, 'w') as fd: - print >> fd, data + print(data, file=fd) return fname def make_ramdisk(filename, text): @@ -216,7 +218,7 @@ def test_fit(u_boot_console): for i in range(100): data += '%s %d was seldom used in the middle ages\n' % (text, i) with open(fname, 'w') as fd: - print >> fd, data + print(data, file=fd) return fname def find_matching(text, match): diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 647e1f879f..9a2fe9cb59 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -42,7 +42,7 @@ class ConsoleSandbox(ConsoleBase): bcfg = self.config.buildconfig config_spl = bcfg.get('config_spl', 'n') == 'y' fname = '/spl/u-boot-spl' if config_spl else '/u-boot' - print fname + print(fname) cmd = [] if self.config.gdbserver: cmd += ['gdbserver', self.config.gdbserver] diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 3a0fbfad90..15ca4ac838 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -59,7 +59,7 @@ class Spawn(object): os.chdir(cwd) os.execvp(args[0], args) except: - print 'CHILD EXECEPTION:' + print('CHILD EXECEPTION:') import traceback traceback.print_exc() finally: