Skip to content

Reconcile mbed trace and greentea #9954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions TESTS/netsocket/dns/asynchronous_dns_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ void ASYNCHRONOUS_DNS_CACHE()
int delay_ms = (ticker_us - started_us) / 1000;

static int delay_first = delay_ms / 2;
printf("Delays: first: %i, delay_ms: %i\n", delay_first, delay_ms);
greentea_serial->printf("Delays: first: %i, delay_ms: %i\n", delay_first, delay_ms);
// Check that cached accesses are at least twice as fast as the first one
TEST_ASSERT_TRUE(i == 0 || delay_ms <= delay_first);

printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
dns_test_hosts[0], data.addr.get_ip_address(), delay_ms);
greentea_serial->printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
dns_test_hosts[0], data.addr.get_ip_address(), delay_ms);
}
}
14 changes: 7 additions & 7 deletions TESTS/netsocket/dns/asynchronous_dns_cancel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void ASYNCHRONOUS_DNS_CANCEL()
count++;
} else {
// No memory to initiate DNS query, callback will not be called
printf("Error: No memory to initiate DNS query for %s\n", dns_test_hosts[i]);
greentea_serial->printf("Error: No memory to initiate DNS query for %s\n", dns_test_hosts[i]);
data[i].result = NSAPI_ERROR_NO_MEMORY;
data[i].value_set = true;
}
Expand All @@ -63,19 +63,19 @@ void ASYNCHRONOUS_DNS_CANCEL()

for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
if (!data[i].value_set) {
printf("DNS: query \"%s\" => cancel\n", dns_test_hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => cancel\n", dns_test_hosts[i]);
continue;
}
TEST_ASSERT(data[i].result == NSAPI_ERROR_OK || data[i].result == NSAPI_ERROR_NO_MEMORY || data[i].result == NSAPI_ERROR_DNS_FAILURE || data[i].result == NSAPI_ERROR_TIMEOUT);
if (data[i].result == NSAPI_ERROR_OK) {
printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts[i], data[i].addr.get_ip_address());
greentea_serial->printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts[i], data[i].addr.get_ip_address());
} else if (data[i].result == NSAPI_ERROR_DNS_FAILURE) {
printf("DNS: query \"%s\" => DNS failure\n", dns_test_hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => DNS failure\n", dns_test_hosts[i]);
} else if (data[i].result == NSAPI_ERROR_TIMEOUT) {
printf("DNS: query \"%s\" => timeout\n", dns_test_hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => timeout\n", dns_test_hosts[i]);
} else if (data[i].result == NSAPI_ERROR_NO_MEMORY) {
printf("DNS: query \"%s\" => no memory\n", dns_test_hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => no memory\n", dns_test_hosts[i]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions TESTS/netsocket/dns/asynchronous_dns_non_async_and_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
for (unsigned int i = 0; i < MBED_CONF_APP_DNS_TEST_HOSTS_NUM; i++) {
SocketAddress addr;
int err = get_interface()->gethostbyname(dns_test_hosts[i], &addr);
printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts[i], addr.get_ip_address());
greentea_serial->printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts[i], addr.get_ip_address());

TEST_ASSERT_EQUAL(0, err);
TEST_ASSERT((bool)addr);
Expand All @@ -49,8 +49,8 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()

TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, data.result);

printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts_second[0], data.addr.get_ip_address());
greentea_serial->printf("DNS: query \"%s\" => \"%s\"\n",
dns_test_hosts_second[0], data.addr.get_ip_address());

TEST_ASSERT(strlen(data.addr.get_ip_address()) > 1);
}
39 changes: 26 additions & 13 deletions TESTS/netsocket/dns/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#endif

