Skip to content

Commit e4ff16e

Browse files
committed
Adding failure logs to TCP echo test.
This adds some extra logs to the test for debugging purposes. Also allows the test to fail immediately if it fails to obtain an IP address.
1 parent d5ac063 commit e4ff16e

File tree

1 file changed

+9
-5
lines changed
  • features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_echo

1 file changed

+9
-5
lines changed

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_echo/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ void prep_buffer(char *tx_buffer, size_t tx_size) {
3030

3131
int main() {
3232
GREENTEA_SETUP(60, "tcp_echo");
33-
3433
EthernetInterface eth;
35-
eth.connect();
34+
int err = eth.connect();
35+
36+
if (err) {
37+
printf("MBED: failed to connect with an error of %d\r\n", err);
38+
GREENTEA_TESTSUITE_RESULT(false);
39+
}
3640

3741
printf("MBED: TCPClient IP address is '%s'\n", eth.get_ip_address());
3842
printf("MBED: TCPClient waiting for server IP and port...\n");
@@ -64,12 +68,12 @@ int main() {
6468

6569
prep_buffer(tx_buffer, sizeof(tx_buffer));
6670
sock.send(tx_buffer, sizeof(tx_buffer));
67-
71+
printf("MBED: Finished sending\r\n");
6872
// Server will respond with HTTP GET's success code
6973
const int ret = sock.recv(rx_buffer, sizeof(rx_buffer));
70-
74+
printf("MBED: Finished receiving\r\n");
75+
7176
result = !memcmp(tx_buffer, rx_buffer, sizeof(tx_buffer));
72-
7377
TEST_ASSERT_EQUAL(ret, sizeof(rx_buffer));
7478
TEST_ASSERT_EQUAL(true, result);
7579
}

0 commit comments

Comments
 (0)