summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorNathan Rossi <nathan@nathanrossi.com>2019-09-27 05:31:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-09-30 16:55:21 +0100
commitec1104fd7fc0311e918fa832a566d3c8aedc2f11 (patch)
treea87481ad426890a557e5946d7974c5c97cdb5bed /meta
parent02a334c98fef6a8af9ee3dcd29815dbe6d145d3c (diff)
downloadpoky-ec1104fd7fc0311e918fa832a566d3c8aedc2f11.tar.gz
oeqa/core/case.py: Encode binary data of log
Do not decode the log content into a string only to re-encode it as binary data again. Some logs might un-intentionally contain bytes that do not decode as utf-8, as such preserve the log file content as it was on disk. Handle the decoding on the resulttool side, but also handle the failure to decode the data. (From OE-Core rev: 20531dc0b8f76a6e37cc856f36cd94077b6aba50) Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/core/case.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/meta/lib/oeqa/core/case.py b/meta/lib/oeqa/core/case.py
index 180635ac6c..aae451fef2 100644
--- a/meta/lib/oeqa/core/case.py
+++ b/meta/lib/oeqa/core/case.py
@@ -59,7 +59,7 @@ class OEPTestResultTestCase:
59 """ 59 """
60 @staticmethod 60 @staticmethod
61 def _compress_log(log): 61 def _compress_log(log):
62 logdata = log.encode("utf-8") 62 logdata = log.encode("utf-8") if isinstance(log, str) else log
63 logdata = zlib.compress(logdata) 63 logdata = zlib.compress(logdata)
64 logdata = base64.b64encode(logdata).decode("utf-8") 64 logdata = base64.b64encode(logdata).decode("utf-8")
65 return {"compressed" : logdata} 65 return {"compressed" : logdata}
@@ -80,7 +80,7 @@ class OEPTestResultTestCase:
80 if log is not None: 80 if log is not None:
81 sections[section]["log"] = self._compress_log(log) 81 sections[section]["log"] = self._compress_log(log)
82 elif logfile is not None: 82 elif logfile is not None:
83 with open(logfile, "r") as f: 83 with open(logfile, "rb") as f:
84 sections[section]["log"] = self._compress_log(f.read()) 84 sections[section]["log"] = self._compress_log(f.read())
85 85
86 if duration is not None: 86 if duration is not None: