Skip to content

Commit b16569d

Browse files
authored
Merge pull request #8838 from 0xc0170/dev_rollup
Rollup v2 for 5.11rc1
2 parents 860e4be + 0f14f4b commit b16569d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2099
-286
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ matrix:
141141
after_success:
142142
# run astyle for all files on the branch
143143
- git checkout -- .
144-
- find -regex '.*\.\(h\|c\|hpp\|cpp\)' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-branch.out;
144+
- find -regex '.*\.\(h\|c\|hpp\|cpp\)$' -type f | fgrep -v -f .astyleignore | xargs -n 100 -I {} bash -c "astyle -n --options=.astylerc \"{}\"" > astyle-branch.out;
145145
# update status if we succeeded, compare with master if possible
146146
- |
147147
CURR=$(cat astyle-branch.out | grep Formatted | wc -l)

TESTS/netsocket/dns/asynchronous_dns_non_async_and_async.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void ASYNCHRONOUS_DNS_NON_ASYNC_AND_ASYNC()
4545
TEST_ASSERT(strlen(addr.get_ip_address()) > 1);
4646
}
4747

48-
semaphore.wait();
48+
semaphore.wait(100);
4949

5050
TEST_ASSERT(data.result == NSAPI_ERROR_OK);
5151

TESTS/netsocket/tcp/tcp_tests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket &sock);
3030
int split2half_rmng_tcp_test_time(); // [s]
3131

3232
namespace tcp_global {
33-
static const int TESTS_TIMEOUT = 960;
33+
static const int TESTS_TIMEOUT = 480;
3434
static const int TCP_OS_STACK_SIZE = 2048;
3535

3636
static const int RX_BUFF_SIZE = 1220;

TESTS/netsocket/tcp/tcpsocket_recv_timeout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ void TCPSOCKET_RECV_TIMEOUT()
6666
TEST_FAIL();
6767
goto CLEANUP;
6868
}
69-
printf("MBED: recv() took: %dms\n", timer.read_ms());
70-
TEST_ASSERT_INT_WITHIN(50, 150, timer.read_ms());
69+
printf("MBED: recv() took: %dus\n", timer.read_us());
70+
TEST_ASSERT_INT_WITHIN(51, 150, (timer.read_us() + 500) / 1000);
7171
continue;
7272
} else if (recvd < 0) {
7373
printf("[pkt#%02d] network error %d\n", i, recvd);

TESTS/network/interface/networkinterface_status.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ void NETWORKINTERFACE_STATUS()
8989
}
9090
TEST_ASSERT_EQUAL(NSAPI_STATUS_GLOBAL_UP, status);
9191

92-
net->disconnect();
92+
err = net->disconnect();
93+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
9394

9495
status = wait_status_callback();
9596
TEST_ASSERT_EQUAL(NSAPI_STATUS_DISCONNECTED, status);
@@ -123,7 +124,8 @@ void NETWORKINTERFACE_STATUS_NONBLOCK()
123124
}
124125
TEST_ASSERT_EQUAL(NSAPI_STATUS_GLOBAL_UP, status);
125126

126-
net->disconnect();
127+
err = net->disconnect();
128+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
127129

128130
status = wait_status_callback();
129131
TEST_ASSERT_EQUAL(NSAPI_STATUS_DISCONNECTED, status);
@@ -150,7 +152,8 @@ void NETWORKINTERFACE_STATUS_GET()
150152
wait(0.5);
151153
}
152154

153-
net->disconnect();
155+
err = net->disconnect();
156+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, err);
154157

155158
TEST_ASSERT_EQUAL(NSAPI_STATUS_DISCONNECTED, net->get_connection_status());
156159
}

TESTS/network/wifi/wifi_connect_params_null.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void wifi_connect_params_null(void)
3030
error = wifi->connect(NULL, NULL);
3131
wifi->disconnect();
3232
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
33-
error = wifi->connect("", "");
33+
error = wifi->connect("", "");
3434
wifi->disconnect();
3535
TEST_ASSERT(error == NSAPI_ERROR_PARAMETER);
3636
}

TESTS/network/wifi/wifi_connect_secure.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void wifi_connect_secure(void)
3232
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->set_credentials(MBED_CONF_APP_WIFI_SECURE_SSID, MBED_CONF_APP_WIFI_PASSWORD, get_security()));
3333

