Skip to content

Commit 485bdee

Browse files
author
Cruz Monrreal
authored
Merge pull request #7631 from ARMmbed/release-candidate
Release candidate for mbed-os-5.9.4
2 parents 50bd61a + 6974f23 commit 485bdee

File tree

414 files changed

+416073
-502
lines changed

Some content is hidden

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

414 files changed

+416073
-502
lines changed

LICENSE-BSD-3-Clause

Lines changed: 0 additions & 25 deletions
This file was deleted.

TESTS/mbed_hal/common_tickers/main.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
#define TICKER_INT_VAL 500
3030
#define TICKER_DELTA 10
3131

32-
#define LP_TICKER_OVERFLOW_DELTA 0 // this will allow to detect that ticker counter rollovers to 0
33-
#define US_TICKER_OVERFLOW_DELTA 50
32+
#define LP_TICKER_OVERFLOW_DELTA1 0 // this will allow to detect that ticker counter rollovers to 0
33+
#define LP_TICKER_OVERFLOW_DELTA2 0
34+
#define US_TICKER_OVERFLOW_DELTA1 50
35+
#define US_TICKER_OVERFLOW_DELTA2 60
3436

3537
#define TICKER_100_TICKS 100
3638

@@ -48,7 +50,18 @@ using namespace utest::v1;
4850
volatile int intFlag = 0;
4951
const ticker_interface_t* intf;
5052
ticker_irq_handler_type prev_irq_handler;
51-
unsigned int ticker_overflow_delta;
53+
/* Some targets might fail overflow test uncertainly due to getting trapped in busy
54+
* intf->read() loop. In the loop, some ticker values wouldn't get caught in time
55+
* because of:
56+
* 1. Lower CPU clock
57+
* 2. Compiled code with worse performance
58+
* 3. Interrupt at that time
59+
*
60+
* We fix it by checking small ticker value range rather than one exact ticker point
61+
* in near overflow check.
62+
*/
63+
unsigned int ticker_overflow_delta1;
64+
unsigned int ticker_overflow_delta2;
5265

5366
/* Auxiliary function to count ticker ticks elapsed during execution of N cycles of empty while loop.
5467
* Parameter <step> is used to disable compiler optimisation. */
@@ -293,12 +306,13 @@ void ticker_overflow_test(void)
293306
intFlag = 0;
294307

