Skip to content

Commit 1933574

Browse files
Veijo PesonenSeppo Takalo
authored andcommitted
Adds TCP test case
tcpsocket_send_repeat
1 parent 096ed1e commit 1933574

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

TESTS/netsocket/tcp/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Case cases[] = {
101101
Case("Receive 100k from CHARGEN service", test_tcpsocket_recv_100k),
102102
Case("Receive 100k from CHARGEN service non-block", test_tcpsocket_recv_100k_nonblock),
103103
Case("Receive in given time", test_tcpsocket_recv_timeout),
104+
Case("Send repeatedly", test_tcpsocket_send_repeat),
104105
Case("Sending shall not take too long", test_tcpsocket_send_timeout),
105106
Case("Parallel socket thread safety", test_tcpsocket_thread_per_socket_safety),
106107
Case("Endpoint initiated close", test_tcpsocket_endpoint_close),

TESTS/netsocket/tcp/tcp_tests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void test_tcpsocket_open_limit();
3636
void test_tcpsocket_recv_100k();
3737
void test_tcpsocket_recv_100k_nonblock();
3838
void test_tcpsocket_recv_timeout();
39+
void test_tcpsocket_send_repeat();
3940
void test_tcpsocket_send_timeout();
4041
void test_tcpsocket_thread_per_socket_safety();
4142

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2018, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "mbed.h"
19+
#include MBED_CONF_APP_HEADER_FILE
20+
#include "TCPSocket.h"
21+
#include "greentea-client/test_env.h"
22+
#include "unity/unity.h"
23+
#include "utest.h"
24+
#include "tcp_tests.h"
25+
26+
using namespace utest::v1;
27+
28+
void test_tcpsocket_send_repeat()
29+
{
30+
TCPSocket sock;
31+
sock.open(get_interface());
32+
sock.connect(MBED_CONF_APP_ECHO_SERVER_ADDR, 9);
33+
34+
int err;
35+
Timer timer;
36+
static const char tx_buffer[] = {'h','e','l','l','o'};
37+
for (int i = 0; i < 1000; i++) {
38+
err = sock.send(tx_buffer, sizeof(tx_buffer));
39+
TEST_ASSERT_EQUAL(sizeof(tx_buffer), err);
40+
}
41+
sock.close();
42+
}

0 commit comments

Comments
 (0)