Skip to content

Commit

Permalink
gracefully handle non-UTF-8 output generated by implementations (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Feb 29, 2024
1 parent cc58623 commit 9b35b4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _check_impl_is_compliant(self, name: str) -> bool:
)
if not self._is_unsupported(output.stdout.splitlines()):
logging.error("%s client not compliant.", name)
logging.debug("%s", output.stdout.decode("utf-8"))
logging.debug("%s", output.stdout.decode("utf-8", errors="replace"))
self.compliant[name] = False
return False
logging.debug("%s client compliant.", name)
Expand All @@ -166,7 +166,7 @@ def _check_impl_is_compliant(self, name: str) -> bool:
)
if not self._is_unsupported(output.stdout.splitlines()):
logging.error("%s server not compliant.", name)
logging.debug("%s", output.stdout.decode("utf-8"))
logging.debug("%s", output.stdout.decode("utf-8", errors="replace"))
self.compliant[name] = False
return False
logging.debug("%s server compliant.", name)
Expand Down Expand Up @@ -310,7 +310,9 @@ def _copy_logs(self, container: str, dir: tempfile.TemporaryDirectory):
)
if r.returncode != 0:
logging.info(
"Copying logs from %s failed: %s", container, r.stdout.decode("utf-8")
"Copying logs from %s failed: %s",
container,
r.stdout.decode("utf-8", errors="replace"),
)

def _run_testcase(
Expand Down Expand Up @@ -393,7 +395,7 @@ def _run_test(
output = ex.stdout
expired = True

logging.debug("%s", output.decode("utf-8"))
logging.debug("%s", output.decode("utf-8", errors="replace"))

if expired:
logging.debug("Test failed: took longer than %ds.", testcase.timeout())
Expand All @@ -404,7 +406,7 @@ def _run_test(
stderr=subprocess.STDOUT,
timeout=60,
)
logging.debug("%s", r.stdout.decode("utf-8"))
logging.debug("%s", r.stdout.decode("utf-8", errors="replace"))

# copy the pcaps from the simulator
self._copy_logs("sim", sim_log_dir)
Expand Down

0 comments on commit 9b35b4d

Please sign in to comment.