295308
/* Wait for max count. */
296-
while (intf->read() != (max_count - ticker_overflow_delta)) {
309+
while (intf->read() >= (max_count - ticker_overflow_delta2) &&
310+
intf->read() <= (max_count - ticker_overflow_delta1)) {
297311
/* Just wait. */
298312
}
299313

300314
/* Now we are near/at the overflow point. Detect rollover. */
301-
while (intf->read() > ticker_overflow_delta);
315+
while (intf->read() > ticker_overflow_delta1);
302316

303317
const uint32_t after_overflow = intf->read();
304318

@@ -310,7 +324,7 @@ void ticker_overflow_test(void)
310324
const uint32_t next_after_overflow = intf->read();
311325

312326
/* Check that after the overflow ticker continue count. */
313-
TEST_ASSERT(after_overflow <= ticker_overflow_delta);
327+
TEST_ASSERT(after_overflow <= ticker_overflow_delta1);
314328
TEST_ASSERT(next_after_overflow >= TICKER_100_TICKS);
315329
TEST_ASSERT_EQUAL(0, intFlag);
316330

@@ -465,7 +479,8 @@ utest::v1::status_t us_ticker_setup(const Case *const source, const size_t index
465479

466480
prev_irq_handler = set_us_ticker_irq_handler(ticker_event_handler_stub);
467481

468-
ticker_overflow_delta = US_TICKER_OVERFLOW_DELTA;
482+
ticker_overflow_delta1 = US_TICKER_OVERFLOW_DELTA1;
483+
ticker_overflow_delta2 = US_TICKER_OVERFLOW_DELTA2;
469484

470485
return greentea_case_setup_handler(source, index_of_case);
471486
}
@@ -493,7 +508,8 @@ utest::v1::status_t lp_ticker_setup(const Case *const source, const size_t index
493508

494509
prev_irq_handler = set_lp_ticker_irq_handler(ticker_event_handler_stub);
495510

496-
ticker_overflow_delta = LP_TICKER_OVERFLOW_DELTA;
511+
ticker_overflow_delta1 = LP_TICKER_OVERFLOW_DELTA1;
512+
ticker_overflow_delta2 = LP_TICKER_OVERFLOW_DELTA2;
497513

498514
return greentea_case_setup_handler(source, index_of_case);
499515
}

TESTS/mbedmicro-rtos-mbed/basic/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
using utest::v1::Case;
3131

32+
#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
33+
#define TEST_STACK_SIZE 512
34+
#else
3235
#define TEST_STACK_SIZE 256
36+
#endif
3337
#define ONE_MILLI_SEC 1000
3438

3539
volatile uint32_t elapsed_time_ms = 0;

TESTS/mbedmicro-rtos-mbed/event_flags/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ using utest::v1::Case;
3030
#error [NOT_SUPPORTED] test not supported
3131
#endif
3232

33+
#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
34+
#define THREAD_STACK_SIZE 512
35+
#else
3336
#define THREAD_STACK_SIZE 320 /* 512B stack on GCC_ARM compiler cause out of memory on some 16kB RAM boards e.g. NUCLEO_F070RB */
37+
#endif
3438

3539
#define MAX_FLAG_POS 30
3640
#define PROHIBITED_FLAG_POS 31

TESTS/mbedmicro-rtos-mbed/mail/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
using namespace utest::v1;
3131

32+
#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
33+
#define THREAD_STACK_SIZE 512
34+
#else
3235
#define THREAD_STACK_SIZE 320 /* larger stack cause out of heap memory on some 16kB RAM boards in multi thread test*/
36+
#endif
3337
#define QUEUE_SIZE 16
3438
#define THREAD_1_ID 1
3539
#define THREAD_2_ID 2

TESTS/mbedmicro-rtos-mbed/malloc/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ volatile bool thread_should_continue = true;
3737

3838
#if defined(__CORTEX_A9)
3939
#define THREAD_STACK_SIZE 512
40+
#elif defined(__CORTEX_M23) || defined(__CORTEX_M33)
41+
#define THREAD_STACK_SIZE 512
4042
#else
4143
#define THREAD_STACK_SIZE 256
4244
#endif

TESTS/mbedmicro-rtos-mbed/mutex/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929

3030
using namespace utest::v1;
3131

32+
#if defined(__CORTEX_M23) || defined(__CORTEX_M33)
33+
#define TEST_STACK_SIZE 768
34+
#else
3235
#define TEST_STACK_SIZE 512
36+
#endif
3337

3438
#define TEST_LONG_DELAY 20
3539
#define TEST_DELAY 10

TESTS/mbedmicro-rtos-mbed/systimer/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#if !MBED_TICKLESS
16+
#ifndef MBED_TICKLESS
1717
#error [NOT_SUPPORTED] Tickless mode not supported for this target.
1818
#endif
1919

TESTS/mbedmicro-rtos-mbed/threads/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define THREAD_STACK_SIZE 512
3333
#if defined(__CORTEX_A9)
3434
#define PARALLEL_THREAD_STACK_SIZE 512
35+
#elif defined(__CORTEX_M23) || defined(__CORTEX_M33)
36+
#define PARALLEL_THREAD_STACK_SIZE 512
3537
#else
3638
#define PARALLEL_THREAD_STACK_SIZE 384
3739
#endif

TESTS/netsocket/tcp/main.cpp

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using namespace utest::v1;
3232
namespace
3333
{
3434
NetworkInterface* net;
35+
Timer tc_bucket; // Timer to limit a test cases run time
3536
}
3637

3738
char tcp_global::rx_buffer[RX_BUFF_SIZE];
@@ -66,24 +67,32 @@ static void _ifdown() {
6667
printf("MBED: ifdown\n");
6768
}
6869

69-
void tcpsocket_connect_to_echo_srv(TCPSocket& sock) {
70+
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock) {
7071
SocketAddress tcp_addr;
7172

7273
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
7374
tcp_addr.set_port(MBED_CONF_APP_ECHO_SERVER_PORT);
7475

75-
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
76-
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.connect(tcp_addr));
76+
nsapi_error_t err = sock.open(get_interface());
77+
if (err != NSAPI_ERROR_OK) {
78+
return err;
79+
}
80+
81+
return sock.connect(tcp_addr);
7782
}
7883

79-
void tcpsocket_connect_to_discard_srv(TCPSocket& sock) {
84+
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock) {
8085
SocketAddress tcp_addr;
8186

8287
get_interface()->gethostbyname(MBED_CONF_APP_ECHO_SERVER_ADDR, &tcp_addr);
8388
tcp_addr.set_port(9);
8489

85-
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.open(get_interface()));
86-
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.connect(tcp_addr));
90+
nsapi_error_t err = sock.open(get_interface());
91+
if (err != NSAPI_ERROR_OK) {
92+
return err;
93+
}
94+
95+
return sock.connect(tcp_addr);
8796
}
8897

8998
void fill_tx_buffer_ascii(char *buff, size_t len)
@@ -93,16 +102,23 @@ void fill_tx_buffer_ascii(char *buff, size_t len)
93102
}
94103
}
95104

105+
int split2half_rmng_tcp_test_time()
106+
{
107+
return (tcp_global::TESTS_TIMEOUT-tc_bucket.read())/2;
108+
}
109+
96110
// Test setup
97111
utest::v1::status_t greentea_setup(const size_t number_of_cases)
98112
{
99-
GREENTEA_SETUP(480, "default_auto");
113+
GREENTEA_SETUP(tcp_global::TESTS_TIMEOUT, "default_auto");
100114
_ifup();
115+
tc_bucket.start();
101116
return greentea_test_setup_handler(number_of_cases);
102117
}
103118

104119
void greentea_teardown(const size_t passed, const size_t failed, const failure_t failure)
105120
{
121+
tc_bucket.stop();
106122
_ifdown();
107123
return greentea_test_teardown_handler(passed, failed, failure);
108124
}

