Merge branch 'bugfix/tiny_test_fw_filter_invalid_serial_port' into 'master'

tiny-test-fw: filter out invalid IDF ports

See merge request idf/esp-idf!2745
This commit is contained in:
He Yin Ling 2018-07-12 19:56:48 +08:00
commit 05d74d532e

View File

@ -43,6 +43,9 @@ class IDFDUT(DUT.SerialDUT):
""" IDF DUT, extends serial with ESPTool methods """
CHIP_TYPE_PATTERN = re.compile(r"Detecting chip type[.:\s]+(.+)")
# /dev/ttyAMA0 port is listed in Raspberry Pi
# /dev/tty.Bluetooth-Incoming-Port port is listed in Mac
INVALID_PORT_PATTERN = re.compile(r"AMA|Bluetooth")
def __init__(self, name, port, log_file, app, **kwargs):
self.download_config, self.partition_table = app.process_app_info()
@ -133,8 +136,14 @@ class IDFDUT(DUT.SerialDUT):
ports = [x.device for x in list_ports.comports()]
espport = os.getenv('ESPPORT')
if not espport:
return ports
# It's a little hard filter out invalid port with `serial.tools.list_ports.grep()`:
# The check condition in `grep` is: `if r.search(port) or r.search(desc) or r.search(hwid)`.
# This means we need to make all 3 conditions fail, to filter out the port.
# So some part of the filters will not be straight forward to users.
# And negative regular expression (`^((?!aa|bb|cc).)*$`) is not easy to understand.
# Filter out invalid port by our own will be much simpler.
return [x for x in ports if not cls.INVALID_PORT_PATTERN.search(x)]
port_hint = espport.decode('utf8')
# If $ESPPORT is a valid port, make it appear first in the list