Skip to content

Commit 6e0d01c

Browse files
Merge pull request #5268 from ARMmbed/release-candidate
Release candidate for mbed-os-5.6.2
2 parents cc7556a + 5fda5bc commit 6e0d01c

File tree

456 files changed

+13698
-8859
lines changed

Some content is hidden

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

456 files changed

+13698
-8859
lines changed

.coveragerc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
omit =
3+
*/usr/local/lib*
4+
*/tools/test/*
5+
6+
[report]
7+
omit =
8+
*/usr/local/lib*
9+
*/tools/test/*
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
2+
/* mbed Microcontroller Library
3+
* Copyright (c) 2017 ARM Limited
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+
#if !DEVICE_SLEEP
19+
#error [NOT_SUPPORTED] Sleep not supported for this target
20+
#endif
21+
22+
#include "utest/utest.h"
23+
#include "unity/unity.h"
24+
#include "greentea-client/test_env.h"
25+
26+
#include "mbed.h"
27+
28+
using namespace utest::v1;
29+
30+
void deep_sleep_lock_lock_test()
31+
{
32+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
33+
{
34+
// Check basic usage works
35+
DeepSleepLock lock;
36+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
37+
}
38+
39+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
40+
{
41+
// Check that unlock and lock change can deep sleep as expected
42+
DeepSleepLock lock;
43+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
44+
lock.unlock();
45+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
46+
lock.lock();
47+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
48+
}
49+
50+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
51+
{
52+
// Check that unlock releases sleep based on count
53+
DeepSleepLock lock;
54+
lock.lock();
55+
lock.lock();
56+
lock.unlock();
57+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
58+
}
59+
60+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
61+
{
62+
// Check that unbalanced locks do not leave deep sleep locked
63+
DeepSleepLock lock;
64+
lock.lock();
65+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
66+
}
67+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
68+
69+
}
70+
71+
void timer_lock_test()
72+
{
73+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
74+
{
75+
// Just creating a timer object does not lock sleep
76+
Timer timer;
77+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
78+
}
79+
80+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
81+
{
82+
// Starting a timer does lock sleep
83+
Timer timer;
84+
timer.start();
85+
TEST_ASSERT_EQUAL(false, sleep_manager_can_deep_sleep());
86+
}
87+
88+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
89+
{
90+
// Stopping a timer after starting it allows sleep
91+
Timer timer;
92+
timer.start();
93+
timer.stop();
94+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
95+
}
96+
97+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
98+
{
99+
// Starting a timer multiple times still lets you sleep
100+
Timer timer;
101+
timer.start();
102+
timer.start();
103+
}
104+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
105+
106+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
107+
{
108+
// Stopping a timer multiple times still lets you sleep
109+
Timer timer;
110+
timer.start();
111+
timer.stop();
112+
timer.stop();
113+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
114+
}
115+
TEST_ASSERT_EQUAL(true, sleep_manager_can_deep_sleep());
116+
}
117+
118+
Case cases[] = {
119+
Case("DeepSleepLock lock test", deep_sleep_lock_lock_test),
120+
Case("timer lock test", timer_lock_test),
121+
};
122+
123+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
124+
GREENTEA_SETUP(20, "default_auto");
125+
return greentea_test_setup_handler(number_of_cases);
126+
}
127+
128+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
129+
130+
int main() {
131+
Harness::run(specification);
132+
}

features/FEATURE_LWIP/TESTS/mbedmicro-net/connectivity/main.cpp renamed to TESTS/netsocket/connectivity/main.cpp

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,57 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
1+
/*
2+
* Copyright (c) 2013-2017, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
34
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
67
* You may obtain a copy of the License at
78
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
910
*
1011
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
1516
*/
16-
#if !FEATURE_LWIP
17-
#error [NOT_SUPPORTED] LWIP not supported for this target
18-
#endif
19-
#if DEVICE_EMAC
20-
#error [NOT_SUPPORTED] Not supported for WiFi targets
21-
#endif
17+
18+
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
19+
#error [NOT_SUPPORTED] No network configuration found for this target.
20+
#endif
2221

2322
#include "mbed.h"
2423
#include "greentea-client/test_env.h"
2524
#include "unity.h"
2625
#include "utest.h"
27-
28-
#include "EthernetInterface.h"
26+
#include MBED_CONF_APP_HEADER_FILE
2927

3028
using namespace utest::v1;
3129

32-
3330
// Bringing the network up and down
3431
template <int COUNT>
3532
void test_bring_up_down() {
36-
EthernetInterface eth;
33+
NetworkInterface* net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
3734

3835
for (int i = 0; i < COUNT; i++) {
39-
int err = eth.connect();
36+
int err = MBED_CONF_APP_CONNECT_STATEMENT;
4037
TEST_ASSERT_EQUAL(0, err);
4138

42-
printf("MBED: IP Address %s\r\n", eth.get_ip_address());
43-
printf("MBED: Netmask %s\r\n", eth.get_netmask());
44-
printf("MBED: Gateway %s\r\n", eth.get_gateway());
45-
TEST_ASSERT(eth.get_ip_address());
46-
TEST_ASSERT(eth.get_netmask());
47-
TEST_ASSERT(eth.get_gateway());
39+
printf("MBED: IP Address %s\r\n", net->get_ip_address());
40+
TEST_ASSERT(net->get_ip_address());
4841

4942
UDPSocket udp;
50-
err = udp.open(&eth);
43+
err = udp.open(net);
5144
TEST_ASSERT_EQUAL(0, err);
5245
err = udp.close();
5346
TEST_ASSERT_EQUAL(0, err);
5447

5548
TCPSocket tcp;
56-
err = tcp.open(&eth);
49+
err = tcp.open(net);
5750
TEST_ASSERT_EQUAL(0, err);
5851
err = tcp.close();
5952
TEST_ASSERT_EQUAL(0, err);
6053

61-
err = eth.disconnect();
54+
err = net->disconnect();
6255
TEST_ASSERT_EQUAL(0, err);
6356
}
6457
}

