Skip to content

Commit f6c1a40

Browse files
author
Deepika
committed
Add config options for socket statistics
1. MBED_CONF_NSAPI_SOCKET_STATS_ENABLE to enable the statistics 2. MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT max sockets statistics cached
1 parent a851df6 commit f6c1a40

16 files changed

+35
-27
lines changed

TESTS/netsocket/tcp/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ NetworkInterface *net;
3838
Timer tc_bucket; // Timer to limit a test cases run time
3939
}
4040

41-
#if defined(MBED_NW_STATS_ENABLED)
41+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
4242
mbed_stats_socket_t tcp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT] = {0};
4343
#endif
4444

@@ -119,7 +119,7 @@ int split2half_rmng_tcp_test_time()
119119
return (tcp_global::TESTS_TIMEOUT - tc_bucket.read()) / 2;
120120
}
121121

122-
#if defined(MBED_NW_STATS_ENABLED)
122+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
123123
int fetch_stats()
124124
{
125125
return SocketStats::mbed_stats_socket_get_each(&tcp_stats[0], MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT);

TESTS/netsocket/tcp/tcp_tests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void fill_tx_buffer_ascii(char *buff, size_t len);
2424
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket &sock);
2525
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock);
2626

27-
#if defined(MBED_NW_STATS_ENABLED)
27+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
2828
extern mbed_stats_socket_t tcp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
2929
int fetch_stats(void);
3030
#endif

TESTS/netsocket/tcp/tcpsocket_echotest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes)
114114

115115
void TCPSOCKET_ECHOTEST_NONBLOCK()
116116
{
117-
#if defined(MBED_NW_STATS_ENABLED)
117+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
118118
int j = 0;
119119
int count = fetch_stats();
120120
for (; j < count; j++) {
@@ -167,7 +167,7 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
167167
bytes2send -= sent;
168168
}
169169
printf("[Sender#%02d] bytes sent: %d\n", s_idx, pkt_s);
170-
#if defined(MBED_NW_STATS_ENABLED)
170+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
171171
count = fetch_stats();
172172
for (j = 0; j < count; j++) {
173173
if ((tcp_stats[j].state == SOCK_OPEN) && (tcp_stats[j].proto == NSAPI_TCP)) {

TESTS/netsocket/tcp/tcpsocket_open_close_repeat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace utest::v1;
2626

2727
void TCPSOCKET_OPEN_CLOSE_REPEAT()
2828
{
29-
#if defined(MBED_NW_STATS_ENABLED)
29+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
3030
int count = fetch_stats();
3131
for (int j = 0; j < count; j++) {
3232
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);
@@ -42,7 +42,7 @@ void TCPSOCKET_OPEN_CLOSE_REPEAT()
4242
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
4343
}
4444
delete sock;
45-
#if defined(MBED_NW_STATS_ENABLED)
45+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
4646
count = fetch_stats();
4747
for (int j = 0; j < count; j++) {
4848
TEST_ASSERT_EQUAL(SOCK_CLOSED, tcp_stats[j].state);

TESTS/netsocket/tcp/tcpsocket_open_limit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void TCPSOCKET_OPEN_LIMIT()
7070
break;
7171
}
7272

73-
#if defined(MBED_NW_STATS_ENABLED)
73+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
7474
int count = fetch_stats();
7575
int open_count = 0;
7676
for (int j = 0; j < count; j++) {

TESTS/netsocket/udp/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace {
3737
NetworkInterface *net;
3838
}
3939

40-
#if defined(MBED_NW_STATS_ENABLED)
40+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
4141
mbed_stats_socket_t udp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT] = {0};
4242
#endif
4343

@@ -80,7 +80,7 @@ void fill_tx_buffer_ascii(char *buff, size_t len)
8080
}
8181
}
8282

83-
#if defined(MBED_NW_STATS_ENABLED)
83+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
8484
int fetch_stats()
8585
{
8686
return SocketStats::mbed_stats_socket_get_each(&udp_stats[0], MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT);

TESTS/netsocket/udp/udp_tests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ NetworkInterface *get_interface();
2222
void drop_bad_packets(UDPSocket &sock, int orig_timeout);
2323
void fill_tx_buffer_ascii(char *buff, size_t len);
2424

25-
#if defined(MBED_NW_STATS_ENABLED)
25+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
2626
extern mbed_stats_socket_t udp_stats[MBED_CONF_NSAPI_SOCKET_STATS_MAX_COUNT];
2727
int fetch_stats(void);
2828
#endif

TESTS/netsocket/udp/udpsocket_echotest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void udpsocket_echotest_nonblock_receiver(void *receive_bytes)
121121

122122
void UDPSOCKET_ECHOTEST_NONBLOCK()
123123
{
124-
#if defined(MBED_NW_STATS_ENABLED)
124+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
125125
int j = 0;
126126
int count = fetch_stats();
127127
for (; j < count; j++) {
@@ -183,7 +183,7 @@ void UDPSOCKET_ECHOTEST_NONBLOCK()
183183
}
184184
free(stack_mem);
185185

186-
#if defined(MBED_NW_STATS_ENABLED)
186+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
187187
TEST_ASSERT_EQUAL(1, fetch_stats());
188188
TEST_ASSERT_EQUAL(NSAPI_UDP, udp_stats[0].proto);
189189
TEST_ASSERT(udp_stats[0].sent_bytes != 0);

TESTS/netsocket/udp/udpsocket_open_close_repeat.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace utest::v1;
2626

2727
void UDPSOCKET_OPEN_CLOSE_REPEAT()
2828
{
29-
#if defined(MBED_NW_STATS_ENABLED)
29+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
3030
int count = fetch_stats();
3131
for (int j = 0; j < count; j++) {
3232
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);
@@ -42,7 +42,7 @@ void UDPSOCKET_OPEN_CLOSE_REPEAT()
4242
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock->close());
4343
}
4444
delete sock;
45-
#if defined(MBED_NW_STATS_ENABLED)
45+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
4646
count = fetch_stats();
4747
for (int j = 0; j < count; j++) {
4848
TEST_ASSERT_EQUAL(SOCK_CLOSED, udp_stats[j].state);

TESTS/netsocket/udp/udpsocket_open_limit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void UDPSOCKET_OPEN_LIMIT()
7070
if (!socket_list_head) {
7171
break;
7272
}
73-
#if defined(MBED_NW_STATS_ENABLED)
73+
#ifdef MBED_CONF_NSAPI_SOCKET_STATS_ENABLE
7474
int count = fetch_stats();
7575
int open_count = 0;
7676
for (int j = 0; j < count; j++) {

0 commit comments

Comments
 (0)