Merge branch 'bugfix/ttfw_example_test_fails_port_remains_open_v4.0' into 'release/v4.0'

ci: Fix CI issue if one example test fails, and if serial port returns some noise (v4.0)

See merge request espressif/esp-idf!12383
This commit is contained in:
Angus Gratton 2021-02-28 23:57:08 +00:00
commit 4db922612a
2 changed files with 8 additions and 4 deletions

View File

@ -40,6 +40,7 @@ If they using different port then need to implement their DUTPort class as well.
from __future__ import print_function
import time
import re
import sys
import threading
import copy
import functools
@ -78,11 +79,12 @@ def _expect_lock(func):
def _decode_data(data):
""" for python3, if the data is bytes, then decode it to string """
if isinstance(data, bytes):
# convert bytes to string
# convert bytes to string. This is a bit of a hack, we know that we want to log this
# later so encode to the stdout encoding with backslash escapes for anything non-encodable
try:
data = data.decode("utf-8", "ignore")
except UnicodeDecodeError:
data = data.decode("iso8859-1", )
return data.decode(sys.stdout.encoding, "backslashreplace")
except UnicodeDecodeError: # Python <3.5 doesn't support backslashreplace
return data.decode(sys.stdout.encoding, "replace")
return data

View File

@ -18,6 +18,7 @@ import threading
import functools
import netifaces
import traceback
from . import EnvConfig
@ -184,6 +185,7 @@ class Env(object):
try:
dut.close()
except Exception as e:
traceback.print_exc()
dut_close_errors.append(e)
self.allocated_duts = dict()
return dut_close_errors