#include "mbed.h"
#include "mbed_trace.h"
#include "greentea-client/test_env.h"
#include "unity.h"
#include "utest.h"
Expand Down Expand Up @@ -90,17 +91,17 @@ void do_asynchronous_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsign
TEST_ASSERT(data[i].result == NSAPI_ERROR_OK || data[i].result == NSAPI_ERROR_NO_MEMORY || data[i].result == NSAPI_ERROR_DNS_FAILURE || data[i].result == NSAPI_ERROR_TIMEOUT);
if (data[i].result == NSAPI_ERROR_OK) {
(*exp_ok)++;
printf("DNS: query \"%s\" => \"%s\"\n",
hosts[i], data[i].addr.get_ip_address());
greentea_serial->printf("DNS: query \"%s\" => \"%s\"\n",
hosts[i], data[i].addr.get_ip_address());
} else if (data[i].result == NSAPI_ERROR_DNS_FAILURE) {
(*exp_dns_failure)++;
printf("DNS: query \"%s\" => DNS failure\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => DNS failure\n", hosts[i]);
} else if (data[i].result == NSAPI_ERROR_TIMEOUT) {
(*exp_timeout)++;
printf("DNS: query \"%s\" => timeout\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => timeout\n", hosts[i]);
} else if (data[i].result == NSAPI_ERROR_NO_MEMORY) {
(*exp_no_mem)++;
printf("DNS: query \"%s\" => no memory\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => no memory\n", hosts[i]);
}
}

Expand All @@ -124,19 +125,19 @@ void do_gethostbyname(const char hosts[][DNS_TEST_HOST_LEN], unsigned int op_cou

if (err == NSAPI_ERROR_OK) {
(*exp_ok)++;
printf("DNS: query \"%s\" => \"%s\"\n",
hosts[i], address.get_ip_address());
greentea_serial->printf("DNS: query \"%s\" => \"%s\"\n",
hosts[i], address.get_ip_address());
} else if (err == NSAPI_ERROR_DNS_FAILURE) {
(*exp_dns_failure)++;
printf("DNS: query \"%s\" => DNS failure\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => DNS failure\n", hosts[i]);
} else if (err == NSAPI_ERROR_TIMEOUT) {
(*exp_timeout)++;
printf("DNS: query \"%s\" => timeout\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => timeout\n", hosts[i]);
} else if (err == NSAPI_ERROR_NO_MEMORY) {
(*exp_no_mem)++;
printf("DNS: query \"%s\" => no memory\n", hosts[i]);
greentea_serial->printf("DNS: query \"%s\" => no memory\n", hosts[i]);
} else {
printf("DNS: query \"%s\" => %d, unexpected answer\n", hosts[i], err);
greentea_serial->printf("DNS: query \"%s\" => %d, unexpected answer\n", hosts[i], err);
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_NO_MEMORY || err == NSAPI_ERROR_DNS_FAILURE || err == NSAPI_ERROR_TIMEOUT);
}
}
Expand All @@ -154,13 +155,13 @@ static void net_bringup()
net = NetworkInterface::get_default_instance();
nsapi_error_t err = net->connect();
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
printf("MBED: IP address is '%s'\n", net->get_ip_address());
greentea_serial->printf("MBED: IP address is '%s'\n", net->get_ip_address());
}

static void net_bringdown()
{
NetworkInterface::get_default_instance()->disconnect();
printf("MBED: ifdown\n");
greentea_serial->printf("MBED: ifdown\n");
}

// Test setup
Expand Down Expand Up @@ -195,7 +196,19 @@ Case cases[] = {

Specification specification(test_setup, cases, greentea_teardown, greentea_continue_handlers);

static void my_mutex_wait()
{
greentea_serial->lock();
}
static void my_mutex_release()
{
greentea_serial->unlock();
}

int main()
{
mbed_trace_mutex_wait_function_set(my_mutex_wait);
mbed_trace_mutex_release_function_set(my_mutex_release);
mbed_trace_init();
return !Harness::run(specification);
}
4 changes: 2 additions & 2 deletions TESTS/netsocket/dns/synchronous_dns_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void SYNCHRONOUS_DNS_CACHE()
// Check that cached accesses are at least twice as fast as the first one
TEST_ASSERT_TRUE(i == 0 || delay_ms <= delay_first);

printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
dns_test_hosts_second[0], address.get_ip_address(), delay_ms);
greentea_serial->printf("DNS: query \"%s\" => \"%s\", time %i ms\n",
dns_test_hosts_second[0], address.get_ip_address(), delay_ms);
}
}
23 changes: 18 additions & 5 deletions TESTS/netsocket/tcp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#endif