3434
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->connect());
35-
35+
3636
TEST_ASSERT_EQUAL_INT(NSAPI_ERROR_OK, wifi->disconnect());
3737
}
3838

UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params)
185185
reg_params._periodic_tau = 3;
186186

187187
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_registration_params(CellularNetwork::C_EREG, reg_params));
188-
EXPECT_TRUE(reg_params._status == CellularNetwork::StatusNotAvailable);
188+
EXPECT_TRUE(reg_params._status == CellularNetwork::NotRegistered);
189189
EXPECT_TRUE(reg_params._act == CellularNetwork::RAT_UNKNOWN);
190190
EXPECT_TRUE(reg_params._cell_id == -1 && reg_params._active_time == -1 && reg_params._periodic_tau == -1);
191191

192192
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.get_registration_params(CellularNetwork::C_GREG, reg_params));
193-
EXPECT_TRUE(reg_params._status == CellularNetwork::StatusNotAvailable);
193+
EXPECT_TRUE(reg_params._status == CellularNetwork::NotRegistered);
194194
EXPECT_TRUE(reg_params._act == CellularNetwork::RAT_UNKNOWN);
195195
EXPECT_TRUE(reg_params._cell_id == -1);
196196

@@ -201,12 +201,12 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_registration_params)
201201
reg_params._periodic_tau = 3;
202202

203203
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == nw.get_registration_params(CellularNetwork::C_EREG, reg_params));
204-
EXPECT_TRUE(reg_params._status == CellularNetwork::StatusNotAvailable);
204+
EXPECT_TRUE(reg_params._status == CellularNetwork::NotRegistered);
205205
EXPECT_TRUE(reg_params._act == CellularNetwork::RAT_UNKNOWN);
206206
EXPECT_TRUE(reg_params._cell_id == -1 && reg_params._active_time == -1 && reg_params._periodic_tau == -1);
207207
// Check get_registration_params without specifying the registration type
208208
EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_registration_params(reg_params_check));
209-
EXPECT_TRUE(reg_params_check._status == CellularNetwork::StatusNotAvailable);
209+
EXPECT_TRUE(reg_params_check._status == CellularNetwork::NotRegistered);
210210
EXPECT_TRUE(reg_params_check._act == CellularNetwork::RAT_UNKNOWN);
211211
EXPECT_TRUE(reg_params_check._cell_id == -1 && reg_params_check._active_time == -1 && reg_params_check._periodic_tau == -1);
212212
}
@@ -497,7 +497,7 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_signal_quality)
497497
ATHandler_stub::int_value = 1;
498498
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
499499
EXPECT_TRUE(NSAPI_ERROR_OK == cn.get_signal_quality(rs, ber));
500-
EXPECT_TRUE(rs == 1 && ber == 1);
500+
EXPECT_TRUE(rs == -111 && ber == 1);
501501
}
502502

