From 3b3e3c0f6c261a8c9f989d437dc261ba84467d4f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 31 Oct 2019 07:42:50 -0600 Subject: patman: Adjust 'command' to return strings instead of bytes At present all the 'command' methods return bytes. Most of the time we actually want strings, so change this. We still need to keep the internal representation as bytes since otherwise unicode strings might break over a read() boundary (e.g. 4KB), causing errors. But we can convert the end result to strings. Add a 'binary' parameter to cover the few cases where bytes are needed. Signed-off-by: Simon Glass --- tools/binman/ftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/binman/ftest.py') diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 494e218cbc3..93507993a00 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -174,7 +174,7 @@ class TestFunctional(unittest.TestCase): cls.have_lz4 = True try: tools.Run('lz4', '--no-frame-crc', '-c', - os.path.join(cls._indir, 'u-boot.bin')) + os.path.join(cls._indir, 'u-boot.bin'), binary=True) except: cls.have_lz4 = False -- cgit v1.2.3 From b6ee0cf89f9405094cbb6047076a13e14ebc030b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 31 Oct 2019 07:43:03 -0600 Subject: binman: Convert a few tests to Python 3 Some tests have crept in with Python 2 strings and constructs. Convert then. Signed-off-by: Simon Glass --- tools/binman/ftest.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tools/binman/ftest.py') diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 93507993a00..80df0e3ca9c 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -2113,7 +2113,7 @@ class TestFunctional(unittest.TestCase): data = self.data = self._DoReadFileRealDtb('115_fdtmap.dts') fdtmap_data = data[len(U_BOOT_DATA):] magic = fdtmap_data[:8] - self.assertEqual('_FDTMAP_', magic) + self.assertEqual(b'_FDTMAP_', magic) self.assertEqual(tools.GetBytes(0, 8), fdtmap_data[8:16]) fdt_data = fdtmap_data[16:] @@ -2156,7 +2156,7 @@ class TestFunctional(unittest.TestCase): dtb = fdt.Fdt.FromData(fdt_data) fdt_size = dtb.GetFdtObj().totalsize() hdr_data = data[-8:] - self.assertEqual('BinM', hdr_data[:4]) + self.assertEqual(b'BinM', hdr_data[:4]) offset = struct.unpack('