#include "mbed.h"
#include "mbed_trace.h"
#include "greentea-client/test_env.h"
#include "unity/unity.h"
#include "utest.h"
Expand Down Expand Up @@ -71,13 +72,13 @@ static void _ifup()
NetworkInterface *net = NetworkInterface::get_default_instance();
nsapi_error_t err = net->connect();
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address());
greentea_serial->printf("MBED: TCPClient IP address is '%s'\n", net->get_ip_address());
}

static void _ifdown()
{
NetworkInterface::get_default_instance()->disconnect();
printf("MBED: ifdown\n");
greentea_serial->printf("MBED: ifdown\n");
}

nsapi_error_t tcpsocket_connect_to_srv(TCPSocket &sock, uint16_t port)
Expand All @@ -87,17 +88,17 @@ nsapi_error_t tcpsocket_connect_to_srv(TCPSocket &sock, uint16_t port)
NetworkInterface::get_default_instance()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
tcp_addr.set_port(port);

printf("MBED: Server '%s', port %d\n", tcp_addr.get_ip_address(), tcp_addr.get_port());
greentea_serial->printf("MBED: Server '%s', port %d\n", tcp_addr.get_ip_address(), tcp_addr.get_port());

nsapi_error_t err = sock.open(NetworkInterface::get_default_instance());
if (err != NSAPI_ERROR_OK) {
printf("Error from sock.open: %d\n", err);
greentea_serial->printf("Error from sock.open: %d\n", err);
return err;
}

err = sock.connect(tcp_addr);
if (err != NSAPI_ERROR_OK) {
printf("Error from sock.connect: %d\n", err);
greentea_serial->printf("Error from sock.connect: %d\n", err);
return err;
}

Expand Down Expand Up @@ -180,7 +181,19 @@ Case cases[] = {

Specification specification(greentea_setup, cases, greentea_teardown, greentea_continue_handlers);

static void my_mutex_wait()
{
greentea_serial->lock();
}
static void my_mutex_release()
{
greentea_serial->unlock();
}

int main()
{
mbed_trace_mutex_wait_function_set(my_mutex_wait);
mbed_trace_mutex_release_function_set(my_mutex_release);
mbed_trace_init();
return !Harness::run(specification);
}
8 changes: 4 additions & 4 deletions TESTS/netsocket/tcp/tcpsocket_echotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void TCPSOCKET_ECHOTEST()

sent = sock.send(tcp_global::tx_buffer, pkt_s);
if (sent < 0) {
printf("[Round#%02d] network error %d\n", x, sent);
greentea_serial->printf("[Round#%02d] network error %d\n", x, sent);
TEST_FAIL();
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
return;
Expand All @@ -82,7 +82,7 @@ void TCPSOCKET_ECHOTEST()
while (bytes2recv) {
recvd = sock.recv(&(tcp_global::rx_buffer[sent - bytes2recv]), bytes2recv);
if (recvd < 0) {
printf("[Round#%02d] network error %d\n", x, recvd);
greentea_serial->printf("[Round#%02d] network error %d\n", x, recvd);
TEST_FAIL();
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
return;
Expand All @@ -105,7 +105,7 @@ void tcpsocket_echotest_nonblock_receive()
}
return;
} else if (recvd < 0) {
printf("sock.recv returned an error %d", recvd);
greentea_serial->printf("sock.recv returned an error %d", recvd);
TEST_FAIL();
receive_error = true;
} else {
Expand Down Expand Up @@ -173,7 +173,7 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
}
continue;
} else if (sent <= 0) {
printf("[Sender#%02d] network error %d\n", s_idx, sent);
greentea_serial->printf("[Sender#%02d] network error %d\n", s_idx, sent);
TEST_FAIL();
goto END;
}
Expand Down
12 changes: 6 additions & 6 deletions TESTS/netsocket/tcp/tcpsocket_echotest_burst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void TCPSOCKET_ECHOTEST_BURST()
}
continue;
} else if (sent < 0) {
printf("[%02d] network error %d\n", i, sent);
greentea_serial->printf("[%02d] network error %d\n", i, sent);
TEST_FAIL();
goto END;
}
Expand All @@ -71,7 +71,7 @@ void TCPSOCKET_ECHOTEST_BURST()
while (bt_left > 0) {
recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE - bt_left]), BURST_SIZE);
if (recvd < 0) {
printf("[%02d] network error %d\n", i, recvd);
greentea_serial->printf("[%02d] network error %d\n", i, recvd);
break;
}
bt_left -= recvd;
Expand Down Expand Up @@ -112,7 +112,7 @@ void TCPSOCKET_ECHOTEST_BURST_NONBLOCK()
}
continue;
} else if (sent < 0) {
printf("[%02d] network error %d\n", i, sent);
greentea_serial->printf("[%02d] network error %d\n", i, sent);
TEST_FAIL();
goto END;
}
Expand All @@ -128,19 +128,19 @@ void TCPSOCKET_ECHOTEST_BURST_NONBLOCK()
recvd = sock.recv(&(tcp_global::rx_buffer[BURST_SIZE - bt_left]), BURST_SIZE);
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
if (osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) {
printf("[bt#%02d] packet timeout...", i);
greentea_serial->printf("[bt#%02d] packet timeout...", i);
break;
}
continue;
} else if (recvd < 0) {
printf("[%02d] network error %d\n", i, recvd);
greentea_serial->printf("[%02d] network error %d\n", i, recvd);
break;
}
bt_left -= recvd;
}