features/FEATURE_LWIP/TESTS/mbedmicro-net/gethostbyname/main.cpp renamed to TESTS/netsocket/gethostbyname/main.cpp

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
1+
/*
2+
* Copyright (c) 2013-2017, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
34
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
67
* You may obtain a copy of the License at
78
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
910
*
1011
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
1516
*/
16-
#if !FEATURE_LWIP
17-
#error [NOT_SUPPORTED] LWIP not supported for this target
18-
#endif
19-
#if DEVICE_EMAC
20-
#error [NOT_SUPPORTED] Not supported for WiFi targets
21-
#endif
17+
18+
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
19+
#error [NOT_SUPPORTED] No network configuration found for this target.
20+
#endif
2221

2322
#include "mbed.h"
2423
#include "greentea-client/test_env.h"
2524
#include "unity.h"
2625
#include "utest.h"
27-
#include "EthernetInterface.h"
26+
#include MBED_CONF_APP_HEADER_FILE
2827

2928
using namespace utest::v1;
3029

@@ -34,20 +33,23 @@ using namespace utest::v1;
3433
#define MBED_DNS_TEST_HOST "connector.mbed.com"
3534
#endif
3635

36+
3737
// Address info from stack
3838
const char *ip_literal;
3939
nsapi_version_t ip_pref;
4040
const char *ip_pref_repr;
4141

4242
// Network setup
43-
EthernetInterface net;
43+
NetworkInterface *net;
44+
4445
void net_bringup() {
45-
int err = net.connect();
46+
net = MBED_CONF_APP_OBJECT_CONSTRUCTION;
47+
int err = MBED_CONF_APP_CONNECT_STATEMENT;
4648
TEST_ASSERT_EQUAL(0, err);
4749
printf("MBED: Connected to network\n");
48-
printf("MBED: IP Address: %s\n", net.get_ip_address());
50+
printf("MBED: IP Address: %s\n", net->get_ip_address());
4951

50-
ip_literal = net.get_ip_address();
52+
ip_literal = net->get_ip_address();
5153
ip_pref = SocketAddress(ip_literal).get_ip_version();
5254
ip_pref_repr = (ip_pref == NSAPI_IPv4) ? "ipv4" :
5355
(ip_pref == NSAPI_IPv6) ? "ipv6" : "unspec";
@@ -57,7 +59,7 @@ void net_bringup() {
5759
// DNS tests
5860
void test_dns_query() {
5961
SocketAddress addr;
60-
int err = net.gethostbyname(MBED_DNS_TEST_HOST, &addr);
62+
int err = net->gethostbyname(MBED_DNS_TEST_HOST, &addr);
6163
printf("DNS: query \"%s\" => \"%s\"\n",
6264
MBED_DNS_TEST_HOST, addr.get_ip_address());
6365

@@ -68,7 +70,7 @@ void test_dns_query() {
6870

6971
void test_dns_query_pref() {
7072
SocketAddress addr;
71-
int err = net.gethostbyname(MBED_DNS_TEST_HOST, &addr, ip_pref);
73+
int err = net->gethostbyname(MBED_DNS_TEST_HOST, &addr, ip_pref);
7274
printf("DNS: query %s \"%s\" => \"%s\"\n",
7375
ip_pref_repr, MBED_DNS_TEST_HOST, addr.get_ip_address());
7476

@@ -80,7 +82,7 @@ void test_dns_query_pref() {
8082

8183
void test_dns_literal() {
8284
SocketAddress addr;
83-
int err = net.gethostbyname(ip_literal, &addr);
85+
int err = net->gethostbyname(ip_literal, &addr);
8486
printf("DNS: literal \"%s\" => \"%s\"\n",
8587
ip_literal, addr.get_ip_address());
8688

@@ -92,7 +94,7 @@ void test_dns_literal() {
9294

9395
void test_dns_literal_pref() {
9496
SocketAddress addr;
95-
int err = net.gethostbyname(ip_literal, &addr, ip_pref);
97+
int err = net->gethostbyname(ip_literal, &addr, ip_pref);
9698
printf("DNS: literal %s \"%s\" => \"%s\"\n",
9799
ip_pref_repr, ip_literal, addr.get_ip_address());
98100

TESTS/netsocket/ip_parsing/main.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
/* mbed Microcontroller Library
2-
* Copyright (c) 2017 ARM Limited
1+
/*
2+
* Copyright (c) 2013-2017, ARM Limited, All Rights Reserved
3+
* SPDX-License-Identifier: Apache-2.0
34
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
5+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
* not use this file except in compliance with the License.
67
* You may obtain a copy of the License at
78
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9+
* http://www.apache.org/licenses/LICENSE-2.0
910
*
1011
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
* See the License for the specific language governing permissions and
1415
* limitations under the License.
1516
*/
17+
18+
#ifndef MBED_CONF_APP_CONNECT_STATEMENT
19+
#error [NOT_SUPPORTED] No network configuration found for this target.
20+
#endif
21+
1622
#include "mbed.h"
1723
#include "greentea-client/test_env.h"
1824
#include "unity.h"

0 commit comments

Comments
 (0)