From 859c160ddc872097abb3288bc3315eb502e93df3 Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Tue, 13 Dec 2016 13:17:44 +0000 Subject: [PATCH 1/2] Fix network echo test host scripts for Mac It seems that the 0 aka 'any port' doesn't work well on Mac, causing [Errno 49] Can't assign requested address errors. --- .../TESTS/mbedmicro-net/host_tests/tcp_echo_client.py | 2 +- .../TESTS/mbedmicro-net/host_tests/udp_echo_client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py index 51a3c21c147..abaf5e80459 100644 --- a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py +++ b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py @@ -128,7 +128,7 @@ def find_interface_to_target_addr(target_ip): :return: """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect((target_ip, 0)) # Target IP, Any port + s.connect((target_ip, 8000)) # Target IP, 'random' port ip = s.getsockname()[0] s.close() return ip diff --git a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py index a2882c6aa20..f348b042308 100644 --- a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py +++ b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py @@ -55,7 +55,7 @@ def find_interface_to_target_addr(target_ip): :return: """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect((target_ip, 0)) # Target IP, Any port + s.connect((target_ip, 8000)) # Target IP, 'random' port ip = s.getsockname()[0] s.close() return ip From b77f663520aee76aa541ea3777e8e16f300a12aa Mon Sep 17 00:00:00 2001 From: Bartek Szatkowski Date: Tue, 13 Dec 2016 16:11:26 +0000 Subject: [PATCH 2/2] Add defined port fallback for network echo tests The 0 aka 'any' port doesn't for on Mac, but, only, using defined port may interfere with running multiple tests on CI. --- .../TESTS/mbedmicro-net/host_tests/tcp_echo_client.py | 5 ++++- .../TESTS/mbedmicro-net/host_tests/udp_echo_client.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py index abaf5e80459..44ac15df252 100644 --- a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py +++ b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/tcp_echo_client.py @@ -128,7 +128,10 @@ def find_interface_to_target_addr(target_ip): :return: """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect((target_ip, 8000)) # Target IP, 'random' port + try: + s.connect((target_ip, 0)) # Target IP, any port + except socket.error: + s.connect((target_ip, 8000)) # Target IP, 'random' port ip = s.getsockname()[0] s.close() return ip diff --git a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py index f348b042308..9be3562da58 100644 --- a/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py +++ b/features/FEATURE_LWIP/TESTS/mbedmicro-net/host_tests/udp_echo_client.py @@ -55,7 +55,10 @@ def find_interface_to_target_addr(target_ip): :return: """ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect((target_ip, 8000)) # Target IP, 'random' port + try: + s.connect((target_ip, 0)) # Target IP, any port + except socket.error: + s.connect((target_ip, 8000)) # Target IP, 'random' port ip = s.getsockname()[0] s.close() return ip