if (bt_left != 0) {
printf("network error %d, missing %d bytes from a burst\n", recvd, bt_left);
greentea_serial->printf("network error %d, missing %d bytes from a burst\n", recvd, bt_left);
TEST_FAIL();
goto END;
}
Expand Down
4 changes: 2 additions & 2 deletions TESTS/netsocket/tcp/tcpsocket_open_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void TCPSOCKET_OPEN_LIMIT()
}
ret = sock->open(NetworkInterface::get_default_instance());
if (ret == NSAPI_ERROR_NO_MEMORY || ret == NSAPI_ERROR_NO_SOCKET) {
printf("[round#%02d] unable to open new socket, error: %d\n", i, ret);
greentea_serial->printf("[round#%02d] unable to open new socket, error: %d\n", i, ret);
delete sock;
break;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ void TCPSOCKET_OPEN_LIMIT()
delete tmp->sock;
delete tmp;
}
printf("[round#%02d] %d sockets opened\n", i, open_sockets[i]);
greentea_serial->printf("[round#%02d] %d sockets opened\n", i, open_sockets[i]);
}
TEST_ASSERT_EQUAL(open_sockets[0], open_sockets[1]);
TEST_ASSERT(open_sockets[0] >= 4);
Expand Down
4 changes: 2 additions & 2 deletions TESTS/netsocket/tcp/tcpsocket_recv_100k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void rcv_n_chk_against_rfc864_pattern(TCPSocket &sock)
recvd_size += rd;
}
timer.stop();
printf("MBED: Time taken: %fs\n", timer.read());
greentea_serial->printf("MBED: Time taken: %fs\n", timer.read());
}

void TCPSOCKET_RECV_100K()
Expand Down Expand Up @@ -159,7 +159,7 @@ void rcv_n_chk_against_rfc864_pattern_nonblock(TCPSocket &sock)
}
}
timer.stop();
printf("MBED: Time taken: %fs\n", timer.read());
greentea_serial->printf("MBED: Time taken: %fs\n", timer.read());
}

static void _sigio_handler(osThreadId id)
Expand Down
4 changes: 2 additions & 2 deletions TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ void TCPSOCKET_RECV_TIMEOUT()
TEST_FAIL();
goto CLEANUP;
}
printf("MBED: recv() took: %dus\n", timer.read_us());
greentea_serial->printf("MBED: recv() took: %dus\n", timer.read_us());
TEST_ASSERT_INT_WITHIN(51, 150, (timer.read_us() + 500) / 1000);
continue;
} else if (recvd < 0) {
printf("[pkt#%02d] network error %d\n", i, recvd);
greentea_serial->printf("[pkt#%02d] network error %d\n", i, recvd);
TEST_FAIL();
goto CLEANUP;
}
Expand Down
2 changes: 1 addition & 1 deletion TESTS/netsocket/tcp/tcpsocket_send_timeout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void TCPSOCKET_SEND_TIMEOUT()
(timer.read_ms() <= 800)) {
continue;
}
printf("send: err %d, time %d", err, timer.read_ms());
greentea_serial->printf("send: err %d, time %d", err, timer.read_ms());
TEST_FAIL();
break;
}
Expand Down
Loading