TESTS/netsocket/tcp/tcp_tests.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@
2121
NetworkInterface* get_interface();
2222
void drop_bad_packets(TCPSocket& sock, int orig_timeout);
2323
void fill_tx_buffer_ascii(char *buff, size_t len);
24-
void tcpsocket_connect_to_echo_srv(TCPSocket& sock);
25-
void tcpsocket_connect_to_discard_srv(TCPSocket& sock);
24+
nsapi_error_t tcpsocket_connect_to_echo_srv(TCPSocket& sock);
25+
nsapi_error_t tcpsocket_connect_to_discard_srv(TCPSocket& sock);
26+
27+
/**
28+
* Single testcase might take only half of the remaining execution time
29+
*/
30+
int split2half_rmng_tcp_test_time(); // [s]
2631

2732
namespace tcp_global
2833
{
34+
static const int TESTS_TIMEOUT = 480;
2935
static const int TCP_OS_STACK_SIZE = 1024;
3036

3137
static const int RX_BUFF_SIZE = 1220;

TESTS/netsocket/tcp/tcpsocket_echotest.cpp

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ namespace
3737
1100,1200};
3838
TCPSocket sock;
3939
Semaphore tx_sem(0, 1);
40+
41+
Timer tc_exec_time;
42+
int time_allotted;
4043
}
4144

4245
static void _sigio_handler(osThreadId id) {
@@ -45,7 +48,10 @@ static void _sigio_handler(osThreadId id) {
4548

4649
void TCPSOCKET_ECHOTEST()
4750
{
48-
tcpsocket_connect_to_echo_srv(sock);
51+
if (tcpsocket_connect_to_echo_srv(sock) != NSAPI_ERROR_OK) {
52+
TEST_FAIL();
53+
return;
54+
}
4955

5056
int recvd;
5157
int sent;
@@ -57,6 +63,8 @@ void TCPSOCKET_ECHOTEST()
5763
if (sent < 0) {
5864
printf("[Round#%02d] network error %d\n", x, sent);
5965
TEST_FAIL();
66+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
67+
return;
6068
}
6169

6270
int bytes2recv = sent;
@@ -65,6 +73,8 @@ void TCPSOCKET_ECHOTEST()
6573
if (recvd < 0) {
6674
printf("[Round#%02d] network error %d\n", x, recvd);
6775
TEST_FAIL();
76+
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
77+
return;
6878
}
6979
bytes2recv -= recvd;
7080
}
@@ -80,10 +90,15 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes)
8090
while (bytes2recv) {
8191
recvd = sock.recv(&(tcp_global::rx_buffer[*(int*)receive_bytes-bytes2recv]), bytes2recv);
8292
if (recvd == NSAPI_ERROR_WOULD_BLOCK) {
93+
if (tc_exec_time.read() >= time_allotted) {
94+
TEST_FAIL();
95+
break;
96+
}
8397
wait(1);
8498
continue;
8599
} else if (recvd < 0) {
86100
TEST_FAIL();
101+
break;
87102
}
88103
bytes2recv -= recvd;
89104
}
@@ -99,6 +114,9 @@ void tcpsocket_echotest_nonblock_receiver(void *receive_bytes)
99114

100115
void TCPSOCKET_ECHOTEST_NONBLOCK()
101116
{
117+
tc_exec_time.start();
118+
time_allotted = split2half_rmng_tcp_test_time(); // [s]
119+
102120
tcpsocket_connect_to_echo_srv(sock);
103121
sock.set_blocking(false);
104122
sock.sigio(callback(_sigio_handler, Thread::gettid()));
@@ -124,19 +142,30 @@ void TCPSOCKET_ECHOTEST_NONBLOCK()
124142
while (bytes2send > 0) {
125143
sent = sock.send(&(tcp_global::tx_buffer[pkt_s-bytes2send]), bytes2send);
126144
if (sent == NSAPI_ERROR_WOULD_BLOCK) {
127-
TEST_ASSERT_NOT_EQUAL(osEventTimeout, osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status);
145+
if (tc_exec_time.read() >= time_allotted ||
146+
osSignalWait(SIGNAL_SIGIO, SIGIO_TIMEOUT).status == osEventTimeout) {
147+
thread->terminate();
148+
delete thread;
149+
TEST_FAIL();
150+
goto END;
151+
}
128152
continue;
129153
} else if (sent <= 0) {
130154
printf("[Sender#%02d] network error %d\n", s_idx, sent);
155+
thread->terminate();
156+
delete thread;
131157
TEST_FAIL();
158+
goto END;
132159
}
133160
bytes2send -= sent;
134161
}
135162
printf("[Sender#%02d] bytes sent: %d\n", s_idx, pkt_s);
136-
tx_sem.wait();
163+
tx_sem.wait(split2half_rmng_tcp_test_time());
137164
thread->join();
138165
delete thread;
139166
}
167+
END:
168+
tc_exec_time.stop();
140169
free(stack_mem);
141170
TEST_ASSERT_EQUAL(NSAPI_ERROR_OK, sock.close());
142171
}

0 commit comments

Comments
 (0)