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.
pull/4369/head
Brian Daniels 2017-04-27 15:42:55 -05:00 committed by Martin Kojtal
parent 26eafd9958
commit 98a5262361
1 changed files with 9 additions and 5 deletions

View File

@ -30,9 +30,13 @@ void prep_buffer(char *tx_buffer, size_t tx_size) {
int main() { int main() {
GREENTEA_SETUP(60, "tcp_echo"); GREENTEA_SETUP(60, "tcp_echo");
EthernetInterface eth; EthernetInterface eth;
eth.connect(); int err = eth.connect();
if (err) {
printf("MBED: failed to connect with an error of %d\r\n", err);
GREENTEA_TESTSUITE_RESULT(false);
}
printf("MBED: TCPClient IP address is '%s'\n", eth.get_ip_address()); printf("MBED: TCPClient IP address is '%s'\n", eth.get_ip_address());
printf("MBED: TCPClient waiting for server IP and port...\n"); printf("MBED: TCPClient waiting for server IP and port...\n");
@ -64,12 +68,12 @@ int main() {
prep_buffer(tx_buffer, sizeof(tx_buffer)); prep_buffer(tx_buffer, sizeof(tx_buffer));
sock.send(tx_buffer, sizeof(tx_buffer)); sock.send(tx_buffer, sizeof(tx_buffer));
printf("MBED: Finished sending\r\n");
// Server will respond with HTTP GET's success code // Server will respond with HTTP GET's success code
const int ret = sock.recv(rx_buffer, sizeof(rx_buffer)); const int ret = sock.recv(rx_buffer, sizeof(rx_buffer));
printf("MBED: Finished receiving\r\n");
result = !memcmp(tx_buffer, rx_buffer, sizeof(tx_buffer)); result = !memcmp(tx_buffer, rx_buffer, sizeof(tx_buffer));
TEST_ASSERT_EQUAL(ret, sizeof(rx_buffer)); TEST_ASSERT_EQUAL(ret, sizeof(rx_buffer));
TEST_ASSERT_EQUAL(true, result); TEST_ASSERT_EQUAL(true, result);
} }