]> git.sur5r.net Git - u-boot/commitdiff
Merge git://git.denx.de/u-boot-dm
authorTom Rini <trini@konsulko.com>
Wed, 11 Jul 2018 13:40:38 +0000 (09:40 -0400)
committerTom Rini <trini@konsulko.com>
Wed, 11 Jul 2018 13:40:38 +0000 (09:40 -0400)
test/py/conftest.py
test/py/test.py
test/py/tests/test_fit.py
test/py/tests/test_hush_if_test.py
test/py/tests/test_vboot.py
test/py/u_boot_console_sandbox.py
test/py/u_boot_spawn.py
test/py/u_boot_utils.py

index 446d8cb6faf1e23eab5ac14b1d54037c588b2143..5c658b8c4840fce1e8c0e143a29c22f7f6f2dbdf 100644 (file)
@@ -18,11 +18,15 @@ import os
 import os.path
 import pytest
 from _pytest.runner import runtestprotocol
-import ConfigParser
 import re
 import StringIO
 import sys
 
+try:
+    import configparser
+except:
+    import ConfigParser as configparser
+
 # Globals: The HTML log file, and the connection to the U-Boot console.
 log = None
 console = None
@@ -166,7 +170,7 @@ def pytest_configure(config):
         with open(dot_config, 'rt') as f:
             ini_str = '[root]\n' + f.read()
             ini_sio = StringIO.StringIO(ini_str)
-            parser = ConfigParser.RawConfigParser()
+            parser = configparser.RawConfigParser()
             parser.readfp(ini_sio)
             ubconfig.buildconfig.update(parser.items('root'))
 
@@ -586,7 +590,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?
 
index 04baf8df3ba5581df53629c4da8f451b47be5394..a5140945d4b95107de3c118f9dac339fec82101b 100755 (executable)
@@ -7,6 +7,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
@@ -26,7 +28,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)
index e407ccc05a29dc1a54e00be164d620efba223136..34696e976796baf22269e66cbac55833b422212b 100755 (executable)
@@ -3,6 +3,8 @@
 #
 # Sanity check of the FIT handling in U-Boot
 
+from __future__ import print_function
+
 import os
 import pytest
 import struct
@@ -141,7 +143,7 @@ def test_fit(u_boot_console):
         Returns:
             Contents of file as a string
         """
-        with open(fname, 'r') as fd:
+        with open(fname, 'rb') as fd:
             return fd.read()
 
     def make_dtb():
@@ -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):
index 1196e0a53ff99a4fec54fb84d80deba078280fb7..bba8d41d9648c9d57f9f99571bffbf844de9d754 100644 (file)
@@ -148,7 +148,7 @@ def test_hush_if_test_host_file_exists(u_boot_console):
     exec_hush_if(u_boot_console, expr, False)
 
     try:
-        with file(test_file, 'wb'):
+        with open(test_file, 'wb'):
             pass
         assert os.path.exists(test_file)
 
index 3d25ec3d66678fcc44f2946bd811f677ad597543..e9cbd57fbab7c1ac3fa943328a566ef45080f059 100644 (file)
@@ -210,8 +210,8 @@ def test_vboot(u_boot_console):
     public_exponent = 65537
     util.run_and_log(cons, 'openssl genpkey -algorithm RSA -out %sdev.key '
                      '-pkeyopt rsa_keygen_bits:2048 '
-                     '-pkeyopt rsa_keygen_pubexp:%d '
-                     '2>/dev/null'  % (tmpdir, public_exponent))
+                     '-pkeyopt rsa_keygen_pubexp:%d' %
+                     (tmpdir, public_exponent))
 
     # Create a certificate containing the public key
     util.run_and_log(cons, 'openssl req -batch -new -x509 -key %sdev.key -out '
index a616cfb49fc7a06a97af6e6b19fd93b804f3cf0e..778f6d0983d621e86a16ae825d20dc5b5ee7defc 100644 (file)
@@ -41,7 +41,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]
@@ -81,7 +81,7 @@ class ConsoleSandbox(ConsoleBase):
 
         p = self.p
         self.p = None
-        for i in xrange(100):
+        for i in range(100):
             ret = not p.isalive()
             if ret:
                 break
index 108498a9a4b7fb9cfd07f3c8c228db26e679dfa0..b011a3e3da255f5301163973bc52f72af9da3a32 100644 (file)
@@ -58,7 +58,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:
@@ -134,7 +134,7 @@ class Spawn(object):
             the expected time.
         """
 
-        for pi in xrange(len(patterns)):
+        for pi in range(len(patterns)):
             if type(patterns[pi]) == type(''):
                 patterns[pi] = re.compile(patterns[pi])
 
@@ -143,7 +143,7 @@ class Spawn(object):
             while True:
                 earliest_m = None
                 earliest_pi = None
-                for pi in xrange(len(patterns)):
+                for pi in range(len(patterns)):
                     pattern = patterns[pi]
                     m = pattern.search(self.buf)
                     if not m:
@@ -198,7 +198,7 @@ class Spawn(object):
         """
 
         os.close(self.fd)
-        for i in xrange(100):
+        for i in range(100):
             if not self.isalive():
                 break
             time.sleep(0.1)
index bb31e57b279993e3de4055bee6d0ff6a2a8d1dd0..d68d1dd10541d963e93c610d9a684330c72c9830 100644 (file)
@@ -120,7 +120,7 @@ def wait_until_open_succeeds(fn):
         An open file handle to the file.
     """
 
-    for i in xrange(100):
+    for i in range(100):
         fh = attempt_to_open_file(fn)
         if fh:
             return fh
@@ -143,7 +143,7 @@ def wait_until_file_open_fails(fn, ignore_errors):
         Nothing.
     """
 
-    for i in xrange(100):
+    for i in range(100):
         fh = attempt_to_open_file(fn)
         if not fh:
             return