503503
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_get_3gpp_error)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may 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,
13+
* WITHOUT 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+
#ifndef UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKET_DTLS_TEST_CONFIG_H_
19+
#define UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKET_DTLS_TEST_CONFIG_H_
20+
21+
#define MBEDTLS_SSL_CLI_C
22+
23+
24+
#endif /* UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKET_DTLS_TEST_CONFIG_H_ */
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may 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,
13+
* WITHOUT 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 "gtest/gtest.h"
19+
#include "features/netsocket/DTLSSocket.h"
20+
#include "NetworkStack_stub.h"
21+
22+
#include "mbed_error.h"
23+
mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
24+
{
25+
return 0;
26+
}
27+
28+
// Control the rtos EventFlags stub. See EventFlags_stub.cpp
29+
extern std::list<uint32_t> eventFlagsStubNextRetval;
30+
31+
class TestDTLSSocket : public testing::Test {
32+
public:
33+
unsigned int dataSize = 10;
34+
char dataBuf[10];
35+
protected:
36+
DTLSSocket *socket;
37+
NetworkStackstub stack;
38+
39+
virtual void SetUp()
40+
{
41+
socket = new DTLSSocket();
42+
}
43+
44+
virtual void TearDown()
45+
{
46+
stack.return_values.clear();
47+
eventFlagsStubNextRetval.clear();
48+
delete socket;
49+
}
50+
};
51+
52+
TEST_F(TestDTLSSocket, constructor)
53+
{
54+
EXPECT_TRUE(socket);
55+
}
56+
57+
/* connect */
58+
59+
TEST_F(TestDTLSSocket, connect)
60+
{
61+
socket->open((NetworkStack *)&stack);
62+
63+
stack.return_value = NSAPI_ERROR_OK;
64+
EXPECT_EQ(socket->connect("127.0.0.1", 1024), NSAPI_ERROR_OK);
65+
}
66+
67+
TEST_F(TestDTLSSocket, connect_error)
68+
{
69+
socket->open((NetworkStack *)&stack);
70+
71+
stack.return_value = NSAPI_ERROR_DNS_FAILURE;
72+
EXPECT_EQ(socket->connect("127.0.0.1", 1024), NSAPI_ERROR_DNS_FAILURE);
73+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
####################
3+
# UNIT TESTS
4+
####################
5+
6+
set(unittest-sources
7+
../features/netsocket/SocketAddress.cpp
8+
../features/netsocket/NetworkStack.cpp
9+
../features/netsocket/InternetSocket.cpp
10+
../features/netsocket/UDPSocket.cpp
11+
../features/netsocket/DTLSSocket.cpp
12+
../features/netsocket/DTLSSocketWrapper.cpp
13+
../features/netsocket/TLSSocketWrapper.cpp
14+
../features/frameworks/nanostack-libservice/source/libip4string/ip4tos.c
15+
../features/frameworks/nanostack-libservice/source/libip6string/ip6tos.c
16+
../features/frameworks/nanostack-libservice/source/libip4string/stoip4.c
17+
../features/frameworks/nanostack-libservice/source/libip6string/stoip6.c
18+
../features/frameworks/nanostack-libservice/source/libBits/common_functions.c
19+
)
20+
21+
set(unittest-test-sources
22+
features/netsocket/DTLSSocket/test_DTLSSocket.cpp
23+
stubs/Mutex_stub.cpp
24+
stubs/mbed_assert_stub.c
25+
stubs/equeue_stub.c
26+
../features/nanostack/coap-service/test/coap-service/unittest/stub/mbedtls_stub.c
27+
stubs/EventQueue_stub.cpp
28+
stubs/mbed_shared_queues_stub.cpp
29+
stubs/nsapi_dns_stub.cpp
30+
stubs/EventFlags_stub.cpp
31+
stubs/stoip4_stub.c
32+
stubs/ip4tos_stub.c
33+
stubs/Kernel_stub.cpp
34+
)
35+
36+
set(MBEDTLS_USER_CONFIG_FILE_PATH "\"../UNITTESTS/features/netsocket/DTLSSocket/dtls_test_config.h\"")
37+
set_source_files_properties(features/netsocket/DTLSSocket/test_DTLSSocket.cpp PROPERTIES COMPILE_DEFINITIONS MBEDTLS_USER_CONFIG_FILE=${MBEDTLS_USER_CONFIG_FILE_PATH})
38+
set_source_files_properties(../features/netsocket/DTLSSocket.cpp PROPERTIES COMPILE_DEFINITIONS MBEDTLS_USER_CONFIG_FILE=${MBEDTLS_USER_CONFIG_FILE_PATH})
39+
set_source_files_properties(../features/netsocket/DTLSSocketWrapper.cpp PROPERTIES COMPILE_DEFINITIONS MBEDTLS_USER_CONFIG_FILE=${MBEDTLS_USER_CONFIG_FILE_PATH})
40+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2018, Arm Limited and affiliates
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may 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,
13+
* WITHOUT 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+
#ifndef UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKETWRAPPER_TLS_TEST_CONFIG_H_
19+
#define UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKETWRAPPER_TLS_TEST_CONFIG_H_
20+
21+
#define MBEDTLS_SSL_CLI_C
22+
23+
24+
#endif /* UNITTESTS_FEATURES_NETSOCKET_DTLSSOCKETWRAPPER_TLS_TEST_CONFIG_H_ */

0 commit comments

Comments
 (0)